From 647c82b322ddb798f12b8b37174ce15f9696d213 Mon Sep 17 00:00:00 2001 From: Daniel Polito Date: Tue, 12 Sep 2023 18:56:43 -0300 Subject: [PATCH 1/2] Add 8.2 --- .github/workflows/ci-cd.yml | 8 ++- 7.4-nginx-prod/entrypoint | 79 +++++++++++++++--------------- 7.4-nginx/entrypoint | 79 +++++++++++++++--------------- 7.4-prod/entrypoint | 79 +++++++++++++++--------------- 7.4/entrypoint | 79 +++++++++++++++--------------- 8.0-nginx-prod/entrypoint | 79 +++++++++++++++--------------- 8.0-nginx/entrypoint | 79 +++++++++++++++--------------- 8.0-prod/entrypoint | 79 +++++++++++++++--------------- 8.0/entrypoint | 79 +++++++++++++++--------------- 8.1-nginx-prod/entrypoint | 79 +++++++++++++++--------------- 8.1-nginx/entrypoint | 79 +++++++++++++++--------------- 8.1-prod/entrypoint | 79 +++++++++++++++--------------- 8.1/entrypoint | 79 +++++++++++++++--------------- 8.2-nginx-prod/Dockerfile | 15 ++++++ 8.2-nginx-prod/entrypoint | 92 +++++++++++++++++++++++++++++++++++ 8.2-nginx/Dockerfile | 15 ++++++ 8.2-nginx/entrypoint | 92 +++++++++++++++++++++++++++++++++++ 8.2-prod/Dockerfile | 14 ++++++ 8.2-prod/entrypoint | 90 ++++++++++++++++++++++++++++++++++ 8.2/Dockerfile | 14 ++++++ 8.2/entrypoint | 90 ++++++++++++++++++++++++++++++++++ README.md | 7 +++ fwd-template.json | 76 +++++++++++++++++++++++++++++ template/entrypoint.blade.php | 79 +++++++++++++++--------------- 24 files changed, 1018 insertions(+), 522 deletions(-) create mode 100644 8.2-nginx-prod/Dockerfile create mode 100644 8.2-nginx-prod/entrypoint create mode 100644 8.2-nginx/Dockerfile create mode 100644 8.2-nginx/entrypoint create mode 100644 8.2-prod/Dockerfile create mode 100644 8.2-prod/entrypoint create mode 100644 8.2/Dockerfile create mode 100644 8.2/entrypoint diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 636bb15..8cecad7 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,6 +1,10 @@ name: CI/CD -on: [push, workflow_dispatch] +on: + push: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' env: DOCKER_BUILDKIT: 1 @@ -10,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - version: [ '7.4', '8.0', '8.1' ] + version: [ '7.4', '8.0', '8.1', '8.2' ] type: [ '', '-prod' ] steps: diff --git a/7.4-nginx-prod/entrypoint b/7.4-nginx-prod/entrypoint index 045561d..845d991 100644 --- a/7.4-nginx-prod/entrypoint +++ b/7.4-nginx-prod/entrypoint @@ -16,77 +16,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/7.4-nginx/entrypoint b/7.4-nginx/entrypoint index 045561d..845d991 100644 --- a/7.4-nginx/entrypoint +++ b/7.4-nginx/entrypoint @@ -16,77 +16,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/7.4-prod/entrypoint b/7.4-prod/entrypoint index 0b4e078..553e1a2 100644 --- a/7.4-prod/entrypoint +++ b/7.4-prod/entrypoint @@ -14,77 +14,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/7.4/entrypoint b/7.4/entrypoint index 0b4e078..553e1a2 100644 --- a/7.4/entrypoint +++ b/7.4/entrypoint @@ -14,77 +14,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.0-nginx-prod/entrypoint b/8.0-nginx-prod/entrypoint index 045561d..845d991 100644 --- a/8.0-nginx-prod/entrypoint +++ b/8.0-nginx-prod/entrypoint @@ -16,77 +16,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.0-nginx/entrypoint b/8.0-nginx/entrypoint index 045561d..845d991 100644 --- a/8.0-nginx/entrypoint +++ b/8.0-nginx/entrypoint @@ -16,77 +16,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.0-prod/entrypoint b/8.0-prod/entrypoint index 0b4e078..553e1a2 100644 --- a/8.0-prod/entrypoint +++ b/8.0-prod/entrypoint @@ -14,77 +14,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.0/entrypoint b/8.0/entrypoint index 0b4e078..553e1a2 100644 --- a/8.0/entrypoint +++ b/8.0/entrypoint @@ -14,77 +14,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.1-nginx-prod/entrypoint b/8.1-nginx-prod/entrypoint index 045561d..845d991 100644 --- a/8.1-nginx-prod/entrypoint +++ b/8.1-nginx-prod/entrypoint @@ -16,77 +16,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.1-nginx/entrypoint b/8.1-nginx/entrypoint index 045561d..845d991 100644 --- a/8.1-nginx/entrypoint +++ b/8.1-nginx/entrypoint @@ -16,77 +16,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.1-prod/entrypoint b/8.1-prod/entrypoint index 0b4e078..553e1a2 100644 --- a/8.1-prod/entrypoint +++ b/8.1-prod/entrypoint @@ -14,77 +14,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.1/entrypoint b/8.1/entrypoint index 0b4e078..553e1a2 100644 --- a/8.1/entrypoint +++ b/8.1/entrypoint @@ -14,77 +14,76 @@ user=kool group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 diff --git a/8.2-nginx-prod/Dockerfile b/8.2-nginx-prod/Dockerfile new file mode 100644 index 0000000..cdce9b2 --- /dev/null +++ b/8.2-nginx-prod/Dockerfile @@ -0,0 +1,15 @@ +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 + +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.2-nginx-prod/entrypoint b/8.2-nginx-prod/entrypoint new file mode 100644 index 0000000..845d991 --- /dev/null +++ b/8.2-nginx-prod/entrypoint @@ -0,0 +1,92 @@ +#!/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.2-nginx/Dockerfile b/8.2-nginx/Dockerfile new file mode 100644 index 0000000..f02705b --- /dev/null +++ b/8.2-nginx/Dockerfile @@ -0,0 +1,15 @@ +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 + +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.2-nginx/entrypoint b/8.2-nginx/entrypoint new file mode 100644 index 0000000..845d991 --- /dev/null +++ b/8.2-nginx/entrypoint @@ -0,0 +1,92 @@ +#!/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.2-prod/Dockerfile b/8.2-prod/Dockerfile new file mode 100644 index 0000000..3587b53 --- /dev/null +++ b/8.2-prod/Dockerfile @@ -0,0 +1,14 @@ +FROM wordpress:cli-php8.2 as wordpress-cli +FROM wordpress:php8.2-fpm-alpine as wordpress +FROM kooldev/php:8.2-prod + + +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.2-prod/entrypoint b/8.2-prod/entrypoint new file mode 100644 index 0000000..553e1a2 --- /dev/null +++ b/8.2-prod/entrypoint @@ -0,0 +1,90 @@ +#!/bin/bash +set -eo pipefail + + +# 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.2/Dockerfile b/8.2/Dockerfile new file mode 100644 index 0000000..a421773 --- /dev/null +++ b/8.2/Dockerfile @@ -0,0 +1,14 @@ +FROM wordpress:cli-php8.2 as wordpress-cli +FROM wordpress:php8.2-fpm-alpine as wordpress +FROM kooldev/php:8.2 + + +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.2/entrypoint b/8.2/entrypoint new file mode 100644 index 0000000..553e1a2 --- /dev/null +++ b/8.2/entrypoint @@ -0,0 +1,90 @@ +#!/bin/bash +set -eo pipefail + + +# 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/README.md b/README.md index 4f38841..3ed64fd 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ Minimal PHP Docker image for wordpress based on [kooldev/php](https://github.com ## Available Tags +### 8.2 + +- [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.2-nginx](https://github.com/kool-dev/docker-wordpress/blob/master/8.2-nginx/Dockerfile) +- [8.2-nginx-prod](https://github.com/kool-dev/docker-wordpress/blob/master/8.2-nginx-prod/Dockerfile) + ### 8.1 - [8.1](https://github.com/kool-dev/docker-wordpress/blob/master/8.1/Dockerfile) diff --git a/fwd-template.json b/fwd-template.json index 6a57b6c..4ef1f44 100644 --- a/fwd-template.json +++ b/fwd-template.json @@ -228,6 +228,82 @@ "path": "template/entrypoint" } ] + }, + { + "name": "8.2", + "data": { + "from": "kooldev/php:8.2", + "nginx": false, + "prod": false, + "version": "8.2" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile" + }, + { + "name": "entrypoint", + "path": "template/entrypoint" + } + ] + }, + { + "name": "8.2-prod", + "data": { + "from": "kooldev/php:8.2-prod", + "nginx": false, + "prod": true, + "version": "8.2" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile" + }, + { + "name": "entrypoint", + "path": "template/entrypoint" + } + ] + }, + { + "name": "8.2-nginx", + "data": { + "from": "kooldev/php:8.2-nginx", + "nginx": true, + "prod": false, + "version": "8.2" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile" + }, + { + "name": "entrypoint", + "path": "template/entrypoint" + } + ] + }, + { + "name": "8.2-nginx-prod", + "data": { + "from": "kooldev/php:8.2-nginx-prod", + "nginx": true, + "prod": true, + "version": "8.2" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile" + }, + { + "name": "entrypoint", + "path": "template/entrypoint" + } + ] } ] } diff --git a/template/entrypoint.blade.php b/template/entrypoint.blade.php index 48d1531..f0a9a07 100644 --- a/template/entrypoint.blade.php +++ b/template/entrypoint.blade.php @@ -18,77 +18,76 @@ group=kool uid=$(id -u) -if [ "$1" = "php-fpm" ] || [ "$1" = "supervisord" ]; then +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" . + 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)" + echo >&2 "WARNING: $PWD is not empty! (copying anyhow)" fi sourceTarArgs=( - --create - --file - - --directory /kool/wordpress - --owner "$user" --group "$group" + --create + --file - + --directory /kool/wordpress + --owner "$user" --group "$group" ) targetTarArgs=( - --extract - --file - + --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 ) + # 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/*/*/ \ + /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" ) + echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)" + sourceTarArgs+=( --exclude "./$contentPath" ) fi done tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}" - chown -R "$user:$group" /app 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 + 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 From 1fc2d37963f9ea81be78c915cccb6e1a612c47d4 Mon Sep 17 00:00:00 2001 From: Daniel Polito Date: Tue, 12 Sep 2023 19:05:34 -0300 Subject: [PATCH 2/2] Adding ARM build --- .github/workflows/ci-cd.yml | 50 ++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8cecad7..fe064e7 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -3,8 +3,6 @@ name: CI/CD on: push: workflow_dispatch: - schedule: - - cron: '0 0 * * 0' env: DOCKER_BUILDKIT: 1 @@ -19,17 +17,27 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@master + uses: actions/checkout@v3 - - name: Build image - run: | - docker build \ - --tag kooldev/wordpress:${{ matrix.version }}${{ matrix.type }} \ - ${{ matrix.version }}${{ matrix.type }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and export to Docker + uses: docker/build-push-action@v3 + with: + context: ${{ matrix.version }}${{ matrix.type }} + load: true + tags: kooldev/wordpress:${{ matrix.version }}${{ matrix.type }} - docker build \ - --tag kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} \ - ${{ matrix.version }}-nginx${{ matrix.type }} + - name: Build and export to Docker (nginx) + uses: docker/build-push-action@v3 + with: + context: ${{ matrix.version }}-nginx${{ matrix.type }} + load: true + tags: kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} - name: Test docker images PHP executable run: | @@ -48,7 +56,7 @@ jobs: docker run kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} php /kool/wordpress/index.php - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-wordpress' with: username: ${{ secrets.DOCKER_USERNAME }} @@ -59,3 +67,21 @@ jobs: run: | docker push kooldev/wordpress:${{ matrix.version }}${{ matrix.type }} docker push kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }} + + - name: Build and push + uses: docker/build-push-action@v3 + if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-wordpress' + with: + context: ${{ matrix.version }}${{ matrix.type }} + platforms: linux/amd64,linux/arm64 + push: true + tags: kooldev/wordpress:${{ matrix.version }}${{ matrix.type }} + + - name: Build and push (nginx) + uses: docker/build-push-action@v3 + if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-wordpress' + with: + context: ${{ matrix.version }}-nginx${{ matrix.type }} + platforms: linux/amd64,linux/arm64 + push: true + tags: kooldev/wordpress:${{ matrix.version }}-nginx${{ matrix.type }}