├── 7.4 ├── .dockerignore ├── Dockerfile ├── config │ ├── fpm-pool.conf │ ├── nginx.conf │ ├── php.ini │ └── supervisord.conf └── src │ ├── index.php │ └── test.html └── README.md /7.4/.dockerignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Desktop.ini 3 | .idea 4 | *~ 5 | *.swp 6 | ._* 7 | *.pyc 8 | Thumbs.db 9 | .Spotlight-V100 10 | .Trashes 11 | .env 12 | .svn 13 | .cvs 14 | .travis 15 | .git* 16 | .*.yml 17 | CODE_OF_CONDUCT.md 18 | app/vendor/**/test 19 | app/vendor/**/tests -------------------------------------------------------------------------------- /7.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.11 2 | 3 | LABEL Maintainer="Jabar Digital Service " \ 4 | Description="Lightweight container with Nginx 1.16 & PHP-FPM 7.4 based on Alpine Linux (forked from trafex/alpine-nginx-php7)." 5 | 6 | ADD https://dl.bintray.com/php-alpine/key/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub 7 | 8 | # make sure you can use HTTPS 9 | RUN apk --update add ca-certificates 10 | 11 | RUN echo "https://dl.bintray.com/php-alpine/v3.11/php-7.4" >> /etc/apk/repositories 12 | 13 | # Install packages 14 | RUN apk --no-cache add php php-fpm php-opcache php-openssl php-curl \ 15 | nginx supervisor curl 16 | 17 | # https://github.com/codecasts/php-alpine/issues/21 18 | RUN ln -s /usr/bin/php7 /usr/bin/php 19 | 20 | # Configure nginx 21 | COPY config/nginx.conf /etc/nginx/nginx.conf 22 | 23 | # Remove default server definition 24 | RUN rm /etc/nginx/conf.d/default.conf 25 | 26 | # Configure PHP-FPM 27 | COPY config/fpm-pool.conf /etc/php7/php-fpm.d/www.conf 28 | COPY config/php.ini /etc/php7/conf.d/custom.ini 29 | 30 | # Configure supervisord 31 | COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf 32 | 33 | # Setup document root 34 | RUN mkdir -p /var/www/html 35 | 36 | # Make sure files/folders needed by the processes are accessable when they run under the nobody user 37 | RUN chown -R nobody.nobody /var/www/html && \ 38 | chown -R nobody.nobody /run && \ 39 | chown -R nobody.nobody /var/lib/nginx && \ 40 | chown -R nobody.nobody /var/log/nginx 41 | 42 | # Switch to use a non-root user from here on 43 | USER nobody 44 | 45 | # Add application 46 | WORKDIR /var/www/html 47 | COPY --chown=nobody src/ /var/www/html/ 48 | 49 | # Expose the port nginx is reachable on 50 | EXPOSE 8080 51 | 52 | # Let supervisord start nginx & php-fpm 53 | CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] 54 | 55 | # Configure a healthcheck to validate that everything is up&running 56 | HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping 57 | -------------------------------------------------------------------------------- /7.4/config/fpm-pool.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | ; Log to stderr 3 | error_log = /dev/stderr 4 | 5 | [www] 6 | ; The address on which to accept FastCGI requests. 7 | ; Valid syntaxes are: 8 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 9 | ; a specific port; 10 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 11 | ; a specific port; 12 | ; 'port' - to listen on a TCP socket to all addresses 13 | ; (IPv6 and IPv4-mapped) on a specific port; 14 | ; '/path/to/unix/socket' - to listen on a unix socket. 15 | ; Note: This value is mandatory. 16 | listen = /run/php-fpm.sock 17 | 18 | ; Enable status page 19 | pm.status_path = /fpm-status 20 | 21 | ; Ondemand process manager 22 | pm = static 23 | 24 | ; The number of child processes to be created when pm is set to 'static' and the 25 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 26 | ; This value sets the limit on the number of simultaneous requests that will be 27 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 28 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 29 | ; CGI. The below defaults are based on a server without much resources. Don't 30 | ; forget to tweak pm.* to fit your needs. 31 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 32 | ; Note: This value is mandatory. 33 | pm.max_children = 100 34 | 35 | ; The number of seconds after which an idle process will be killed. 36 | ; Note: Used only when pm is set to 'ondemand' 37 | ; Default Value: 10s 38 | pm.process_idle_timeout = 10s; 39 | 40 | ; The number of requests each child process should execute before respawning. 41 | ; This can be useful to work around memory leaks in 3rd party libraries. For 42 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 43 | ; Default Value: 0 44 | pm.max_requests = 1000 45 | 46 | ; Make sure the FPM workers can reach the environment variables for configuration 47 | clear_env = no 48 | 49 | ; Catch output from PHP 50 | catch_workers_output = yes 51 | 52 | ; Remove the 'child 10 said into stderr' prefix in the log and only show the actual message 53 | decorate_workers_output = no 54 | 55 | ; Enable ping page to use in healthcheck 56 | ping.path = /fpm-ping 57 | -------------------------------------------------------------------------------- /7.4/config/nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 1; 2 | error_log stderr warn; 3 | pid /run/nginx.pid; 4 | 5 | events { 6 | worker_connections 1024; 7 | } 8 | 9 | http { 10 | include mime.types; 11 | default_type application/octet-stream; 12 | 13 | # Define custom log format to include reponse times 14 | log_format main_timed '$remote_addr - $remote_user [$time_local] "$request" ' 15 | '$status $body_bytes_sent "$http_referer" ' 16 | '"$http_user_agent" "$http_x_forwarded_for" ' 17 | '$request_time $upstream_response_time $pipe $upstream_cache_status'; 18 | 19 | access_log /dev/stdout main_timed; 20 | error_log /dev/stderr notice; 21 | 22 | keepalive_timeout 65; 23 | 24 | server_tokens off; 25 | 26 | # Write temporary files to /tmp so they can be created as a non-privileged user 27 | client_body_temp_path /tmp/client_temp; 28 | proxy_temp_path /tmp/proxy_temp_path; 29 | fastcgi_temp_path /tmp/fastcgi_temp; 30 | uwsgi_temp_path /tmp/uwsgi_temp; 31 | scgi_temp_path /tmp/scgi_temp; 32 | 33 | # Default server definition 34 | server { 35 | listen [::]:8080 default_server; 36 | listen 8080 default_server; 37 | server_name _; 38 | 39 | sendfile off; 40 | 41 | root /var/www/html; 42 | index index.php index.html; 43 | 44 | location / { 45 | # First attempt to serve request as file, then 46 | # as directory, then fall back to index.php 47 | try_files $uri $uri/ /index.php?q=$uri&$args; 48 | } 49 | 50 | # Redirect server error pages to the static page /50x.html 51 | error_page 500 502 503 504 /50x.html; 52 | location = /50x.html { 53 | root /var/lib/nginx/html; 54 | } 55 | 56 | # Pass the PHP scripts to PHP-FPM listening on 127.0.0.1:9000 57 | location ~ \.php$ { 58 | try_files $uri =404; 59 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 60 | fastcgi_pass unix:/run/php-fpm.sock; 61 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 62 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 63 | fastcgi_index index.php; 64 | include fastcgi_params; 65 | } 66 | 67 | location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { 68 | expires 5d; 69 | } 70 | 71 | # Deny access to . files, for security 72 | location ~ /\. { 73 | log_not_found off; 74 | deny all; 75 | } 76 | 77 | # Allow fpm ping and status from localhost 78 | location ~ ^/(fpm-status|fpm-ping)$ { 79 | access_log off; 80 | allow 127.0.0.1; 81 | deny all; 82 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 83 | include fastcgi_params; 84 | fastcgi_pass unix:/run/php-fpm.sock; 85 | } 86 | } 87 | 88 | gzip on; 89 | gzip_proxied any; 90 | gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss; 91 | gzip_vary on; 92 | gzip_disable "msie6"; 93 | 94 | # Include other server configs 95 | include /etc/nginx/conf.d/*.conf; 96 | } 97 | -------------------------------------------------------------------------------- /7.4/config/php.ini: -------------------------------------------------------------------------------- 1 | expose_php = Off 2 | 3 | [Date] 4 | date.timezone="UTC" 5 | -------------------------------------------------------------------------------- /7.4/config/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | logfile=/dev/null 4 | logfile_maxbytes=0 5 | pidfile=/run/supervisord.pid 6 | 7 | [program:php-fpm] 8 | command=php-fpm7 -F 9 | stdout_logfile=/dev/stdout 10 | stdout_logfile_maxbytes=0 11 | stderr_logfile=/dev/stderr 12 | stderr_logfile_maxbytes=0 13 | autorestart=false 14 | startretries=0 15 | 16 | [program:nginx] 17 | command=nginx -g 'daemon off;' 18 | stdout_logfile=/dev/stdout 19 | stdout_logfile_maxbytes=0 20 | stderr_logfile=/dev/stderr 21 | stderr_logfile_maxbytes=0 22 | autorestart=false 23 | startretries=0 24 | -------------------------------------------------------------------------------- /7.4/src/index.php: -------------------------------------------------------------------------------- 1 | `) 13 | * Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs 14 | 15 | ## Credits 16 | Forked from https://github.com/TrafeX/docker-php-nginx --------------------------------------------------------------------------------