Currently there's an fpm variant that includes apache. I'd really like to see an nginx variant of this as well. Running nginx/fpm in separate containers leads to nginx dns caching issues when the fpm container is redeployed.
Are there plans to add an nginx variant and/or a reason why we shouldn't?
There are no plans to add an nginx variant, since we'd then have to start both NGINX and FPM in the same container, and manage/monitor both their lifecycles directly (since NGINX does not, to my knowledge, have a way to directly invoke and manage the FPM processes in a simple well-supported way).
The Apache variant does _NOT_ use FPM -- it uses mod_php. :+1:
This setup has proven to be simple and reliable for me:
supervisord.conf
[supervisord]
nodaemon = true
logfile = /dev/null
logfile_maxbytes = 0
[program:php-fpm]
command = /usr/local/sbin/php-fpm
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
[program:nginx]
command = /usr/sbin/nginx -g "daemon off;"
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server {
listen 80;
server_name _;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass localhost:9000;
}
}
}
Dockerfile
FROM php:7.1-fpm
RUN set -e; \
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
found=''; \
for server in \
ha.pool.sks-keyservers.net \
hkp://keyserver.ubuntu.com:80 \
hkp://p80.pool.sks-keyservers.net:80 \
pgp.mit.edu \
; do \
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
done; \
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
exit 0
RUN echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates \
nginx \
nginx-module-xslt \
nginx-module-geoip \
nginx-module-image-filter \
nginx-module-perl \
nginx-module-njs \
gettext-base \
supervisor \
&& rm -rf /var/lib/apt/lists/*
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["/usr/bin/supervisord"]
Actually, this past weekend I started using https://github.com/bkuhl/fpm-nginx/ in production. It's the same concept, but using S6 Overlay instead of Supervisor.
Most helpful comment
This setup has proven to be simple and reliable for me:
supervisord.conf
nginx.conf
Dockerfile