I have a need to combine the php-fpm with nginx in one dockerfile for production deployment.
So is it better to :
(1) Start the dockerfile using php:7.1.8-fpm and then install nginx image layer on top of it ?
(2) Or do you recommend using nginx image and then installing php-fpm using apt-get ?
PS: I do not have a docker-compose build option for production deployment. On my development environment, I already use docker-compose and build multi-container app easily from two images. Our organization devops do not support docker-compose based deployment for prod environment.
You should deploy two container, one with
fpm
, the other withnginx
, and you should link them. Even though you can usesupervisor
in order to monitore multiple processes within the same container,Docker
philosophy is to have one process per container.Something like:
With
site.conf
with(Shamefully inspired by http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/)
Nginx installation is much easier than PHP so it should be easier for you to install Nginx into ready-to-use official PHP image. Here is the example Dockerfile showing how your goal can be reached with example of installing few PHP extensions:
The
nginx-site.conf
file contain your nginx http host configuration. The example below is for Symfony app:The
entrypoint.sh
will run nginx and php-fpm on container startup (otherwise only php-fpm will be started as the default action of the official PHP image):Of course this is not a best way from the best practice perspective, but I hope this is the answer for your question.