How can I do a PHPFPM+Nginx deployment for devspace?
Actually, I’m working with PHP-Apache and have this 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"
My Dockerfile is like
FROM php:7.4.4-apache
[...]
EXPOSE 80
CMD ["apache2-foreground"]
All is working fine and Host is registered on Ingress. But, I like to upgrade from PHPApache to PHP-FPM + Nginx.
I change my Dockerfile from FROM php:7.4.4-apache
to FROM php:7.4.4-fpm
and EXPOSE
and COMMAND
are removed. But now? Particular configurations for PHP and NGinx are no neccesary now.
Then, how can I add nginx service to devspace.yaml
and connect to php-fpm?
2
Answers
devspace.yaml
:nginx.conf
:You can use two containers in one pod, one for the PHP-FPM and one for the Nginx.
This way (as they are in the same pod), they can communicate easily via port 9000.
PHP Container:
FROM php:7.4-fpm
…
Nginx Container:
FROM nginx:1.9-alpine
…
Make sure to include FPM in Nginx configuration:
On "devspace.yaml" configuration, you will list both of them under the images stanza.
You can mount the website-data to both containers; beware, you can not have more than one readOnly: false volume mount; in the following snippet, both mount it as read-only; if you need to write, then change accordingly.