From 600bced93fb8515b4ca97ac641a227f0753f8458 Mon Sep 17 00:00:00 2001 From: thespad Date: Mon, 16 Jun 2025 18:28:00 +0100 Subject: [PATCH] Rebase to 3.22 & PHP 8.4. Add autoreload functionality --- .editorconfig | 0 .github/CONTRIBUTING.md | 0 .github/FUNDING.yml | 0 .github/ISSUE_TEMPLATE/config.yml | 0 .github/ISSUE_TEMPLATE/issue.bug.yml | 0 .github/ISSUE_TEMPLATE/issue.feature.yml | 0 .github/workflows/call_issue_pr_tracker.yml | 0 .github/workflows/call_issues_cron.yml | 0 .github/workflows/external_trigger.yml | 4 +- .../workflows/external_trigger_scheduler.yml | 0 .github/workflows/greetings.yml | 0 .../workflows/package_trigger_scheduler.yml | 0 .github/workflows/permissions.yml | 0 Dockerfile | 65 +++++++++---------- Dockerfile.aarch64 | 65 +++++++++---------- Jenkinsfile | 2 +- LICENSE | 0 README.md | 7 ++ jenkins-vars.yml | 2 +- readme-vars.yml | 5 ++ .../dependencies.d/init-services | 0 .../s6-rc.d/svc-nginx-auto-reload/run | 42 ++++++++++++ .../s6-rc.d/svc-nginx-auto-reload/type | 1 + 23 files changed, 123 insertions(+), 70 deletions(-) mode change 100755 => 100644 .editorconfig mode change 100755 => 100644 .github/CONTRIBUTING.md mode change 100755 => 100644 .github/FUNDING.yml mode change 100755 => 100644 .github/ISSUE_TEMPLATE/config.yml mode change 100755 => 100644 .github/ISSUE_TEMPLATE/issue.bug.yml mode change 100755 => 100644 .github/ISSUE_TEMPLATE/issue.feature.yml mode change 100755 => 100644 .github/workflows/call_issue_pr_tracker.yml mode change 100755 => 100644 .github/workflows/call_issues_cron.yml mode change 100755 => 100644 .github/workflows/external_trigger.yml mode change 100755 => 100644 .github/workflows/external_trigger_scheduler.yml mode change 100755 => 100644 .github/workflows/greetings.yml mode change 100755 => 100644 .github/workflows/package_trigger_scheduler.yml mode change 100755 => 100644 .github/workflows/permissions.yml mode change 100755 => 100644 LICENSE create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/dependencies.d/init-services create mode 100755 root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/run create mode 100644 root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/type diff --git a/.editorconfig b/.editorconfig old mode 100755 new mode 100644 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md old mode 100755 new mode 100644 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml old mode 100755 new mode 100644 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml old mode 100755 new mode 100644 diff --git a/.github/ISSUE_TEMPLATE/issue.bug.yml b/.github/ISSUE_TEMPLATE/issue.bug.yml old mode 100755 new mode 100644 diff --git a/.github/ISSUE_TEMPLATE/issue.feature.yml b/.github/ISSUE_TEMPLATE/issue.feature.yml old mode 100755 new mode 100644 diff --git a/.github/workflows/call_issue_pr_tracker.yml b/.github/workflows/call_issue_pr_tracker.yml old mode 100755 new mode 100644 diff --git a/.github/workflows/call_issues_cron.yml b/.github/workflows/call_issues_cron.yml old mode 100755 new mode 100644 diff --git a/.github/workflows/external_trigger.yml b/.github/workflows/external_trigger.yml old mode 100755 new mode 100644 index d2b3d51..0483edb --- a/.github/workflows/external_trigger.yml +++ b/.github/workflows/external_trigger.yml @@ -26,7 +26,7 @@ jobs: echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY echo "> External trigger running off of master branch. To disable this trigger, add \`nginx_master\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`." >> $GITHUB_STEP_SUMMARY printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY - EXT_RELEASE=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ + EXT_RELEASE=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.22/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ && awk '/^P:'"nginx"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://') echo "Type is \`alpine_repo\`" >> $GITHUB_STEP_SUMMARY if grep -q "^nginx_master_${EXT_RELEASE}" <<< "${SKIP_EXTERNAL_TRIGGER}"; then @@ -104,7 +104,7 @@ jobs: if [ "${EXT_RELEASE}" == "${IMAGE_VERSION}" ]; then echo "Version \`${EXT_RELEASE}\` already pushed, exiting" >> $GITHUB_STEP_SUMMARY exit 0 - elif [[ $(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/aarch64/APKINDEX.tar.gz" | tar -xz -C /tmp && awk '/^P:'"nginx"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://') != "${EXT_RELEASE}" ]]; then + elif [[ $(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.22/main/aarch64/APKINDEX.tar.gz" | tar -xz -C /tmp && awk '/^P:'"nginx"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://') != "${EXT_RELEASE}" ]]; then echo "New version \`${EXT_RELEASE}\` found; but not all arch repos updated yet; exiting" >> $GITHUB_STEP_SUMMARY FAILURE_REASON="New version ${EXT_RELEASE} for nginx tag latest is detected, however not all arch repos are updated yet. Will try again later." curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903, diff --git a/.github/workflows/external_trigger_scheduler.yml b/.github/workflows/external_trigger_scheduler.yml old mode 100755 new mode 100644 diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml old mode 100755 new mode 100644 diff --git a/.github/workflows/package_trigger_scheduler.yml b/.github/workflows/package_trigger_scheduler.yml old mode 100755 new mode 100644 diff --git a/.github/workflows/permissions.yml b/.github/workflows/permissions.yml old mode 100755 new mode 100644 diff --git a/Dockerfile b/Dockerfile index bdc9472..c201e70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.21 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.22 # set version label ARG BUILD_DATE @@ -13,7 +13,7 @@ LABEL maintainer="nemchik" # install packages RUN \ if [ -z ${NGINX_VERSION+x} ]; then \ - NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ + NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.22/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ && awk '/^P:nginx$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \ fi && \ apk add --no-cache \ @@ -38,37 +38,36 @@ RUN \ nginx-mod-stream-geoip==${NGINX_VERSION} \ nginx-mod-stream-geoip2==${NGINX_VERSION} \ nginx-vim==${NGINX_VERSION} \ - php83-bcmath \ - php83-bz2 \ - php83-dom \ - php83-exif \ - php83-ftp \ - php83-gd \ - php83-gmp \ - php83-imap \ - php83-intl \ - php83-ldap \ - php83-mysqli \ - php83-mysqlnd \ - php83-opcache \ - php83-pdo_mysql \ - php83-pdo_odbc \ - php83-pdo_pgsql \ - php83-pdo_sqlite \ - php83-pear \ - php83-pecl-apcu \ - php83-pecl-mcrypt \ - php83-pecl-memcached \ - php83-pecl-redis \ - php83-pgsql \ - php83-posix \ - php83-soap \ - php83-sockets \ - php83-sodium \ - php83-sqlite3 \ - php83-tokenizer \ - php83-xmlreader \ - php83-xsl && \ + php84-bcmath \ + php84-bz2 \ + php84-dom \ + php84-exif \ + php84-ftp \ + php84-gd \ + php84-gmp \ + php84-imap \ + php84-intl \ + php84-ldap \ + php84-mysqli \ + php84-mysqlnd \ + php84-opcache \ + php84-pdo_mysql \ + php84-pdo_odbc \ + php84-pdo_pgsql \ + php84-pdo_sqlite \ + php84-pear \ + php84-pecl-apcu \ + php84-pecl-memcached \ + php84-pecl-redis \ + php84-pgsql \ + php84-posix \ + php84-soap \ + php84-sockets \ + php84-sodium \ + php84-sqlite3 \ + php84-tokenizer \ + php84-xmlreader \ + php84-xsl && \ printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \ rm -f /etc/nginx/conf.d/stream.conf diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 0ac9dc8..7f8855b 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.21 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.22 # set version label ARG BUILD_DATE @@ -13,7 +13,7 @@ LABEL maintainer="nemchik" # install packages RUN \ if [ -z ${NGINX_VERSION+x} ]; then \ - NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ + NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.22/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ && awk '/^P:nginx$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \ fi && \ apk add --no-cache \ @@ -38,37 +38,36 @@ RUN \ nginx-mod-stream-geoip==${NGINX_VERSION} \ nginx-mod-stream-geoip2==${NGINX_VERSION} \ nginx-vim==${NGINX_VERSION} \ - php83-bcmath \ - php83-bz2 \ - php83-dom \ - php83-exif \ - php83-ftp \ - php83-gd \ - php83-gmp \ - php83-imap \ - php83-intl \ - php83-ldap \ - php83-mysqli \ - php83-mysqlnd \ - php83-opcache \ - php83-pdo_mysql \ - php83-pdo_odbc \ - php83-pdo_pgsql \ - php83-pdo_sqlite \ - php83-pear \ - php83-pecl-apcu \ - php83-pecl-mcrypt \ - php83-pecl-memcached \ - php83-pecl-redis \ - php83-pgsql \ - php83-posix \ - php83-soap \ - php83-sockets \ - php83-sodium \ - php83-sqlite3 \ - php83-tokenizer \ - php83-xmlreader \ - php83-xsl && \ + php84-bcmath \ + php84-bz2 \ + php84-dom \ + php84-exif \ + php84-ftp \ + php84-gd \ + php84-gmp \ + php84-imap \ + php84-intl \ + php84-ldap \ + php84-mysqli \ + php84-mysqlnd \ + php84-opcache \ + php84-pdo_mysql \ + php84-pdo_odbc \ + php84-pdo_pgsql \ + php84-pdo_sqlite \ + php84-pear \ + php84-pecl-apcu \ + php84-pecl-memcached \ + php84-pecl-redis \ + php84-pgsql \ + php84-posix \ + php84-soap \ + php84-sockets \ + php84-sodium \ + php84-sqlite3 \ + php84-tokenizer \ + php84-xmlreader \ + php84-xsl && \ printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \ rm -f /etc/nginx/conf.d/stream.conf diff --git a/Jenkinsfile b/Jenkinsfile index 3c61290..b228431 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,7 +27,7 @@ pipeline { DEV_DOCKERHUB_IMAGE = 'lsiodev/nginx' PR_DOCKERHUB_IMAGE = 'lspipepr/nginx' DIST_IMAGE = 'alpine' - DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.21/main/' + DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.22/main/' DIST_REPO_PACKAGES = 'nginx' MULTIARCH='true' CI='true' diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md index 8ef1f8c..77de44e 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ services: - PUID=1000 - PGID=1000 - TZ=Etc/UTC + - NGINX_AUTORELOAD= #optional + - NGINX_AUTORELOAD_WATCHLIST= #optional volumes: - /path/to/nginx/config:/config ports: @@ -105,6 +107,8 @@ docker run -d \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=Etc/UTC \ + -e NGINX_AUTORELOAD= `#optional` \ + -e NGINX_AUTORELOAD_WATCHLIST= `#optional` \ -p 80:80 \ -p 443:443 \ -v /path/to/nginx/config:/config \ @@ -123,6 +127,8 @@ Containers are configured using parameters passed at runtime (such as those abov | `-e PUID=1000` | for UserID - see below for explanation | | `-e PGID=1000` | for GroupID - see below for explanation | | `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | +| `-e NGINX_AUTORELOAD=` | Set to `true` to enable automatic reloading of confs on change without stopping/restarting nginx. Your filesystem must support inotify. This functionality was previously offered [via mod](https://github.com/linuxserver/docker-mods/tree/swag-auto-reload). | +| `-e NGINX_AUTORELOAD_WATCHLIST=` | A [pipe](https://en.wikipedia.org/wiki/Vertical_bar)-separated list of additional folders for auto reload to watch in addition to `/config/nginx` | | `-v /config` | Persistent config files | | `--read-only=true` | Run container with a read-only filesystem. Please [read the docs](https://docs.linuxserver.io/misc/read-only/). | @@ -288,6 +294,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **16.06.25:** - Rebase to Alpine 3.22 with PHP 8.4. Add [Auto Reload](https://github.com/linuxserver/docker-mods/tree/swag-auto-reload) functionality. Drop PHP bindings for mcrypt as it is no longer maintained. * **17.12.24:** - Rebase to Alpine 3.21. * **31.05.24:** - Rebase to Alpine 3.20. Existing users should update their nginx confs to avoid http2 deprecation warnings. * **05.03.24:** - Rebase to Alpine 3.19 with php 8.3. diff --git a/jenkins-vars.yml b/jenkins-vars.yml index e982b99..e03bfe9 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -15,7 +15,7 @@ repo_vars: - DEV_DOCKERHUB_IMAGE = 'lsiodev/nginx' - PR_DOCKERHUB_IMAGE = 'lspipepr/nginx' - DIST_IMAGE = 'alpine' - - DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.21/main/' + - DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.22/main/' - DIST_REPO_PACKAGES = 'nginx' - MULTIARCH='true' - CI='true' diff --git a/readme-vars.yml b/readme-vars.yml index c1c8ebd..a15b5d4 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -21,6 +21,10 @@ param_usage_include_ports: true param_ports: - {external_port: "80", internal_port: "80", port_desc: "http"} - {external_port: "443", internal_port: "443", port_desc: "https"} +opt_param_usage_include_env: true +opt_param_env_vars: + - {env_var: "NGINX_AUTORELOAD", env_value: "", desc: "Set to `true` to enable automatic reloading of confs on change without stopping/restarting nginx. Your filesystem must support inotify. This functionality was previously offered [via mod](https://github.com/linuxserver/docker-mods/tree/swag-auto-reload)."} + - {env_var: "NGINX_AUTORELOAD_WATCHLIST", env_value: "", desc: "A [pipe](https://en.wikipedia.org/wiki/Vertical_bar)-separated list of additional folders for auto reload to watch in addition to `/config/nginx`"} readonly_supported: true readonly_message: | * `/tmp` must be mounted to tmpfs @@ -81,6 +85,7 @@ init_diagram: | "nginx:latest" <- Base Images # changelog changelogs: + - {date: "16.06.25:", desc: "Rebase to Alpine 3.22 with PHP 8.4. Add [Auto Reload](https://github.com/linuxserver/docker-mods/tree/swag-auto-reload) functionality. Drop PHP bindings for mcrypt as it is no longer maintained."} - {date: "17.12.24:", desc: "Rebase to Alpine 3.21."} - {date: "31.05.24:", desc: "Rebase to Alpine 3.20. Existing users should update their nginx confs to avoid http2 deprecation warnings."} - {date: "05.03.24:", desc: "Rebase to Alpine 3.19 with php 8.3."} diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/dependencies.d/init-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/run b/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/run new file mode 100755 index 0000000..97a3261 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/run @@ -0,0 +1,42 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +if [[ ${NGINX_AUTORELOAD,,} == "true" ]]; then + if [[ -f "/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run" ]]; then + echo "ERROR: Legacy SWAG Auto Reload Mod detected, to use the built-in Auto Reload functionality please remove it from your container config" + echo " and update your environment variables as per the image documentation." + sleep infinity + else + echo "Auto-reload: Watching the following folders for changes to .conf files:" + echo "/config/nginx" + ACTIVE_WATCH=("/config/nginx") + for i in $(echo "${NGINX_AUTORELOAD_WATCHLIST}" | tr "|" " "); do + if [ -f "${i}" ] || [ -d "${i}" ]; then + echo "${i}" + ACTIVE_WATCH+=("${i}") + fi + done + + function wait_for_changes { + inotifywait -rq \ + --event modify,move,create,delete \ + --includei '\.conf$' \ + "${ACTIVE_WATCH[@]}" + } + + while wait_for_changes; do + NGINX_CONF=() + if ! grep -q "/config/nginx/nginx.conf" /etc/nginx/nginx.conf; then + NGINX_CONF=("-c" "/config/nginx/nginx.conf") + fi + if /usr/sbin/nginx "${NGINX_CONF[@]}" -t; then + echo "Changes to nginx config detected and the changes are valid, reloading nginx" + /usr/sbin/nginx "${NGINX_CONF[@]}" -s reload + else + echo "Changes to nginx config detected but the changes are not valid, skipping nginx reload. Please fix your config." + fi + done + fi +else + sleep infinity +fi diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/type b/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-nginx-auto-reload/type @@ -0,0 +1 @@ +longrun