如何为devspace进行PHPFPM+Nginx部署?
实际上,我正在使用PHP并拥有这个devspace.yaml。
[...]
deployments:
- name: panel
helm:
componentChart: true
values:
containers:
- image: registry.digitalocean.com/mycompany/myapp
service:
ports:
- port: 80
ingress:
rules:
- host: "mydomain.com.ar"我的Dockerfile就像
FROM php:7.4.4-apache
[...]
EXPOSE 80
CMD ["apache2-foreground"]一切都很好,主机在大会上注册。但是,我喜欢从PHPApache升级到PHP+ Nginx。
我将我的Dockerfile从FROM php:7.4.4-apache更改为FROM php:7.4.4-fpm,并删除EXPOSE和COMMAND。但是现在呢?PHP和NGinx的特殊配置现在没有必要了。
然后,如何将nginx服务添加到devspace.yaml并连接到php?
发布于 2021-03-25 15:41:09
devspace.yaml
version: v1beta9
images:
app-nginx:
image: registry.digitalocean.com/reyesoft/app-nginx
dockerfile: build/nginx/Dockerfile
# preferSyncOverRebuild: true
preferSyncOverRebuild: true
appendDockerfileInstructions:
- USER root
app-php:
image: registry.digitalocean.com/reyesoft/app-php
dockerfile: build/php/Dockerfile
preferSyncOverRebuild: true
injectRestartHelper: true
appendDockerfileInstructions:
- USER root
deployments:
- name: app
helm:
componentChart: true
values:
containers:
- name: app-nginx
image: registry.digitalocean.com/reyesoft/app-nginx
- name: panel
image: registry.digitalocean.com/reyesoft/app-php
env: &panelEnv
- name: APP_ENV
value: "develop"
service:
ports:
- port: 80
ingress:
# tls: true
rules:
- host: "reyesoft.com"
[...]nginx.conf
server {
# [...]
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root /usr/share/nginx/html/public/;
include php_location.include/*.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
include fastcgi_params;
}
}发布于 2021-03-09 08:52:39
您可以在一个容器中使用两个容器,一个用于PHP,另一个用于Nginx。这种方式(因为他们在同一个舱),他们可以很容易地通过端口9000通信。
PHP容器:
来自php:7.4-fpm .
Nginx集装箱:
来自nginx:1.9-高山.
确保在Nginx配置中包括FPM:
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}在"devspace.yaml“配置中,您将在图像小节中列出这两种配置。
您可以将网站数据挂载到两个容器;小心,您不能有多个readOnly: false卷挂载;在下面的代码段中,两者都是只读的;如果需要写入,则相应地进行更改。
deployments:
- name: my-component
helm:
componentChart: true
values:
containers:
- name: nginx
image: "nginx:1.9-alpine"
volumeMounts:
- containerPath: /var/www/html
volume:
name: website-data
subPath: /website-data
readOnly: true
- name: php-fpm
image: "php:7.4-fpm"
volumeMounts:
- containerPath: /var/www/html
volume:
name: website-data
subPath: /website-data
readOnly: true
volumes:
- name: website-data
size: "5Gi"https://stackoverflow.com/questions/66522089
复制相似问题