Created
January 14, 2017 07:57
-
-
Save jckimble/a65517528502ce57371127a1c37fee94 to your computer and use it in GitHub Desktop.
nginx php7 docker file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest | |
COPY nginx.conf /etc/nginx/nginx.conf | |
COPY fpm-pool.conf /etc/php7/php-fpm.d/zzz_custom.conf | |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
COPY bower.json composer.json gulpfile.js package.json /var/www/ | |
ADD resources /var/www/resources | |
ADD templates /var/www/templates | |
WORKDIR /var/www | |
RUN apk --update add php7 php7-fpm php7-openssl php7-json php7-curl php7-gd php7-phar php7-iconv php7-mbstring nginx supervisor --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ \ | |
&& apk add --virtual .build nodejs ruby git curl \ | |
&& gem install sass --no-rdoc --no-ri \ | |
&& ln -s /usr/bin/php7 /usr/bin/php \ | |
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \ | |
&& echo "strict-ssl=false" > /root/.npmrc \ | |
&& cd /var/www && npm install && npm install gulp -g && gulp build\ | |
&& rm -rf /var/www/node_modules /var/www/.sass-cache /var/www/bower_components \ | |
&& rm -rf /var/www/*.json /var/www/gulpfile.js /var/www/composer.lock /var/www/resources \ | |
&& rm -rf /root/.npm /root/.composer /root/.cache \ | |
&& rm -rf /usr/lib/node_modules /usr/lib/ruby \ | |
&& rm /etc/nginx/conf.d/default.conf \ | |
&& rm /usr/bin/composer \ | |
&& apk del .build \ | |
&& rm /var/cache/apk/* | |
EXPOSE 80 | |
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/conf.d/supervisord.conf"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
pid /run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
access_log /dev/stdout; | |
error_log /dev/stderr info; | |
keepalive_timeout 65; | |
server { | |
listen [::]:80 default_server; | |
listen 80 default_server; | |
server_name _; | |
sendfile off; | |
root /var/www/public; | |
index index.php index.html; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to index.php | |
try_files $uri $uri/ /index.php; | |
} | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /var/lib/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; | |
log_not_found off; | |
access_log off; | |
} | |
# deny access to . files, for security | |
# | |
location ~ /\. { | |
log_not_found off; | |
deny all; | |
} | |
} | |
include conf.d/*.conf; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[supervisord] | |
nodaemon=true | |
[program:php-fpm] | |
command=php-fpm7 -F | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 | |
[program:nginx] | |
command=nginx -g 'daemon off;' | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment