commit fd3195a8b23bcde7f388734933a5b72f115b820c Author: paspo Date: Fri Dec 13 10:00:45 2024 +0100 initial release (nginx+php ok) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe9c8ee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3.21 + +RUN \ + apk -U upgrade && \ + apk add tini nginx gettext-envsubst openssh-server php84 php84-fpm php83 php83-fpm php82 php82-fpm + +COPY rootfs / + +VOLUME [ "/www", "/ssh" ] + +ENV \ + USERNAME=theuser \ + PHP=none + +ENTRYPOINT [ "/sbin/tini", "/app/entrypoint.sh" ] diff --git a/rootfs/app/entrypoint.sh b/rootfs/app/entrypoint.sh new file mode 100755 index 0000000..8618ef7 --- /dev/null +++ b/rootfs/app/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +WEBROOT=/www +PHP=${PHP:-none} +USERNAME=${USERNAME:-theuser} +adduser -DH -h "${WEBROOT}" -G "nginx" -u "1000" "${USERNAME}" + +chown "${USERNAME}:nginx" "${WEBROOT}" -R +find "${WEBROOT}" -type d -exec chmod 0755 {} \; +find "${WEBROOT}" -type f -exec chmod 0644 {} \; + +envsubst < /app/nginx.conf.tpl > /etc/nginx/http.d/default.conf + +case "${PHP}" in + "php84") /usr/sbin/php-fpm84 -D ;; + "php83") /usr/sbin/php-fpm83 -D ;; + "php82") /usr/sbin/php-fpm82 -D ;; + *) ;; +esac + +nginx diff --git a/rootfs/app/nginx.conf.tpl b/rootfs/app/nginx.conf.tpl new file mode 100644 index 0000000..629969e --- /dev/null +++ b/rootfs/app/nginx.conf.tpl @@ -0,0 +1,46 @@ +error_log /dev/stdout info; +access_log /dev/stdout; + +server { + listen 80 default_server; + listen [::]:80 default_server; + root /www; + # server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + index index.html index.htm; + + # autoindex on; + # autoindex_exact_size off; + # autoindex_format html; + # autoindex_localtime on; + } + + #error_page 404 /404.html; + + location = /404.html { + internal; + } + + # 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; + } + + include /etc/nginx/custom.d/${PHP}.conf; + + gzip on; + gzip_proxied any; + gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js image/x-icon font/woff2 font/woff application/x-font-woff; + gzip_vary on; + gzip_disable "msie6"; + + etag on; + if_modified_since exact; + add_header Pragma "public"; + add_header Cache-Control "max-age=31536000, public"; +} diff --git a/rootfs/etc/nginx/conf.d/nodaemon.conf b/rootfs/etc/nginx/conf.d/nodaemon.conf new file mode 100644 index 0000000..ef1f9c1 --- /dev/null +++ b/rootfs/etc/nginx/conf.d/nodaemon.conf @@ -0,0 +1 @@ +daemon off; diff --git a/rootfs/etc/nginx/custom.d/none.conf b/rootfs/etc/nginx/custom.d/none.conf new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/nginx/custom.d/php82.conf b/rootfs/etc/nginx/custom.d/php82.conf new file mode 100644 index 0000000..4431e5a --- /dev/null +++ b/rootfs/etc/nginx/custom.d/php82.conf @@ -0,0 +1,6 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.*)$; + fastcgi_pass 127.0.0.1:9000; + include fastcgi.conf; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +} diff --git a/rootfs/etc/nginx/custom.d/php83.conf b/rootfs/etc/nginx/custom.d/php83.conf new file mode 100644 index 0000000..4431e5a --- /dev/null +++ b/rootfs/etc/nginx/custom.d/php83.conf @@ -0,0 +1,6 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.*)$; + fastcgi_pass 127.0.0.1:9000; + include fastcgi.conf; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +} diff --git a/rootfs/etc/nginx/custom.d/php84.conf b/rootfs/etc/nginx/custom.d/php84.conf new file mode 100644 index 0000000..4431e5a --- /dev/null +++ b/rootfs/etc/nginx/custom.d/php84.conf @@ -0,0 +1,6 @@ +location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.*)$; + fastcgi_pass 127.0.0.1:9000; + include fastcgi.conf; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +} diff --git a/rootfs/etc/php82/php-fpm.d/errlog.conf b/rootfs/etc/php82/php-fpm.d/errlog.conf new file mode 100644 index 0000000..e50a4ee --- /dev/null +++ b/rootfs/etc/php82/php-fpm.d/errlog.conf @@ -0,0 +1 @@ +error_log = /dev/stderr diff --git a/rootfs/etc/php83/php-fpm.d/errlog.conf b/rootfs/etc/php83/php-fpm.d/errlog.conf new file mode 100644 index 0000000..e50a4ee --- /dev/null +++ b/rootfs/etc/php83/php-fpm.d/errlog.conf @@ -0,0 +1 @@ +error_log = /dev/stderr diff --git a/rootfs/etc/php84/php-fpm.d/errlog.conf b/rootfs/etc/php84/php-fpm.d/errlog.conf new file mode 100644 index 0000000..e50a4ee --- /dev/null +++ b/rootfs/etc/php84/php-fpm.d/errlog.conf @@ -0,0 +1 @@ +error_log = /dev/stderr diff --git a/rootfs/www/index.html b/rootfs/www/index.html new file mode 100644 index 0000000..e8f5622 --- /dev/null +++ b/rootfs/www/index.html @@ -0,0 +1,23 @@ + + + +Welcome to nginx! + + + +

Welcome to nginx!

+

If you see this page, the nginx web server is successfully installed and +working. Further configuration is required.

+ +

For online documentation and support please refer to +nginx.org.
+Commercial support is available at +nginx.com.

+ +

Thank you for using nginx.

+ +