Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash
set -e

if [ -z "$MYSQL_PORT_3306_TCP" ]; then
echo >&2 'error: missing MYSQL_PORT_3306_TCP environment variable'
echo >&2 ' Did you forget to --link some_mysql_container:mysql ?'
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
WORDPRESS_DB_HOST='mysql'
fi

if [ -z "$WORDPRESS_DB_HOST" ]; then
echo >&2 'error: missing WORDPRESS_DB_HOST and MYSQL_PORT_3306_TCP environment variables'
echo >&2 ' Did you forget to --link some_mysql_container:mysql or set an external db'
echo >&2 ' with -e WORDPRESS_DB_HOST=hostname:port?'
exit 1
fi

Expand Down Expand Up @@ -64,8 +69,6 @@ set_config() {
sed -ri "s/((['\"])$key\2\s*,\s*)(['\"]).*\3/\1$sed_escaped_value/" wp-config.php
}

WORDPRESS_DB_HOST='mysql'

set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
set_config 'DB_USER' "$WORDPRESS_DB_USER"
set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
Expand Down