Skip to content

Commit 08bae59

Browse files
committed
renamed root password variable and added root user variable, added more gripes for missing variables, added explicit upstream version tag
1 parent 1bbaef4 commit 08bae59

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

Dockerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
FROM nickbreen/wp-cli
1+
FROM nickbreen/wp-cli:v1.0.0
22

33
MAINTAINER Nick Breen <nick@foobar.net.nz>
44

5-
ENV MYSQL_ROOT_PASSWORD="" \
5+
ENV WP_DB_ROOT_USER="root" \
6+
WP_DB_ROOT_PASSWORD="" \
67
WP_LOCALE="" \
78
WP_DB_HOST="" \
89
WP_DB_PORT="" \
910
WP_DB_NAME="" \
1011
WP_DB_USER="" \
1112
WP_DB_PASSWORD="" \
1213
WP_DB_PREFIX="" \
14+
WP_SUBDOMAINS="" \
1315
WP_URL="" \
1416
WP_TITLE="" \
1517
WP_ADMIN_USER="" \
1618
WP_ADMIN_PASSWORD="" \
1719
WP_ADMIN_EMAIL="" \
18-
WP_THEMES="" \
19-
BB_THEMES="" \
20-
WP_PLUGINS="" \
21-
BB_PLUGINS="" \
22-
WP_OPTIONS="" \
23-
WP_IMPORT="" \
2420
WP_EXTRA_PHP=""
2521

2622
RUN mkdir -p /usr/local/share/php/

setup.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#!/bin/bash
22

33
# Juggle ENV VARS
4-
: ${MYSQL_ROOT_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
4+
: ${WP_DB_ROOT_USER:=root}
5+
: ${WP_DB_ROOT_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
56
: ${WP_DB_NAME:=$MYSQL_ENV_MYSQL_DATABASE}
67
: ${WP_DB_USER:=$MYSQL_ENV_MYSQL_USER}
78
: ${WP_DB_PASSWORD:=$MYSQL_ENV_MYSQL_PASSWORD}
89
: ${WP_DB_HOST:=$MYSQL_PORT_3306_TCP_ADDR}
910
: ${WP_DB_PORT:=${MYSQL_PORT_3306_TCP_PORT:-3306}}
10-
: ${WP_NETWORK:-no}
1111
: ${WP_SUBDOMAINS:-no}
12-
: ${WP_URL:?WP_URL is required}
12+
: ${WP_URL:? is required}
13+
: ${WP_TITLE:? is required}
14+
: ${WP_ADMIN_USER:? is required}
15+
: ${WP_ADMIN_PASSWORD:? is required}
16+
: ${WP_ADMIN_EMAIL:? is required}
1317

1418
function install_core {
1519
# Download the lastest WP, preferebly with the selected locale, but fall back to the default locale.
@@ -19,12 +23,12 @@ function install_core {
1923
# Setup the database if required.
2024
local SQL="CREATE DATABASE IF NOT EXISTS $WP_DB_NAME; CREATE USER '$WP_DB_USER' IDENTIFIED BY '$WP_DB_PASSWORD'; GRANT ALL PRIVILEGES ON $WP_DB_NAME.* TO '$WP_DB_USER'; FLUSH PRIVILEGES; SHOW GRANTS FOR \"$WP_DB_USER\""
2125
echo Waiting for the server at $WP_DB_HOST
22-
while ! mysql $V -h$WP_DB_HOST -P$WP_DB_PORT -uroot -p$MYSQL_ROOT_PASSWORD -e "SELECT VERSION();"; do sleep 5; done
26+
while ! mysql $V -h$WP_DB_HOST -P$WP_DB_PORT -u$WP_DB_ROOT_USER -p$WP_DB_ROOT_PASSWORD -e "SELECT VERSION();"; do sleep 5; done
2327
echo Checking the DB $WP_DB_NAME and USER $WP_DB_USER is available.
2428
if ! mysql $V -h$WP_DB_HOST -P$WP_DB_PORT -u$WP_DB_USER -p$WP_DB_PASSWORD $WP_DB_NAME -e "SELECT DATABASE(), USER();"
2529
then
2630
echo Set up the DB $WP_DB_NAME and USER $WP_DB_USER.
27-
while ! mysql $V -h$WP_DB_HOST -P$WP_DB_PORT -uroot -p$MYSQL_ROOT_PASSWORD -e "$SQL"; do sleep 5; done
31+
while ! mysql $V -h$WP_DB_HOST -P$WP_DB_PORT -u$WP_DB_ROOT_USER -p$WP_DB_ROOT_PASSWORD -e "$SQL"; do sleep 5; done
2832
fi
2933

3034
# Configure the database
@@ -52,8 +56,6 @@ function install_core {
5256
# Allows execution of arbitrary WP-CLI commands.
5357
# I suppose this is either quite dangerous and makes most of
5458
# the rest of this script redundant.
55-
# Use this carefully as it, rather xargs, will process quotes.
56-
# If you command contains quotes they shall not pass! Without escaping that is.
5759
function wp_commands {
5860
for V in ${!WP_COMMANDS*}
5961
do

0 commit comments

Comments
 (0)