Skip to content

Commit 610717f

Browse files
author
Misty Stanley-Jones
committed
Add support for passing a file path as the value for WORDPRESS_DB_PASSWORD
Allows use of Docker secrets to store these credentials. If the secret has been granted to the container, the password will be available within the container as an unencrypted string in /run/secrets/. Signed-off-by: Misty Stanley-Jones <[email protected]>
1 parent 9c8f5d0 commit 610717f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docker-entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
1010
fi
1111
: ${WORDPRESS_DB_PASSWORD:=$MYSQL_ENV_MYSQL_PASSWORD}
1212
: ${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-wordpress}}
13-
13+
# If the value of WORDPRESS_DB_PASSWORD is a file that exists within
14+
# the container, read the contents of that file (useful if using
15+
# Docker-managed secrets)
16+
if [ -f "$WORDPRESS_DB_PASSWORD" ]; then
17+
WORDPRESS_DB_PASSWORD="$(cat $WORDPRESS_DB_PASSWORD)"
18+
fi
1419
if [ -z "$WORDPRESS_DB_PASSWORD" ]; then
1520
echo >&2 'error: missing required WORDPRESS_DB_PASSWORD environment variable'
1621
echo >&2 ' Did you forget to -e WORDPRESS_DB_PASSWORD=... ?'

0 commit comments

Comments
 (0)