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-f
You should deploy two container, one with fpm, the other with nginx, and you should link them.
Even though you can use supervisor in order to monitore multiple processes within the same container, Docker philosophy is to have one process per container.
Something like:
docker run --name php -v ./code:/code php:7-fpm
docker run --name nginx -v ./code:/code -v site.conf:/etc/nginx/conf.d/site.conf --link php nginx:latest
With site.conf with
server {
index index.php index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
(Shamefully inspired by http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/)