From 4b083e18ab1a0a207f0c5ebcf19106d44a290f8a Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 18 Oct 2025 11:51:48 -0300 Subject: [PATCH 1/5] drop php 7.4/8.0 --- 7.4-nginx-prod/Dockerfile | 15 ------- 7.4-nginx-prod/entrypoint | 92 --------------------------------------- 7.4-nginx/Dockerfile | 15 ------- 7.4-nginx/entrypoint | 92 --------------------------------------- 8.0-nginx-prod/Dockerfile | 15 ------- 8.0-nginx-prod/entrypoint | 92 --------------------------------------- 8.0-nginx/Dockerfile | 15 ------- 8.0-nginx/entrypoint | 92 --------------------------------------- fwd-template.json | 72 ------------------------------ 9 files changed, 500 deletions(-) delete mode 100644 7.4-nginx-prod/Dockerfile delete mode 100644 7.4-nginx-prod/entrypoint delete mode 100644 7.4-nginx/Dockerfile delete mode 100644 7.4-nginx/entrypoint delete mode 100644 8.0-nginx-prod/Dockerfile delete mode 100644 8.0-nginx-prod/entrypoint delete mode 100644 8.0-nginx/Dockerfile delete mode 100644 8.0-nginx/entrypoint diff --git a/7.4-nginx-prod/Dockerfile b/7.4-nginx-prod/Dockerfile deleted file mode 100644 index 0e56218..0000000 --- a/7.4-nginx-prod/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM wordpress:cli-php7.4 as wordpress-cli -FROM wordpress:php7.4-fpm-alpine as wordpress -FROM kooldev/php:7.4-nginx-prod - -ENV NGINX_ROOT=/app - -COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp -COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress -COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content -COPY entrypoint /kool/wordpress-entrypoint - -RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint - -ENTRYPOINT [ "/kool/wordpress-entrypoint" ] -CMD [ "supervisord", "-c", "/kool/supervisor.conf" ] diff --git a/7.4-nginx-prod/entrypoint b/7.4-nginx-prod/entrypoint deleted file mode 100644 index 845d991..0000000 --- a/7.4-nginx-prod/entrypoint +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -set -eo pipefail - -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf - -# Run as current user -CURRENT_USER=${ASUSER:-${UID:-0}} - -if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then - usermod -u $CURRENT_USER kool -fi - -# user/group for Wordpress -user=kool -group=kool -uid=$(id -u) - -if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then - # Original Wordpress Entrypoint - fresh install if none exists - if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then - # if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory) - if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then - chown "$user:$group" . - fi - - echo >&2 "WordPress not found in $PWD - copying now..." - if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then - echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" - fi - sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" - ) - targetTarArgs=( - --extract - --file - - ) - if [ "$uid" != '0' ]; then - # avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted" - targetTarArgs+=( --no-overwrite-dir ) - fi - # loop over "pluggable" content in the source, and if it already exists in the destination, skip it - # https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded) - for contentPath in \ - /kool/wordpress/.htaccess \ - /kool/wordpress/wp-content/*/*/ \ - ; do - contentPath="${contentPath%/}" - [ -e "$contentPath" ] || continue - contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc. - if [ -e "$PWD/$contentPath" ]; then - echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" - sourceTarArgs+=( --exclude "./$contentPath" ) - fi - done - tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - echo >&2 "Complete! WordPress has been successfully copied to $PWD" - fi - - wpEnvs=( "${!WORDPRESS_@}" ) - if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then - for wpConfigDocker in \ - wp-config-docker.php \ - /kool/wordpress/wp-config-docker.php \ - ; do - if [ -s "$wpConfigDocker" ]; then - echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})" - # using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables) - awk ' - /put your unique phrase here/ { - cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" - cmd | getline str - close(cmd) - gsub("put your unique phrase here", str) - } - { print } - ' "$wpConfigDocker" > wp-config.php - if [ "$uid" = '0' ]; then - # attempt to ensure that wp-config.php is owned by the run user - # could be on a filesystem that doesn't allow chown (like some NFS setups) - chown "$user:$group" wp-config.php || true - fi - break - fi - done - fi -fi - -exec /kool/entrypoint "$@" diff --git a/7.4-nginx/Dockerfile b/7.4-nginx/Dockerfile deleted file mode 100644 index 23c5f57..0000000 --- a/7.4-nginx/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM wordpress:cli-php7.4 as wordpress-cli -FROM wordpress:php7.4-fpm-alpine as wordpress -FROM kooldev/php:7.4-nginx - -ENV NGINX_ROOT=/app - -COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp -COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress -COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content -COPY entrypoint /kool/wordpress-entrypoint - -RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint - -ENTRYPOINT [ "/kool/wordpress-entrypoint" ] -CMD [ "supervisord", "-c", "/kool/supervisor.conf" ] diff --git a/7.4-nginx/entrypoint b/7.4-nginx/entrypoint deleted file mode 100644 index 845d991..0000000 --- a/7.4-nginx/entrypoint +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -set -eo pipefail - -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf - -# Run as current user -CURRENT_USER=${ASUSER:-${UID:-0}} - -if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then - usermod -u $CURRENT_USER kool -fi - -# user/group for Wordpress -user=kool -group=kool -uid=$(id -u) - -if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then - # Original Wordpress Entrypoint - fresh install if none exists - if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then - # if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory) - if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then - chown "$user:$group" . - fi - - echo >&2 "WordPress not found in $PWD - copying now..." - if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then - echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" - fi - sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" - ) - targetTarArgs=( - --extract - --file - - ) - if [ "$uid" != '0' ]; then - # avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted" - targetTarArgs+=( --no-overwrite-dir ) - fi - # loop over "pluggable" content in the source, and if it already exists in the destination, skip it - # https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded) - for contentPath in \ - /kool/wordpress/.htaccess \ - /kool/wordpress/wp-content/*/*/ \ - ; do - contentPath="${contentPath%/}" - [ -e "$contentPath" ] || continue - contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc. - if [ -e "$PWD/$contentPath" ]; then - echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" - sourceTarArgs+=( --exclude "./$contentPath" ) - fi - done - tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - echo >&2 "Complete! WordPress has been successfully copied to $PWD" - fi - - wpEnvs=( "${!WORDPRESS_@}" ) - if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then - for wpConfigDocker in \ - wp-config-docker.php \ - /kool/wordpress/wp-config-docker.php \ - ; do - if [ -s "$wpConfigDocker" ]; then - echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})" - # using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables) - awk ' - /put your unique phrase here/ { - cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" - cmd | getline str - close(cmd) - gsub("put your unique phrase here", str) - } - { print } - ' "$wpConfigDocker" > wp-config.php - if [ "$uid" = '0' ]; then - # attempt to ensure that wp-config.php is owned by the run user - # could be on a filesystem that doesn't allow chown (like some NFS setups) - chown "$user:$group" wp-config.php || true - fi - break - fi - done - fi -fi - -exec /kool/entrypoint "$@" diff --git a/8.0-nginx-prod/Dockerfile b/8.0-nginx-prod/Dockerfile deleted file mode 100644 index c5a2188..0000000 --- a/8.0-nginx-prod/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM wordpress:cli-php8.0 as wordpress-cli -FROM wordpress:php8.0-fpm-alpine as wordpress -FROM kooldev/php:8.0-nginx-prod - -ENV NGINX_ROOT=/app - -COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp -COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress -COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content -COPY entrypoint /kool/wordpress-entrypoint - -RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint - -ENTRYPOINT [ "/kool/wordpress-entrypoint" ] -CMD [ "supervisord", "-c", "/kool/supervisor.conf" ] diff --git a/8.0-nginx-prod/entrypoint b/8.0-nginx-prod/entrypoint deleted file mode 100644 index 845d991..0000000 --- a/8.0-nginx-prod/entrypoint +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -set -eo pipefail - -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf - -# Run as current user -CURRENT_USER=${ASUSER:-${UID:-0}} - -if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then - usermod -u $CURRENT_USER kool -fi - -# user/group for Wordpress -user=kool -group=kool -uid=$(id -u) - -if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then - # Original Wordpress Entrypoint - fresh install if none exists - if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then - # if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory) - if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then - chown "$user:$group" . - fi - - echo >&2 "WordPress not found in $PWD - copying now..." - if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then - echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" - fi - sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" - ) - targetTarArgs=( - --extract - --file - - ) - if [ "$uid" != '0' ]; then - # avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted" - targetTarArgs+=( --no-overwrite-dir ) - fi - # loop over "pluggable" content in the source, and if it already exists in the destination, skip it - # https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded) - for contentPath in \ - /kool/wordpress/.htaccess \ - /kool/wordpress/wp-content/*/*/ \ - ; do - contentPath="${contentPath%/}" - [ -e "$contentPath" ] || continue - contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc. - if [ -e "$PWD/$contentPath" ]; then - echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" - sourceTarArgs+=( --exclude "./$contentPath" ) - fi - done - tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - echo >&2 "Complete! WordPress has been successfully copied to $PWD" - fi - - wpEnvs=( "${!WORDPRESS_@}" ) - if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then - for wpConfigDocker in \ - wp-config-docker.php \ - /kool/wordpress/wp-config-docker.php \ - ; do - if [ -s "$wpConfigDocker" ]; then - echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})" - # using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables) - awk ' - /put your unique phrase here/ { - cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" - cmd | getline str - close(cmd) - gsub("put your unique phrase here", str) - } - { print } - ' "$wpConfigDocker" > wp-config.php - if [ "$uid" = '0' ]; then - # attempt to ensure that wp-config.php is owned by the run user - # could be on a filesystem that doesn't allow chown (like some NFS setups) - chown "$user:$group" wp-config.php || true - fi - break - fi - done - fi -fi - -exec /kool/entrypoint "$@" diff --git a/8.0-nginx/Dockerfile b/8.0-nginx/Dockerfile deleted file mode 100644 index fbb1f06..0000000 --- a/8.0-nginx/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM wordpress:cli-php8.0 as wordpress-cli -FROM wordpress:php8.0-fpm-alpine as wordpress -FROM kooldev/php:8.0-nginx - -ENV NGINX_ROOT=/app - -COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp -COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress -COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content -COPY entrypoint /kool/wordpress-entrypoint - -RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint - -ENTRYPOINT [ "/kool/wordpress-entrypoint" ] -CMD [ "supervisord", "-c", "/kool/supervisor.conf" ] diff --git a/8.0-nginx/entrypoint b/8.0-nginx/entrypoint deleted file mode 100644 index 845d991..0000000 --- a/8.0-nginx/entrypoint +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -set -eo pipefail - -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf - -# Run as current user -CURRENT_USER=${ASUSER:-${UID:-0}} - -if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then - usermod -u $CURRENT_USER kool -fi - -# user/group for Wordpress -user=kool -group=kool -uid=$(id -u) - -if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then - # Original Wordpress Entrypoint - fresh install if none exists - if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then - # if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory) - if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then - chown "$user:$group" . - fi - - echo >&2 "WordPress not found in $PWD - copying now..." - if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then - echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" - fi - sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" - ) - targetTarArgs=( - --extract - --file - - ) - if [ "$uid" != '0' ]; then - # avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted" - targetTarArgs+=( --no-overwrite-dir ) - fi - # loop over "pluggable" content in the source, and if it already exists in the destination, skip it - # https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded) - for contentPath in \ - /kool/wordpress/.htaccess \ - /kool/wordpress/wp-content/*/*/ \ - ; do - contentPath="${contentPath%/}" - [ -e "$contentPath" ] || continue - contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc. - if [ -e "$PWD/$contentPath" ]; then - echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" - sourceTarArgs+=( --exclude "./$contentPath" ) - fi - done - tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - echo >&2 "Complete! WordPress has been successfully copied to $PWD" - fi - - wpEnvs=( "${!WORDPRESS_@}" ) - if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then - for wpConfigDocker in \ - wp-config-docker.php \ - /kool/wordpress/wp-config-docker.php \ - ; do - if [ -s "$wpConfigDocker" ]; then - echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})" - # using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables) - awk ' - /put your unique phrase here/ { - cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" - cmd | getline str - close(cmd) - gsub("put your unique phrase here", str) - } - { print } - ' "$wpConfigDocker" > wp-config.php - if [ "$uid" = '0' ]; then - # attempt to ensure that wp-config.php is owned by the run user - # could be on a filesystem that doesn't allow chown (like some NFS setups) - chown "$user:$group" wp-config.php || true - fi - break - fi - done - fi -fi - -exec /kool/entrypoint "$@" diff --git a/fwd-template.json b/fwd-template.json index 4298129..5b19496 100644 --- a/fwd-template.json +++ b/fwd-template.json @@ -1,78 +1,6 @@ { "output": ".", "builds": [ - { - "name": "7.4-nginx", - "data": { - "from": "kooldev/php:7.4-nginx", - "prod": false, - "version": "7.4" - }, - "files": [ - { - "name": "Dockerfile", - "path": "template/Dockerfile" - }, - { - "name": "entrypoint", - "path": "template/entrypoint" - } - ] - }, - { - "name": "7.4-nginx-prod", - "data": { - "from": "kooldev/php:7.4-nginx-prod", - "prod": true, - "version": "7.4" - }, - "files": [ - { - "name": "Dockerfile", - "path": "template/Dockerfile" - }, - { - "name": "entrypoint", - "path": "template/entrypoint" - } - ] - }, - { - "name": "8.0-nginx", - "data": { - "from": "kooldev/php:8.0-nginx", - "prod": false, - "version": "8.0" - }, - "files": [ - { - "name": "Dockerfile", - "path": "template/Dockerfile" - }, - { - "name": "entrypoint", - "path": "template/entrypoint" - } - ] - }, - { - "name": "8.0-nginx-prod", - "data": { - "from": "kooldev/php:8.0-nginx-prod", - "prod": true, - "version": "8.0" - }, - "files": [ - { - "name": "Dockerfile", - "path": "template/Dockerfile" - }, - { - "name": "entrypoint", - "path": "template/entrypoint" - } - ] - }, { "name": "8.1-nginx", "data": { From 89c178f4c28dd2d1e2e5fb51c48134b7e5a23c24 Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 18 Oct 2025 14:32:16 -0300 Subject: [PATCH 2/5] add webp auto serving --- 8.1-nginx-prod/Dockerfile | 5 +- 8.1-nginx-prod/entrypoint | 5 +- 8.1-nginx-prod/wordpress-webp.conf | 17 +++++ 8.1-nginx/Dockerfile | 5 +- 8.1-nginx/entrypoint | 5 +- 8.1-nginx/wordpress-webp.conf | 17 +++++ 8.2-nginx-prod/Dockerfile | 5 +- 8.2-nginx-prod/entrypoint | 5 +- 8.2-nginx-prod/wordpress-webp.conf | 17 +++++ 8.2-nginx/Dockerfile | 5 +- 8.2-nginx/entrypoint | 5 +- 8.2-nginx/wordpress-webp.conf | 17 +++++ 8.3-nginx-prod/Dockerfile | 5 +- 8.3-nginx-prod/entrypoint | 5 +- 8.3-nginx-prod/wordpress-webp.conf | 17 +++++ 8.3-nginx/Dockerfile | 5 +- 8.3-nginx/entrypoint | 5 +- 8.3-nginx/wordpress-webp.conf | 17 +++++ 8.4-nginx-prod/Dockerfile | 16 +++++ 8.4-nginx-prod/entrypoint | 93 ++++++++++++++++++++++++++ 8.4-nginx-prod/wordpress-webp.conf | 17 +++++ 8.4-nginx/Dockerfile | 16 +++++ 8.4-nginx/entrypoint | 93 ++++++++++++++++++++++++++ 8.4-nginx/wordpress-webp.conf | 17 +++++ fwd-template.json | 68 +++++++++++++++++++ kool.yml | 3 + template/Dockerfile.blade.php | 5 +- template/entrypoint.blade.php | 5 +- template/wordpress-webp-conf.blade.php | 17 +++++ 29 files changed, 484 insertions(+), 28 deletions(-) create mode 100644 8.1-nginx-prod/wordpress-webp.conf create mode 100644 8.1-nginx/wordpress-webp.conf create mode 100644 8.2-nginx-prod/wordpress-webp.conf create mode 100644 8.2-nginx/wordpress-webp.conf create mode 100644 8.3-nginx-prod/wordpress-webp.conf create mode 100644 8.3-nginx/wordpress-webp.conf create mode 100644 8.4-nginx-prod/Dockerfile create mode 100644 8.4-nginx-prod/entrypoint create mode 100644 8.4-nginx-prod/wordpress-webp.conf create mode 100644 8.4-nginx/Dockerfile create mode 100644 8.4-nginx/entrypoint create mode 100644 8.4-nginx/wordpress-webp.conf create mode 100644 template/wordpress-webp-conf.blade.php diff --git a/8.1-nginx-prod/Dockerfile b/8.1-nginx-prod/Dockerfile index 29574ed..c90a195 100644 --- a/8.1-nginx-prod/Dockerfile +++ b/8.1-nginx-prod/Dockerfile @@ -1,5 +1,5 @@ -FROM wordpress:cli-php8.1 as wordpress-cli -FROM wordpress:php8.1-fpm-alpine as wordpress +FROM wordpress:cli-php8.1 AS wordpress-cli +FROM wordpress:php8.1-fpm-alpine AS wordpress FROM kooldev/php:8.1-nginx-prod ENV NGINX_ROOT=/app @@ -8,6 +8,7 @@ COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint diff --git a/8.1-nginx-prod/entrypoint b/8.1-nginx-prod/entrypoint index 845d991..e1e4b3c 100644 --- a/8.1-nginx-prod/entrypoint +++ b/8.1-nginx-prod/entrypoint @@ -1,8 +1,9 @@ #!/bin/bash set -eo pipefail -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl # Run as current user CURRENT_USER=${ASUSER:-${UID:-0}} diff --git a/8.1-nginx-prod/wordpress-webp.conf b/8.1-nginx-prod/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.1-nginx-prod/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/8.1-nginx/Dockerfile b/8.1-nginx/Dockerfile index db40abc..d4fc5ab 100644 --- a/8.1-nginx/Dockerfile +++ b/8.1-nginx/Dockerfile @@ -1,5 +1,5 @@ -FROM wordpress:cli-php8.1 as wordpress-cli -FROM wordpress:php8.1-fpm-alpine as wordpress +FROM wordpress:cli-php8.1 AS wordpress-cli +FROM wordpress:php8.1-fpm-alpine AS wordpress FROM kooldev/php:8.1-nginx ENV NGINX_ROOT=/app @@ -8,6 +8,7 @@ COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint diff --git a/8.1-nginx/entrypoint b/8.1-nginx/entrypoint index 845d991..e1e4b3c 100644 --- a/8.1-nginx/entrypoint +++ b/8.1-nginx/entrypoint @@ -1,8 +1,9 @@ #!/bin/bash set -eo pipefail -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl # Run as current user CURRENT_USER=${ASUSER:-${UID:-0}} diff --git a/8.1-nginx/wordpress-webp.conf b/8.1-nginx/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.1-nginx/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/8.2-nginx-prod/Dockerfile b/8.2-nginx-prod/Dockerfile index cdce9b2..c9991fa 100644 --- a/8.2-nginx-prod/Dockerfile +++ b/8.2-nginx-prod/Dockerfile @@ -1,5 +1,5 @@ -FROM wordpress:cli-php8.2 as wordpress-cli -FROM wordpress:php8.2-fpm-alpine as wordpress +FROM wordpress:cli-php8.2 AS wordpress-cli +FROM wordpress:php8.2-fpm-alpine AS wordpress FROM kooldev/php:8.2-nginx-prod ENV NGINX_ROOT=/app @@ -8,6 +8,7 @@ COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint diff --git a/8.2-nginx-prod/entrypoint b/8.2-nginx-prod/entrypoint index 845d991..e1e4b3c 100644 --- a/8.2-nginx-prod/entrypoint +++ b/8.2-nginx-prod/entrypoint @@ -1,8 +1,9 @@ #!/bin/bash set -eo pipefail -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl # Run as current user CURRENT_USER=${ASUSER:-${UID:-0}} diff --git a/8.2-nginx-prod/wordpress-webp.conf b/8.2-nginx-prod/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.2-nginx-prod/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/8.2-nginx/Dockerfile b/8.2-nginx/Dockerfile index f02705b..68fa8f5 100644 --- a/8.2-nginx/Dockerfile +++ b/8.2-nginx/Dockerfile @@ -1,5 +1,5 @@ -FROM wordpress:cli-php8.2 as wordpress-cli -FROM wordpress:php8.2-fpm-alpine as wordpress +FROM wordpress:cli-php8.2 AS wordpress-cli +FROM wordpress:php8.2-fpm-alpine AS wordpress FROM kooldev/php:8.2-nginx ENV NGINX_ROOT=/app @@ -8,6 +8,7 @@ COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint diff --git a/8.2-nginx/entrypoint b/8.2-nginx/entrypoint index 845d991..e1e4b3c 100644 --- a/8.2-nginx/entrypoint +++ b/8.2-nginx/entrypoint @@ -1,8 +1,9 @@ #!/bin/bash set -eo pipefail -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl # Run as current user CURRENT_USER=${ASUSER:-${UID:-0}} diff --git a/8.2-nginx/wordpress-webp.conf b/8.2-nginx/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.2-nginx/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/8.3-nginx-prod/Dockerfile b/8.3-nginx-prod/Dockerfile index 8abdb6a..f8342e3 100644 --- a/8.3-nginx-prod/Dockerfile +++ b/8.3-nginx-prod/Dockerfile @@ -1,5 +1,5 @@ -FROM wordpress:cli-php8.3 as wordpress-cli -FROM wordpress:php8.3-fpm-alpine as wordpress +FROM wordpress:cli-php8.3 AS wordpress-cli +FROM wordpress:php8.3-fpm-alpine AS wordpress FROM kooldev/php:8.3-nginx-prod ENV NGINX_ROOT=/app @@ -8,6 +8,7 @@ COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint diff --git a/8.3-nginx-prod/entrypoint b/8.3-nginx-prod/entrypoint index 845d991..e1e4b3c 100644 --- a/8.3-nginx-prod/entrypoint +++ b/8.3-nginx-prod/entrypoint @@ -1,8 +1,9 @@ #!/bin/bash set -eo pipefail -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl # Run as current user CURRENT_USER=${ASUSER:-${UID:-0}} diff --git a/8.3-nginx-prod/wordpress-webp.conf b/8.3-nginx-prod/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.3-nginx-prod/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/8.3-nginx/Dockerfile b/8.3-nginx/Dockerfile index f8e8f9b..c9a7c7b 100644 --- a/8.3-nginx/Dockerfile +++ b/8.3-nginx/Dockerfile @@ -1,5 +1,5 @@ -FROM wordpress:cli-php8.3 as wordpress-cli -FROM wordpress:php8.3-fpm-alpine as wordpress +FROM wordpress:cli-php8.3 AS wordpress-cli +FROM wordpress:php8.3-fpm-alpine AS wordpress FROM kooldev/php:8.3-nginx ENV NGINX_ROOT=/app @@ -8,6 +8,7 @@ COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint diff --git a/8.3-nginx/entrypoint b/8.3-nginx/entrypoint index 845d991..e1e4b3c 100644 --- a/8.3-nginx/entrypoint +++ b/8.3-nginx/entrypoint @@ -1,8 +1,9 @@ #!/bin/bash set -eo pipefail -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl # Run as current user CURRENT_USER=${ASUSER:-${UID:-0}} diff --git a/8.3-nginx/wordpress-webp.conf b/8.3-nginx/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.3-nginx/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/8.4-nginx-prod/Dockerfile b/8.4-nginx-prod/Dockerfile new file mode 100644 index 0000000..a984e3d --- /dev/null +++ b/8.4-nginx-prod/Dockerfile @@ -0,0 +1,16 @@ +FROM wordpress:cli-php8.4 AS wordpress-cli +FROM wordpress:php8.4-fpm-alpine AS wordpress +FROM kooldev/php:8.4-nginx-prod + +ENV NGINX_ROOT=/app + +COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp +COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress +COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content +COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf + +RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint + +ENTRYPOINT [ "/kool/wordpress-entrypoint" ] +CMD [ "supervisord", "-c", "/kool/supervisor.conf" ] diff --git a/8.4-nginx-prod/entrypoint b/8.4-nginx-prod/entrypoint new file mode 100644 index 0000000..e1e4b3c --- /dev/null +++ b/8.4-nginx-prod/entrypoint @@ -0,0 +1,93 @@ +#!/bin/bash +set -eo pipefail + +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl + +# Run as current user +CURRENT_USER=${ASUSER:-${UID:-0}} + +if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then + usermod -u $CURRENT_USER kool +fi + +# user/group for Wordpress +user=kool +group=kool +uid=$(id -u) + +if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then + # Original Wordpress Entrypoint - fresh install if none exists + if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then + # if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory) + if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then + chown "$user:$group" . + fi + + echo >&2 "WordPress not found in $PWD - copying now..." + if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" + fi + sourceTarArgs=( + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" + ) + targetTarArgs=( + --extract + --file - + ) + if [ "$uid" != '0' ]; then + # avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted" + targetTarArgs+=( --no-overwrite-dir ) + fi + # loop over "pluggable" content in the source, and if it already exists in the destination, skip it + # https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded) + for contentPath in \ + /kool/wordpress/.htaccess \ + /kool/wordpress/wp-content/*/*/ \ + ; do + contentPath="${contentPath%/}" + [ -e "$contentPath" ] || continue + contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc. + if [ -e "$PWD/$contentPath" ]; then + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) + fi + done + tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" + echo >&2 "Complete! WordPress has been successfully copied to $PWD" + fi + + wpEnvs=( "${!WORDPRESS_@}" ) + if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then + for wpConfigDocker in \ + wp-config-docker.php \ + /kool/wordpress/wp-config-docker.php \ + ; do + if [ -s "$wpConfigDocker" ]; then + echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})" + # using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables) + awk ' + /put your unique phrase here/ { + cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" + cmd | getline str + close(cmd) + gsub("put your unique phrase here", str) + } + { print } + ' "$wpConfigDocker" > wp-config.php + if [ "$uid" = '0' ]; then + # attempt to ensure that wp-config.php is owned by the run user + # could be on a filesystem that doesn't allow chown (like some NFS setups) + chown "$user:$group" wp-config.php || true + fi + break + fi + done + fi +fi + +exec /kool/entrypoint "$@" diff --git a/8.4-nginx-prod/wordpress-webp.conf b/8.4-nginx-prod/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.4-nginx-prod/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/8.4-nginx/Dockerfile b/8.4-nginx/Dockerfile new file mode 100644 index 0000000..57b3732 --- /dev/null +++ b/8.4-nginx/Dockerfile @@ -0,0 +1,16 @@ +FROM wordpress:cli-php8.4 AS wordpress-cli +FROM wordpress:php8.4-fpm-alpine AS wordpress +FROM kooldev/php:8.4-nginx + +ENV NGINX_ROOT=/app + +COPY --from=wordpress-cli /usr/local/bin/wp /usr/local/bin/wp +COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress +COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content +COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf + +RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint + +ENTRYPOINT [ "/kool/wordpress-entrypoint" ] +CMD [ "supervisord", "-c", "/kool/supervisor.conf" ] diff --git a/8.4-nginx/entrypoint b/8.4-nginx/entrypoint new file mode 100644 index 0000000..e1e4b3c --- /dev/null +++ b/8.4-nginx/entrypoint @@ -0,0 +1,93 @@ +#!/bin/bash +set -eo pipefail + +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl + +# Run as current user +CURRENT_USER=${ASUSER:-${UID:-0}} + +if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then + usermod -u $CURRENT_USER kool +fi + +# user/group for Wordpress +user=kool +group=kool +uid=$(id -u) + +if [ "$1" = 'php-fpm' ] || [ "$1" = 'supervisord' ]; then + # Original Wordpress Entrypoint - fresh install if none exists + if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then + # if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory) + if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then + chown "$user:$group" . + fi + + echo >&2 "WordPress not found in $PWD - copying now..." + if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" + fi + sourceTarArgs=( + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" + ) + targetTarArgs=( + --extract + --file - + ) + if [ "$uid" != '0' ]; then + # avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted" + targetTarArgs+=( --no-overwrite-dir ) + fi + # loop over "pluggable" content in the source, and if it already exists in the destination, skip it + # https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded) + for contentPath in \ + /kool/wordpress/.htaccess \ + /kool/wordpress/wp-content/*/*/ \ + ; do + contentPath="${contentPath%/}" + [ -e "$contentPath" ] || continue + contentPath="${contentPath#/kool/wordpress/}" # "wp-content/plugins/akismet", etc. + if [ -e "$PWD/$contentPath" ]; then + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) + fi + done + tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" + echo >&2 "Complete! WordPress has been successfully copied to $PWD" + fi + + wpEnvs=( "${!WORDPRESS_@}" ) + if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then + for wpConfigDocker in \ + wp-config-docker.php \ + /kool/wordpress/wp-config-docker.php \ + ; do + if [ -s "$wpConfigDocker" ]; then + echo >&2 "No 'wp-config.php' found in $PWD, but 'WORDPRESS_...' variables supplied; copying '$wpConfigDocker' (${wpEnvs[*]})" + # using "awk" to replace all instances of "put your unique phrase here" with a properly unique string (for AUTH_KEY and friends to have safe defaults if they aren't specified with environment variables) + awk ' + /put your unique phrase here/ { + cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" + cmd | getline str + close(cmd) + gsub("put your unique phrase here", str) + } + { print } + ' "$wpConfigDocker" > wp-config.php + if [ "$uid" = '0' ]; then + # attempt to ensure that wp-config.php is owned by the run user + # could be on a filesystem that doesn't allow chown (like some NFS setups) + chown "$user:$group" wp-config.php || true + fi + break + fi + done + fi +fi + +exec /kool/entrypoint "$@" diff --git a/8.4-nginx/wordpress-webp.conf b/8.4-nginx/wordpress-webp.conf new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/8.4-nginx/wordpress-webp.conf @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file diff --git a/fwd-template.json b/fwd-template.json index 5b19496..7807a10 100644 --- a/fwd-template.json +++ b/fwd-template.json @@ -16,6 +16,10 @@ { "name": "entrypoint", "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" } ] }, @@ -34,6 +38,10 @@ { "name": "entrypoint", "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" } ] }, @@ -52,6 +60,10 @@ { "name": "entrypoint", "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" } ] }, @@ -70,6 +82,10 @@ { "name": "entrypoint", "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" } ] }, @@ -88,6 +104,10 @@ { "name": "entrypoint", "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" } ] }, @@ -106,6 +126,54 @@ { "name": "entrypoint", "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" + } + ] + }, + { + "name": "8.4-nginx", + "data": { + "from": "kooldev/php:8.4-nginx", + "prod": false, + "version": "8.4" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile" + }, + { + "name": "entrypoint", + "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" + } + ] + }, + { + "name": "8.4-nginx-prod", + "data": { + "from": "kooldev/php:8.4-nginx-prod", + "prod": true, + "version": "8.4" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile" + }, + { + "name": "entrypoint", + "path": "template/entrypoint" + }, + { + "name": "wordpress-webp.conf", + "path": "template/wordpress-webp-conf" } ] } diff --git a/kool.yml b/kool.yml index 2167f61..7ea94f2 100644 --- a/kool.yml +++ b/kool.yml @@ -18,3 +18,6 @@ scripts: # PHP 8.3 - docker build -t kooldev/wordpress:8.3-nginx 8.3-nginx - docker build -t kooldev/wordpress:8.3-nginx-prod 8.3-nginx-prod + # PHP 8.4 + - docker build -t kooldev/wordpress:8.4-nginx 8.4-nginx + - docker build -t kooldev/wordpress:8.4-nginx-prod 8.4-nginx-prod diff --git a/template/Dockerfile.blade.php b/template/Dockerfile.blade.php index 9dea081..5b1d375 100644 --- a/template/Dockerfile.blade.php +++ b/template/Dockerfile.blade.php @@ -1,5 +1,5 @@ -FROM wordpress:cli-php{{ $version }} as wordpress-cli -FROM wordpress:php{{ $version }}-fpm-alpine as wordpress +FROM wordpress:cli-php{{ $version }} AS wordpress-cli +FROM wordpress:php{{ $version }}-fpm-alpine AS wordpress FROM {{ $from }} ENV NGINX_ROOT=/app @@ -8,6 +8,7 @@ COPY --from=wordpress --chown=kool:kool /usr/src/wordpress /kool/wordpress COPY --from=wordpress --chown=kool:kool /var/www/html/wp-content /app/wp-content COPY entrypoint /kool/wordpress-entrypoint +COPY wordpress-webp.conf /etc/nginx/wordpress-webp.conf RUN chmod -R 777 wp-content && chmod +x /kool/wordpress-entrypoint diff --git a/template/entrypoint.blade.php b/template/entrypoint.blade.php index 845d991..e1e4b3c 100644 --- a/template/entrypoint.blade.php +++ b/template/entrypoint.blade.php @@ -1,8 +1,9 @@ #!/bin/bash set -eo pipefail -# Nginx server config -dockerize -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf +# Add WebP support for WordPress by injecting include directive +# Insert the include directive before the location / block +sed -i 's/\( location \/ {\)/ # Include WordPress WebP support\n include \/etc\/nginx\/wordpress-webp.conf;\n\n\1/' /kool/default.tmpl # Run as current user CURRENT_USER=${ASUSER:-${UID:-0}} diff --git a/template/wordpress-webp-conf.blade.php b/template/wordpress-webp-conf.blade.php new file mode 100644 index 0000000..f1d94fe --- /dev/null +++ b/template/wordpress-webp-conf.blade.php @@ -0,0 +1,17 @@ +# WordPress WebP support: automatically serve WebP images when available and supported +location ~* ^(.+)\.(jpe?g|png)$ { + set $webp_suffix ""; + + # Check if WebP is supported by the client + if ($http_accept ~* "image/webp") { + set $webp_suffix ".webp"; + } + + # Try to serve the WebP version first, then fallback to original + try_files $uri$webp_suffix $uri /index.php?$query_string; + + # Set appropriate cache headers for images + expires 30d; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept"; +} \ No newline at end of file From 837354948c906b6f53db8b3da6cf31443815309d Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 18 Oct 2025 15:13:46 -0300 Subject: [PATCH 3/5] test nginx --- .github/workflows/ci-cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index ab10870..40e1513 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -37,6 +37,7 @@ jobs: docker run kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} php -v docker run kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} wp --allow-root --version docker run kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} nginx -v + docker run kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} nginx -t docker run kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} supervisord version - name: Test docker images wordpress code From 4d3f310118c32bb204057f2d905421de14714aa9 Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 18 Oct 2025 15:14:12 -0300 Subject: [PATCH 4/5] fix ci matrix config --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 40e1513..7414710 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - version: [ '8.0', '8.1', '8.2', '8.3' ] + version: [ '8.1', '8.2', '8.3', '8.4' ] type: [ '', '-prod' ] steps: From 9ba25677afa41852e20e69d40ac0b0f85e9e38a3 Mon Sep 17 00:00:00 2001 From: fabriciojs Date: Sat, 18 Oct 2025 15:31:19 -0300 Subject: [PATCH 5/5] update readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 35268d8..325deb2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,11 @@ Minimal PHP Docker image for wordpress based on [kooldev/php](https://github.com ## Available Tags +### 8.4 + +- [8.4-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/8.4-nginx/Dockerfile) +- [8.4-nginx-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.4-nginx-prod/Dockerfile) + ### 8.3 - [8.3-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/8.3-nginx/Dockerfile) @@ -21,14 +26,9 @@ Minimal PHP Docker image for wordpress based on [kooldev/php](https://github.com - [8.1-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/8.1-nginx/Dockerfile) - [8.1-nginx-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.1-nginx-prod/Dockerfile) -### 8.0 - -- [8.0-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/8.0-nginx/Dockerfile) -- [8.0-nginx-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.0-nginx-prod/Dockerfile) - ### Legacy Images -Previously supported but now deprecated tags: [8.3](https://github.com/kool-dev/docker-wordpress/blob/master/8.3/Dockerfile), [8.3-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.3-prod/Dockerfile), [8.2](https://github.com/kool-dev/docker-wordpress/blob/master/8.2/Dockerfile), [8.2-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.2-prod/Dockerfile), [8.1](https://github.com/kool-dev/docker-wordpress/blob/master/8.1/Dockerfile), [8.1-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.1-prod/Dockerfile), [8.0](https://github.com/kool-dev/docker-wordpress/blob/master/8.0/Dockerfile), [8.0-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.0-prod/Dockerfile), [7.4](https://github.com/kool-dev/docker-wordpress/blob/master/7.4/Dockerfile), [7.4-prod](https://github.com/kool-dev/docker-wordpress/blob/master/7.4-prod/Dockerfile), [7.4-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/7.4-nginx/Dockerfile), [7.4-nginx-prod](https://github.com/kool-dev/docker-wordpress/blob/master/7.4-nginx-prod/Dockerfile). +Previously supported but now deprecated tags: [8.3](https://github.com/kool-dev/docker-wordpress/blob/master/8.3/Dockerfile), [8.3-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.3-prod/Dockerfile), [8.2](https://github.com/kool-dev/docker-wordpress/blob/master/8.2/Dockerfile), [8.2-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.2-prod/Dockerfile), [8.1](https://github.com/kool-dev/docker-wordpress/blob/master/8.1/Dockerfile), [8.1-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.1-prod/Dockerfile), [8.0](https://github.com/kool-dev/docker-wordpress/blob/master/8.0/Dockerfile), [8.0-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.0-prod/Dockerfile), [7.4](https://github.com/kool-dev/docker-wordpress/blob/master/7.4/Dockerfile), [7.4-prod](https://github.com/kool-dev/docker-wordpress/blob/master/7.4-prod/Dockerfile), [7.4-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/7.4-nginx/Dockerfile), [7.4-nginx-prod](https://github.com/kool-dev/docker-wordpress/blob/master/7.4-nginx-prod/Dockerfile), [8.0-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/8.0-nginx/Dockerfile), [8.0-nginx-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.0-nginx-prod/Dockerfile). ## How to