mirror of
https://github.com/mashirozx/docker-php-nginx.git
synced 2024-11-22 14:58:15 +08:00
Switched to Alpine Linux for a smaller footprint
This commit is contained in:
parent
ac0380bf08
commit
fb9719f647
29
Dockerfile
29
Dockerfile
@ -1,26 +1,17 @@
|
|||||||
FROM php:7.0-fpm
|
FROM alpine:latest
|
||||||
|
|
||||||
# Install Nginx
|
# Install packages
|
||||||
ENV NGINX_VERSION 1.9.11-1~jessie
|
RUN apk --update add php7-fpm nginx supervisor --repository http://nl.alpinelinux.org/alpine/edge/testing/
|
||||||
|
|
||||||
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
|
|
||||||
&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y ca-certificates nginx=${NGINX_VERSION} gettext-base \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Install supervisor
|
|
||||||
RUN apt-get update && apt-get install -y supervisor
|
|
||||||
|
|
||||||
# Configure nginx
|
# Configure nginx
|
||||||
RUN rm /etc/nginx/conf.d/default.conf
|
COPY config/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY config/nginx.conf /etc/nginx/conf.d/nginx.conf
|
|
||||||
|
|
||||||
# Configure supervisor
|
|
||||||
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
|
||||||
|
|
||||||
# Configure PHP-FPM
|
# Configure PHP-FPM
|
||||||
COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini
|
COPY config/fpm-pool.conf /etc/php7/php-fpm.d/zzz_custom.conf
|
||||||
|
COPY config/php.ini /etc/php7/conf.d/zzz_custom.ini
|
||||||
|
|
||||||
|
# Configure supervisord
|
||||||
|
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
# Add application
|
# Add application
|
||||||
RUN mkdir -p /var/www/html
|
RUN mkdir -p /var/www/html
|
||||||
@ -28,4 +19,4 @@ WORKDIR /var/www/html
|
|||||||
COPY src/ /var/www/html/
|
COPY src/ /var/www/html/
|
||||||
|
|
||||||
EXPOSE 80 443
|
EXPOSE 80 443
|
||||||
CMD ["/usr/bin/supervisord"]
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||||
|
28
config/fpm-pool.conf
Normal file
28
config/fpm-pool.conf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
[www]
|
||||||
|
; Enable status page
|
||||||
|
pm.status_path = /fpm-status
|
||||||
|
|
||||||
|
; Ondemand process manager
|
||||||
|
pm = ondemand
|
||||||
|
|
||||||
|
; The number of child processes to be created when pm is set to 'static' and the
|
||||||
|
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
||||||
|
; This value sets the limit on the number of simultaneous requests that will be
|
||||||
|
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||||
|
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||||
|
; CGI. The below defaults are based on a server without much resources. Don't
|
||||||
|
; forget to tweak pm.* to fit your needs.
|
||||||
|
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
||||||
|
; Note: This value is mandatory.
|
||||||
|
pm.max_children = 50
|
||||||
|
|
||||||
|
; The number of seconds after which an idle process will be killed.
|
||||||
|
; Note: Used only when pm is set to 'ondemand'
|
||||||
|
; Default Value: 10s
|
||||||
|
pm.process_idle_timeout = 10s;
|
||||||
|
|
||||||
|
; The number of requests each child process should execute before respawning.
|
||||||
|
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||||
|
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||||
|
; Default Value: 0
|
||||||
|
pm.max_requests = 500
|
@ -1,49 +1,62 @@
|
|||||||
server {
|
worker_processes 1;
|
||||||
listen [::]:80 default_server;
|
|
||||||
listen 80 default_server;
|
|
||||||
server_name _;
|
|
||||||
|
|
||||||
sendfile off;
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
root /var/www/html;
|
http {
|
||||||
index index.php index.html;
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
error_log /dev/stderr info;
|
keepalive_timeout 65;
|
||||||
access_log /dev/stdout;
|
|
||||||
|
|
||||||
location / {
|
server {
|
||||||
# First attempt to serve request as file, then
|
listen [::]:80 default_server;
|
||||||
# as directory, then fall back to index.php
|
listen 80 default_server;
|
||||||
try_files $uri $uri/ /index.php?q=$uri&$args;
|
server_name _;
|
||||||
}
|
|
||||||
|
|
||||||
# redirect server error pages to the static page /50x.html
|
sendfile off;
|
||||||
#
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
}
|
|
||||||
|
|
||||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
root /var/www/html;
|
||||||
#
|
index index.php index.html;
|
||||||
location ~ \.php$ {
|
|
||||||
try_files $uri =404;
|
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
||||||
fastcgi_pass localhost:9000;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
include fastcgi_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
|
error_log /dev/stderr info;
|
||||||
expires 5d;
|
access_log /dev/stdout;
|
||||||
}
|
|
||||||
|
|
||||||
# deny access to . files, for security
|
location / {
|
||||||
#
|
# First attempt to serve request as file, then
|
||||||
location ~ /\. {
|
# as directory, then fall back to index.php
|
||||||
log_not_found off;
|
try_files $uri $uri/ /index.php?q=$uri&$args;
|
||||||
deny all;
|
}
|
||||||
|
|
||||||
|
# redirect server error pages to the static page /50x.html
|
||||||
|
#
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||||
|
#
|
||||||
|
location ~ \.php$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass localhost:9000;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
|
||||||
|
expires 5d;
|
||||||
|
}
|
||||||
|
|
||||||
|
# deny access to . files, for security
|
||||||
|
#
|
||||||
|
location ~ /\. {
|
||||||
|
log_not_found off;
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
nodaemon=true
|
nodaemon=true
|
||||||
|
|
||||||
[program:php-fpm]
|
[program:php-fpm]
|
||||||
command=php-fpm
|
command=php-fpm7 -F
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/stdout
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
|
Loading…
Reference in New Issue
Block a user