-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update wordpress #9772
Update wordpress #9772
Conversation
Changes: - docker-library/wordpress@fb920c6: Merge pull request docker-library/wordpress#572 from infosiftr/un-beta - docker-library/wordpress@891b710: Move "wp-config-docker.php" to non-beta (5.7 GA) - docker-library/wordpress@24c4469: Update latest to 5.7.0 - docker-library/wordpress@59404ef: Update beta to 5.7.0
Diff for a279243:diff --git a/_bashbrew-cat b/_bashbrew-cat
index c647fd9..349657b 100644
--- a/_bashbrew-cat
+++ b/_bashbrew-cat
@@ -1,96 +1,51 @@
Maintainers: Tianon Gravi <admwiggin@gmail.com> (@tianon), Joseph Ferguson <yosifkit@gmail.com> (@yosifkit)
GitRepo: https://github.com/docker-library/wordpress.git
-Tags: 5.6.2-apache, 5.6-apache, 5-apache, apache, 5.6.2, 5.6, 5, latest, 5.6.2-php7.4-apache, 5.6-php7.4-apache, 5-php7.4-apache, php7.4-apache, 5.6.2-php7.4, 5.6-php7.4, 5-php7.4, php7.4
+Tags: 5.7.0-apache, 5.7-apache, 5-apache, apache, 5.7.0, 5.7, 5, latest, 5.7.0-php7.4-apache, 5.7-php7.4-apache, 5-php7.4-apache, php7.4-apache, 5.7.0-php7.4, 5.7-php7.4, 5-php7.4, php7.4
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php7.4/apache
-Tags: 5.6.2-fpm, 5.6-fpm, 5-fpm, fpm, 5.6.2-php7.4-fpm, 5.6-php7.4-fpm, 5-php7.4-fpm, php7.4-fpm
+Tags: 5.7.0-fpm, 5.7-fpm, 5-fpm, fpm, 5.7.0-php7.4-fpm, 5.7-php7.4-fpm, 5-php7.4-fpm, php7.4-fpm
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php7.4/fpm
-Tags: 5.6.2-fpm-alpine, 5.6-fpm-alpine, 5-fpm-alpine, fpm-alpine, 5.6.2-php7.4-fpm-alpine, 5.6-php7.4-fpm-alpine, 5-php7.4-fpm-alpine, php7.4-fpm-alpine
+Tags: 5.7.0-fpm-alpine, 5.7-fpm-alpine, 5-fpm-alpine, fpm-alpine, 5.7.0-php7.4-fpm-alpine, 5.7-php7.4-fpm-alpine, 5-php7.4-fpm-alpine, php7.4-fpm-alpine
Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php7.4/fpm-alpine
-Tags: 5.6.2-php7.3-apache, 5.6-php7.3-apache, 5-php7.3-apache, php7.3-apache, 5.6.2-php7.3, 5.6-php7.3, 5-php7.3, php7.3
+Tags: 5.7.0-php7.3-apache, 5.7-php7.3-apache, 5-php7.3-apache, php7.3-apache, 5.7.0-php7.3, 5.7-php7.3, 5-php7.3, php7.3
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php7.3/apache
-Tags: 5.6.2-php7.3-fpm, 5.6-php7.3-fpm, 5-php7.3-fpm, php7.3-fpm
+Tags: 5.7.0-php7.3-fpm, 5.7-php7.3-fpm, 5-php7.3-fpm, php7.3-fpm
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php7.3/fpm
-Tags: 5.6.2-php7.3-fpm-alpine, 5.6-php7.3-fpm-alpine, 5-php7.3-fpm-alpine, php7.3-fpm-alpine
+Tags: 5.7.0-php7.3-fpm-alpine, 5.7-php7.3-fpm-alpine, 5-php7.3-fpm-alpine, php7.3-fpm-alpine
Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php7.3/fpm-alpine
-Tags: 5.6.2-php8.0-apache, 5.6-php8.0-apache, 5-php8.0-apache, php8.0-apache, 5.6.2-php8.0, 5.6-php8.0, 5-php8.0, php8.0
+Tags: 5.7.0-php8.0-apache, 5.7-php8.0-apache, 5-php8.0-apache, php8.0-apache, 5.7.0-php8.0, 5.7-php8.0, 5-php8.0, php8.0
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php8.0/apache
-Tags: 5.6.2-php8.0-fpm, 5.6-php8.0-fpm, 5-php8.0-fpm, php8.0-fpm
+Tags: 5.7.0-php8.0-fpm, 5.7-php8.0-fpm, 5-php8.0-fpm, php8.0-fpm
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php8.0/fpm
-Tags: 5.6.2-php8.0-fpm-alpine, 5.6-php8.0-fpm-alpine, 5-php8.0-fpm-alpine, php8.0-fpm-alpine
+Tags: 5.7.0-php8.0-fpm-alpine, 5.7-php8.0-fpm-alpine, 5-php8.0-fpm-alpine, php8.0-fpm-alpine
Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: b5d8e4f40bef55630fcf52a0f2830619f4df140e
+GitCommit: 891b7108294a629e6cc16c2f4bf643d9475894cc
Directory: latest/php8.0/fpm-alpine
-Tags: beta-5.7-RC3-apache, beta-5.7-apache, beta-5-apache, beta-apache, beta-5.7-RC3, beta-5.7, beta-5, beta, beta-5.7-RC3-php7.4-apache, beta-5.7-php7.4-apache, beta-5-php7.4-apache, beta-php7.4-apache, beta-5.7-RC3-php7.4, beta-5.7-php7.4, beta-5-php7.4, beta-php7.4
-Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php7.4/apache
-
-Tags: beta-5.7-RC3-fpm, beta-5.7-fpm, beta-5-fpm, beta-fpm, beta-5.7-RC3-php7.4-fpm, beta-5.7-php7.4-fpm, beta-5-php7.4-fpm, beta-php7.4-fpm
-Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php7.4/fpm
-
-Tags: beta-5.7-RC3-fpm-alpine, beta-5.7-fpm-alpine, beta-5-fpm-alpine, beta-fpm-alpine, beta-5.7-RC3-php7.4-fpm-alpine, beta-5.7-php7.4-fpm-alpine, beta-5-php7.4-fpm-alpine, beta-php7.4-fpm-alpine
-Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php7.4/fpm-alpine
-
-Tags: beta-5.7-RC3-php7.3-apache, beta-5.7-php7.3-apache, beta-5-php7.3-apache, beta-php7.3-apache, beta-5.7-RC3-php7.3, beta-5.7-php7.3, beta-5-php7.3, beta-php7.3
-Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php7.3/apache
-
-Tags: beta-5.7-RC3-php7.3-fpm, beta-5.7-php7.3-fpm, beta-5-php7.3-fpm, beta-php7.3-fpm
-Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php7.3/fpm
-
-Tags: beta-5.7-RC3-php7.3-fpm-alpine, beta-5.7-php7.3-fpm-alpine, beta-5-php7.3-fpm-alpine, beta-php7.3-fpm-alpine
-Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php7.3/fpm-alpine
-
-Tags: beta-5.7-RC3-php8.0-apache, beta-5.7-php8.0-apache, beta-5-php8.0-apache, beta-php8.0-apache, beta-5.7-RC3-php8.0, beta-5.7-php8.0, beta-5-php8.0, beta-php8.0
-Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php8.0/apache
-
-Tags: beta-5.7-RC3-php8.0-fpm, beta-5.7-php8.0-fpm, beta-5-php8.0-fpm, beta-php8.0-fpm
-Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, mips64le, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php8.0/fpm
-
-Tags: beta-5.7-RC3-php8.0-fpm-alpine, beta-5.7-php8.0-fpm-alpine, beta-5-php8.0-fpm-alpine, beta-php8.0-fpm-alpine
-Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
-GitCommit: 9af49aa4f49385bf999626c89838b98ab2b980ad
-Directory: beta/php8.0/fpm-alpine
-
Tags: cli-2.4.0, cli-2.4, cli-2, cli, cli-2.4.0-php7.4, cli-2.4-php7.4, cli-2-php7.4, cli-php7.4
Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
GitCommit: fe3078d7544bd0bd77e30e1121988234f426dff9
diff --git a/_bashbrew-list b/_bashbrew-list
index 8790e6e..c9b1043 100644
--- a/_bashbrew-list
+++ b/_bashbrew-list
@@ -14,103 +14,39 @@ wordpress:5-php8.0
wordpress:5-php8.0-apache
wordpress:5-php8.0-fpm
wordpress:5-php8.0-fpm-alpine
-wordpress:5.6
-wordpress:5.6-apache
-wordpress:5.6-fpm
-wordpress:5.6-fpm-alpine
-wordpress:5.6-php7.3
-wordpress:5.6-php7.3-apache
-wordpress:5.6-php7.3-fpm
-wordpress:5.6-php7.3-fpm-alpine
-wordpress:5.6-php7.4
-wordpress:5.6-php7.4-apache
-wordpress:5.6-php7.4-fpm
-wordpress:5.6-php7.4-fpm-alpine
-wordpress:5.6-php8.0
-wordpress:5.6-php8.0-apache
-wordpress:5.6-php8.0-fpm
-wordpress:5.6-php8.0-fpm-alpine
-wordpress:5.6.2
-wordpress:5.6.2-apache
-wordpress:5.6.2-fpm
-wordpress:5.6.2-fpm-alpine
-wordpress:5.6.2-php7.3
-wordpress:5.6.2-php7.3-apache
-wordpress:5.6.2-php7.3-fpm
-wordpress:5.6.2-php7.3-fpm-alpine
-wordpress:5.6.2-php7.4
-wordpress:5.6.2-php7.4-apache
-wordpress:5.6.2-php7.4-fpm
-wordpress:5.6.2-php7.4-fpm-alpine
-wordpress:5.6.2-php8.0
-wordpress:5.6.2-php8.0-apache
-wordpress:5.6.2-php8.0-fpm
-wordpress:5.6.2-php8.0-fpm-alpine
+wordpress:5.7
+wordpress:5.7-apache
+wordpress:5.7-fpm
+wordpress:5.7-fpm-alpine
+wordpress:5.7-php7.3
+wordpress:5.7-php7.3-apache
+wordpress:5.7-php7.3-fpm
+wordpress:5.7-php7.3-fpm-alpine
+wordpress:5.7-php7.4
+wordpress:5.7-php7.4-apache
+wordpress:5.7-php7.4-fpm
+wordpress:5.7-php7.4-fpm-alpine
+wordpress:5.7-php8.0
+wordpress:5.7-php8.0-apache
+wordpress:5.7-php8.0-fpm
+wordpress:5.7-php8.0-fpm-alpine
+wordpress:5.7.0
+wordpress:5.7.0-apache
+wordpress:5.7.0-fpm
+wordpress:5.7.0-fpm-alpine
+wordpress:5.7.0-php7.3
+wordpress:5.7.0-php7.3-apache
+wordpress:5.7.0-php7.3-fpm
+wordpress:5.7.0-php7.3-fpm-alpine
+wordpress:5.7.0-php7.4
+wordpress:5.7.0-php7.4-apache
+wordpress:5.7.0-php7.4-fpm
+wordpress:5.7.0-php7.4-fpm-alpine
+wordpress:5.7.0-php8.0
+wordpress:5.7.0-php8.0-apache
+wordpress:5.7.0-php8.0-fpm
+wordpress:5.7.0-php8.0-fpm-alpine
wordpress:apache
-wordpress:beta
-wordpress:beta-5
-wordpress:beta-5-apache
-wordpress:beta-5-fpm
-wordpress:beta-5-fpm-alpine
-wordpress:beta-5-php7.3
-wordpress:beta-5-php7.3-apache
-wordpress:beta-5-php7.3-fpm
-wordpress:beta-5-php7.3-fpm-alpine
-wordpress:beta-5-php7.4
-wordpress:beta-5-php7.4-apache
-wordpress:beta-5-php7.4-fpm
-wordpress:beta-5-php7.4-fpm-alpine
-wordpress:beta-5-php8.0
-wordpress:beta-5-php8.0-apache
-wordpress:beta-5-php8.0-fpm
-wordpress:beta-5-php8.0-fpm-alpine
-wordpress:beta-5.7
-wordpress:beta-5.7-RC3
-wordpress:beta-5.7-RC3-apache
-wordpress:beta-5.7-RC3-fpm
-wordpress:beta-5.7-RC3-fpm-alpine
-wordpress:beta-5.7-RC3-php7.3
-wordpress:beta-5.7-RC3-php7.3-apache
-wordpress:beta-5.7-RC3-php7.3-fpm
-wordpress:beta-5.7-RC3-php7.3-fpm-alpine
-wordpress:beta-5.7-RC3-php7.4
-wordpress:beta-5.7-RC3-php7.4-apache
-wordpress:beta-5.7-RC3-php7.4-fpm
-wordpress:beta-5.7-RC3-php7.4-fpm-alpine
-wordpress:beta-5.7-RC3-php8.0
-wordpress:beta-5.7-RC3-php8.0-apache
-wordpress:beta-5.7-RC3-php8.0-fpm
-wordpress:beta-5.7-RC3-php8.0-fpm-alpine
-wordpress:beta-5.7-apache
-wordpress:beta-5.7-fpm
-wordpress:beta-5.7-fpm-alpine
-wordpress:beta-5.7-php7.3
-wordpress:beta-5.7-php7.3-apache
-wordpress:beta-5.7-php7.3-fpm
-wordpress:beta-5.7-php7.3-fpm-alpine
-wordpress:beta-5.7-php7.4
-wordpress:beta-5.7-php7.4-apache
-wordpress:beta-5.7-php7.4-fpm
-wordpress:beta-5.7-php7.4-fpm-alpine
-wordpress:beta-5.7-php8.0
-wordpress:beta-5.7-php8.0-apache
-wordpress:beta-5.7-php8.0-fpm
-wordpress:beta-5.7-php8.0-fpm-alpine
-wordpress:beta-apache
-wordpress:beta-fpm
-wordpress:beta-fpm-alpine
-wordpress:beta-php7.3
-wordpress:beta-php7.3-apache
-wordpress:beta-php7.3-fpm
-wordpress:beta-php7.3-fpm-alpine
-wordpress:beta-php7.4
-wordpress:beta-php7.4-apache
-wordpress:beta-php7.4-fpm
-wordpress:beta-php7.4-fpm-alpine
-wordpress:beta-php8.0
-wordpress:beta-php8.0-apache
-wordpress:beta-php8.0-fpm
-wordpress:beta-php8.0-fpm-alpine
wordpress:cli
wordpress:cli-2
wordpress:cli-2-php7.3
diff --git a/wordpress_beta-php7.3-fpm-alpine/Dockerfile b/wordpress_beta-php7.3-fpm-alpine/Dockerfile
deleted file mode 100644
index 5693d44..0000000
diff --git a/wordpress_beta-php7.3-fpm-alpine/docker-entrypoint.sh b/wordpress_beta-php7.3-fpm-alpine/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php7.3-fpm/Dockerfile b/wordpress_beta-php7.3-fpm/Dockerfile
deleted file mode 100644
index 715537c..0000000
diff --git a/wordpress_beta-php7.3-fpm/docker-entrypoint.sh b/wordpress_beta-php7.3-fpm/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php7.3/Dockerfile b/wordpress_beta-php7.3/Dockerfile
deleted file mode 100644
index 52aa76e..0000000
diff --git a/wordpress_beta-php7.3/docker-entrypoint.sh b/wordpress_beta-php7.3/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php7.4-fpm-alpine/Dockerfile b/wordpress_beta-php7.4-fpm-alpine/Dockerfile
deleted file mode 100644
index 467395f..0000000
diff --git a/wordpress_beta-php7.4-fpm-alpine/docker-entrypoint.sh b/wordpress_beta-php7.4-fpm-alpine/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php7.4-fpm/Dockerfile b/wordpress_beta-php7.4-fpm/Dockerfile
deleted file mode 100644
index 3b97ef4..0000000
diff --git a/wordpress_beta-php7.4-fpm/docker-entrypoint.sh b/wordpress_beta-php7.4-fpm/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php7.4/Dockerfile b/wordpress_beta-php7.4/Dockerfile
deleted file mode 100644
index ac24bb7..0000000
diff --git a/wordpress_beta-php7.4/docker-entrypoint.sh b/wordpress_beta-php7.4/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php8.0-fpm-alpine/Dockerfile b/wordpress_beta-php8.0-fpm-alpine/Dockerfile
deleted file mode 100644
index 97f24ac..0000000
diff --git a/wordpress_beta-php8.0-fpm-alpine/docker-entrypoint.sh b/wordpress_beta-php8.0-fpm-alpine/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php8.0-fpm/Dockerfile b/wordpress_beta-php8.0-fpm/Dockerfile
deleted file mode 100644
index f0befc4..0000000
diff --git a/wordpress_beta-php8.0-fpm/docker-entrypoint.sh b/wordpress_beta-php8.0-fpm/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_beta-php8.0/Dockerfile b/wordpress_beta-php8.0/Dockerfile
deleted file mode 100644
index e2d8d18..0000000
diff --git a/wordpress_beta-php8.0/docker-entrypoint.sh b/wordpress_beta-php8.0/docker-entrypoint.sh
deleted file mode 100755
index 0fca21c..0000000
diff --git a/wordpress_php7.3-fpm-alpine/Dockerfile b/wordpress_php7.3-fpm-alpine/Dockerfile
index b09943d..529d23b 100644
--- a/wordpress_php7.3-fpm-alpine/Dockerfile
+++ b/wordpress_php7.3-fpm-alpine/Dockerfile
@@ -82,8 +82,8 @@ RUN { \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -121,6 +121,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php7.3-fpm-alpine/docker-entrypoint.sh b/wordpress_php7.3-fpm-alpine/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php7.3-fpm-alpine/docker-entrypoint.sh
+++ b/wordpress_php7.3-fpm-alpine/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php7.3-fpm-alpine/wp-config-docker.php b/wordpress_php7.3-fpm-alpine/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php7.3-fpm-alpine/wp-config-docker.php
rename to wordpress_php7.3-fpm-alpine/wp-config-docker.php
diff --git a/wordpress_php7.3-fpm/Dockerfile b/wordpress_php7.3-fpm/Dockerfile
index f6bc915..806f34a 100644
--- a/wordpress_php7.3-fpm/Dockerfile
+++ b/wordpress_php7.3-fpm/Dockerfile
@@ -85,8 +85,8 @@ RUN { \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -124,6 +124,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php7.3-fpm/docker-entrypoint.sh b/wordpress_php7.3-fpm/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php7.3-fpm/docker-entrypoint.sh
+++ b/wordpress_php7.3-fpm/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php7.3-fpm/wp-config-docker.php b/wordpress_php7.3-fpm/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php7.3-fpm/wp-config-docker.php
rename to wordpress_php7.3-fpm/wp-config-docker.php
diff --git a/wordpress_php7.3/Dockerfile b/wordpress_php7.3/Dockerfile
index 591eeda..091a064 100644
--- a/wordpress_php7.3/Dockerfile
+++ b/wordpress_php7.3/Dockerfile
@@ -104,8 +104,8 @@ RUN set -eux; \
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -143,6 +143,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php7.3/docker-entrypoint.sh b/wordpress_php7.3/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php7.3/docker-entrypoint.sh
+++ b/wordpress_php7.3/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php7.3/wp-config-docker.php b/wordpress_php7.3/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php7.3/wp-config-docker.php
rename to wordpress_php7.3/wp-config-docker.php
diff --git a/wordpress_php7.4-fpm-alpine/Dockerfile b/wordpress_php7.4-fpm-alpine/Dockerfile
index 6096692..13675a6 100644
--- a/wordpress_php7.4-fpm-alpine/Dockerfile
+++ b/wordpress_php7.4-fpm-alpine/Dockerfile
@@ -81,8 +81,8 @@ RUN { \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -120,6 +120,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php7.4-fpm-alpine/docker-entrypoint.sh b/wordpress_php7.4-fpm-alpine/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php7.4-fpm-alpine/docker-entrypoint.sh
+++ b/wordpress_php7.4-fpm-alpine/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php7.4-fpm-alpine/wp-config-docker.php b/wordpress_php7.4-fpm-alpine/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php7.4-fpm-alpine/wp-config-docker.php
rename to wordpress_php7.4-fpm-alpine/wp-config-docker.php
diff --git a/wordpress_php7.4-fpm/Dockerfile b/wordpress_php7.4-fpm/Dockerfile
index cfbb73e..266e857 100644
--- a/wordpress_php7.4-fpm/Dockerfile
+++ b/wordpress_php7.4-fpm/Dockerfile
@@ -84,8 +84,8 @@ RUN { \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -123,6 +123,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php7.4-fpm/docker-entrypoint.sh b/wordpress_php7.4-fpm/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php7.4-fpm/docker-entrypoint.sh
+++ b/wordpress_php7.4-fpm/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php7.4-fpm/wp-config-docker.php b/wordpress_php7.4-fpm/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php7.4-fpm/wp-config-docker.php
rename to wordpress_php7.4-fpm/wp-config-docker.php
diff --git a/wordpress_php7.4/Dockerfile b/wordpress_php7.4/Dockerfile
index bdc54d7..6a9b74f 100644
--- a/wordpress_php7.4/Dockerfile
+++ b/wordpress_php7.4/Dockerfile
@@ -103,8 +103,8 @@ RUN set -eux; \
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -142,6 +142,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php7.4/docker-entrypoint.sh b/wordpress_php7.4/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php7.4/docker-entrypoint.sh
+++ b/wordpress_php7.4/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php7.4/wp-config-docker.php b/wordpress_php7.4/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php7.4/wp-config-docker.php
rename to wordpress_php7.4/wp-config-docker.php
diff --git a/wordpress_php8.0-fpm-alpine/Dockerfile b/wordpress_php8.0-fpm-alpine/Dockerfile
index 2f8c0eb..cd15b98 100644
--- a/wordpress_php8.0-fpm-alpine/Dockerfile
+++ b/wordpress_php8.0-fpm-alpine/Dockerfile
@@ -76,8 +76,8 @@ RUN { \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -115,6 +115,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php8.0-fpm-alpine/docker-entrypoint.sh b/wordpress_php8.0-fpm-alpine/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php8.0-fpm-alpine/docker-entrypoint.sh
+++ b/wordpress_php8.0-fpm-alpine/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php8.0-fpm-alpine/wp-config-docker.php b/wordpress_php8.0-fpm-alpine/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php8.0-fpm-alpine/wp-config-docker.php
rename to wordpress_php8.0-fpm-alpine/wp-config-docker.php
diff --git a/wordpress_php8.0-fpm/Dockerfile b/wordpress_php8.0-fpm/Dockerfile
index 1370ea8..80f40c9 100644
--- a/wordpress_php8.0-fpm/Dockerfile
+++ b/wordpress_php8.0-fpm/Dockerfile
@@ -81,8 +81,8 @@ RUN { \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -120,6 +120,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php8.0-fpm/docker-entrypoint.sh b/wordpress_php8.0-fpm/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php8.0-fpm/docker-entrypoint.sh
+++ b/wordpress_php8.0-fpm/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php8.0-fpm/wp-config-docker.php b/wordpress_php8.0-fpm/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php8.0-fpm/wp-config-docker.php
rename to wordpress_php8.0-fpm/wp-config-docker.php
diff --git a/wordpress_php8.0/Dockerfile b/wordpress_php8.0/Dockerfile
index ff8a62e..887fe74 100644
--- a/wordpress_php8.0/Dockerfile
+++ b/wordpress_php8.0/Dockerfile
@@ -100,8 +100,8 @@ RUN set -eux; \
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +
RUN set -eux; \
- version='5.6.2'; \
- sha1='8d19761595182c25d107813b55b911a22e7c809b'; \
+ version='5.7'; \
+ sha1='76d1332cfcbc5f8b17151b357999d1f758faf897'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
@@ -139,6 +139,7 @@ RUN set -eux; \
VOLUME /var/www/html
+COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/wordpress_php8.0/docker-entrypoint.sh b/wordpress_php8.0/docker-entrypoint.sh
index 6a40c02..0fca21c 100755
--- a/wordpress_php8.0/docker-entrypoint.sh
+++ b/wordpress_php8.0/docker-entrypoint.sh
@@ -1,30 +1,10 @@
-#!/bin/bash
-set -euo pipefail
+#!/usr/bin/env bash
+set -Eeuo pipefail
-# usage: file_env VAR [DEFAULT]
-# ie: file_env 'XYZ_DB_PASSWORD' 'example'
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
-# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
-file_env() {
- local var="$1"
- local fileVar="${var}_FILE"
- local def="${2:-}"
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
- exit 1
- fi
- local val="$def"
- if [ "${!var:-}" ]; then
- val="${!var}"
- elif [ "${!fileVar:-}" ]; then
- val="$(< "${!fileVar}")"
- fi
- export "$var"="$val"
- unset "$fileVar"
-}
-
-if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
- if [ "$(id -u)" = '0' ]; then
+if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
+ uid="$(id -u)"
+ gid="$(id -g)"
+ if [ "$uid" = '0' ]; then
case "$1" in
apache2*)
user="${APACHE_RUN_USER:-www-data}"
@@ -41,13 +21,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
;;
esac
else
- user="$(id -u)"
- group="$(id -g)"
+ user="$uid"
+ group="$gid"
fi
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 [ "$(id -u)" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
+ if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
@@ -65,7 +45,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
--extract
--file -
)
- if [ "$user" != '0' ]; then
+ 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
@@ -84,202 +64,28 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
- # allow any of these "Authentication Unique Keys and Salts." to be specified via
- # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
- uniqueEnvs=(
- AUTH_KEY
- SECURE_AUTH_KEY
- LOGGED_IN_KEY
- NONCE_KEY
- AUTH_SALT
- SECURE_AUTH_SALT
- LOGGED_IN_SALT
- NONCE_SALT
- )
- envs=(
- WORDPRESS_DB_HOST
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
- WORDPRESS_DB_CHARSET
- WORDPRESS_DB_COLLATE
- "${uniqueEnvs[@]/#/WORDPRESS_}"
- WORDPRESS_TABLE_PREFIX
- WORDPRESS_DEBUG
- WORDPRESS_CONFIG_EXTRA
- )
- haveConfig=
- for e in "${envs[@]}"; do
- file_env "$e"
- if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
- haveConfig=1
- fi
- done
-
- # linking backwards-compatibility
- if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
- haveConfig=1
- # host defaults to "mysql" below if unspecified
- : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
- if [ "$WORDPRESS_DB_USER" = 'root' ]; then
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
- else
- : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
- fi
- : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
- fi
-
- # only touch "wp-config.php" if we have environment-supplied configuration values
- if [ "$haveConfig" ]; then
- : "${WORDPRESS_DB_HOST:=mysql}"
- : "${WORDPRESS_DB_USER:=root}"
- : "${WORDPRESS_DB_PASSWORD:=}"
- : "${WORDPRESS_DB_NAME:=wordpress}"
- : "${WORDPRESS_DB_CHARSET:=utf8}"
- : "${WORDPRESS_DB_COLLATE:=}"
-
- # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
- # https://github.com/docker-library/wordpress/issues/116
- # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
- sed -ri -e 's/\r$//' wp-config*
-
- if [ ! -e wp-config.php ]; then
+ wpEnvs=( "${!WORDPRESS_@}" )
+ if [ ! -s wp-config.php ] && [ "${#wpEnvs[@]}" -gt 0 ]; then
+ for wpConfigDocker in \
+ wp-config-docker.php \
+ /usr/src/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 '
- /^\/\*.*stop editing.*\*\/$/ && c == 0 {
- c = 1
- system("cat")
- if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
- print "// WORDPRESS_CONFIG_EXTRA"
- print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
- }
+ /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 }
- ' wp-config-sample.php > wp-config.php <<'EOPHP'
-// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
-// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
-if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
- $_SERVER['HTTPS'] = 'on';
-}
-
-EOPHP
- chown "$user:$group" wp-config.php
- elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
- # (if the config file already contains the requested PHP code, don't print a warning)
- echo >&2
- echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
- echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
- echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
- echo >&2
- fi
-
- # see http://stackoverflow.com/a/2705678/433558
- sed_escape_lhs() {
- echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
- }
- sed_escape_rhs() {
- echo "$@" | sed -e 's/[\/&]/\\&/g'
- }
- php_escape() {
- local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
- if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
- escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
- fi
- echo "$escaped"
- }
- set_config() {
- key="$1"
- value="$2"
- var_type="${3:-string}"
- start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
- end="\);"
- if [ "${key:0:1}" = '$' ]; then
- start="^(\s*)$(sed_escape_lhs "$key")\s*="
- end=";"
- fi
- sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
- }
-
- set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
- set_config 'DB_USER' "$WORDPRESS_DB_USER"
- set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
- set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
- set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
- set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
-
- for unique in "${uniqueEnvs[@]}"; do
- uniqVar="WORDPRESS_$unique"
- if [ -n "${!uniqVar}" ]; then
- set_config "$unique" "${!uniqVar}"
- else
- # if not specified, let's generate a random value
- currentVal="$(sed -rn -e "s/define\(\s*(([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\s*\);/\4/p" wp-config.php)"
- if [ "$currentVal" = 'put your unique phrase here' ]; then
- set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
- fi
+ ' "$wpConfigDocker" > wp-config.php
+ break
fi
done
-
- if [ "$WORDPRESS_TABLE_PREFIX" ]; then
- set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
- fi
-
- if [ "$WORDPRESS_DEBUG" ]; then
- set_config 'WP_DEBUG' 1 boolean
fi
-
- if ! TERM=dumb php -- <<'EOPHP'
-<?php
-// database might not exist, so let's try creating it (just to be safe)
-
-$stderr = fopen('php://stderr', 'w');
-
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
-// "hostname:port"
-// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
-// "hostname:unix-socket-path"
-list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
-$port = 0;
-if (is_numeric($socket)) {
- $port = (int) $socket;
- $socket = null;
-}
-$user = getenv('WORDPRESS_DB_USER');
-$pass = getenv('WORDPRESS_DB_PASSWORD');
-$dbName = getenv('WORDPRESS_DB_NAME');
-
-$maxTries = 10;
-do {
- $mysql = new mysqli($host, $user, $pass, '', $port, $socket);
- if ($mysql->connect_error) {
- fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
- --$maxTries;
- if ($maxTries <= 0) {
- exit(1);
- }
- sleep(3);
- }
-} while ($mysql->connect_error);
-
-if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
- fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
- $mysql->close();
- exit(1);
-}
-
-$mysql->close();
-EOPHP
- then
- echo >&2
- echo >&2 "WARNING: unable to establish a database connection to '$WORDPRESS_DB_HOST'"
- echo >&2 ' continuing anyways (which might have unexpected results)'
- echo >&2
- fi
- fi
-
- # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
- for e in "${envs[@]}"; do
- unset "$e"
- done
fi
exec "$@"
diff --git a/wordpress_beta-php8.0/wp-config-docker.php b/wordpress_php8.0/wp-config-docker.php
similarity index 100%
rename from wordpress_beta-php8.0/wp-config-docker.php
rename to wordpress_php8.0/wp-config-docker.php
|
Just to make sure the important bits / migration path for users are in more places they might look when things don't seem to be working the same way they used to, see docker-library/wordpress#557 (comment):
|
Changes:
Important Note: now that 5.7 is GA, this includes docker-library/wordpress#557 in all tags (no longer
beta
-only).