wp doesn't work any more #21

Closed
opened 2021-03-13 17:44:06 +00:00 by 3wordchant · 1 comment
Owner

As of the Wordpress 5.7 update this week, the default wp-config.php now seems to load environment variables directly:

define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'database_name_here') );

Unfortunately, the separate recommended wp-cli container doesn't have access to the env variables:

$ echo $WORDPRESS_DB_PASSWORD
$ 

And there doesn't seem to be a corresponding --env-from (like --volumes-from) to load all of them without doing it manually.

The mission to make the most useful WP tool as tricky to use with Docker as humanly possible continues on apace...

As of the Wordpress 5.7 update this week, the default `wp-config.php` now seems to load environment variables directly: `define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'database_name_here') );` Unfortunately, the separate recommended wp-cli container doesn't have access to the env variables: ``` $ echo $WORDPRESS_DB_PASSWORD $ ``` And there doesn't seem to be a corresponding `--env-from` (like `--volumes-from`) to load all of them without doing it manually. The [mission to make the most useful WP tool as tricky to use with Docker as humanly possible](https://github.com/docker-library/wordpress/issues/283) continues on apace...
Author
Owner

This almost works, but there seems to be no way to provide a Docker secret to a container launched with docker run, so I'm stuck again:

diff --git a/abra.sh b/abra.sh
index 66a00db..113f9a7 100644
--- a/abra.sh
+++ b/abra.sh
@@ -4,15 +4,22 @@ export ENTRYPOINT_MAILRELAY_CONF_VERSION=v1
 export MSMTP_CONF_VERSION=v1
 
 sub_wp() {
-  load_instance
-  load_instance_env
-	CONTAINER=$(docker container ls -f "Name=${STACK_NAME}_app" --format '{{ .ID }}')
+  CONTAINER=$(docker container ls -f "Name=${STACK_NAME}_app" --format '{{ .ID }}')
   if [ -z "$CONTAINER" ]; then
     error "Can't find a container for ${STACK_NAME}_app"
     exit
   fi
+  debug "Using Container ID ${CONTAINER}"
   # shellcheck disable=SC2154,SC2086
-  docker run -it --volumes-from "$CONTAINER" --network "container:$CONTAINER" wordpress:cli wp ${abra__args_[*]}
+  docker run -it 
+	--volumes-from "$CONTAINER" 
+	--network "container:$CONTAINER" 
+    -e WORDPRESS_DB_HOST=db 
+    -e WORDPRESS_DB_USER=wordpress 
+    -e WORDPRESS_DB_PASSWORD_FILE=/run/secrets/db_password 
+    -e WORDPRESS_DB_NAME=wordpress 
+    -e WORDPRESS_CONFIG_EXTRA=${WORDPRESS_CONFIG_EXTRA} 
+	wordpress:cli wp ${abra__args_[*]}
 }
 
 abra_backup_app() {
This almost works, but there seems to be no way to provide a Docker secret to a container launched with `docker run`, so I'm stuck again: ``` diff --git a/abra.sh b/abra.sh index 66a00db..113f9a7 100644 --- a/abra.sh +++ b/abra.sh @@ -4,15 +4,22 @@ export ENTRYPOINT_MAILRELAY_CONF_VERSION=v1 export MSMTP_CONF_VERSION=v1 sub_wp() { - load_instance - load_instance_env - CONTAINER=$(docker container ls -f "Name=${STACK_NAME}_app" --format '{{ .ID }}') + CONTAINER=$(docker container ls -f "Name=${STACK_NAME}_app" --format '{{ .ID }}') if [ -z "$CONTAINER" ]; then error "Can't find a container for ${STACK_NAME}_app" exit fi + debug "Using Container ID ${CONTAINER}" # shellcheck disable=SC2154,SC2086 - docker run -it --volumes-from "$CONTAINER" --network "container:$CONTAINER" wordpress:cli wp ${abra__args_[*]} + docker run -it + --volumes-from "$CONTAINER" + --network "container:$CONTAINER" + -e WORDPRESS_DB_HOST=db + -e WORDPRESS_DB_USER=wordpress + -e WORDPRESS_DB_PASSWORD_FILE=/run/secrets/db_password + -e WORDPRESS_DB_NAME=wordpress + -e WORDPRESS_CONFIG_EXTRA=${WORDPRESS_CONFIG_EXTRA} + wordpress:cli wp ${abra__args_[*]} } abra_backup_app() { ```
3wordchant referenced this issue from a commit 2021-03-14 12:28:24 +00:00
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coop-cloud/wordpress#21
No description provided.