diff --git a/services/pressbooks.sh b/services/pressbooks.sh index 54b3f5d..aa3c514 100644 --- a/services/pressbooks.sh +++ b/services/pressbooks.sh @@ -311,7 +311,14 @@ _pressbooks_normalize_slug() { # code, never wp-config.php, .env, or any book's own content/DB rows). _pressbooks_install_plugins_and_themes() { local _dir="$1" _net="$2" _port="$3" - _pb_wpcli() { docker run --rm --network "$_net" -v "${_dir}/html:/var/www/html" --env-file "${_dir}/.env" wordpress:cli "$@"; } + # "wp" is spelled out explicitly rather than relying on the wordpress:cli + # entrypoint's own "wp help $1 && set -- wp $@" auto-detection — that + # probe itself runs through wp-cli's bootstrap, so anything that breaks + # the bootstrap (a bad wp-config.php, a missing bind mount) makes the + # probe fail *silently* and falls through to exec-ing the raw + # subcommand as if it were a binary ("core: not found") instead of + # surfacing the real error. + _pb_wpcli() { docker run --rm --network "$_net" -v "${_dir}/html:/var/www/html" -v "${_dir}/extra-config.php:/usr/local/etc/pressbooks/extra-config.php:ro" --env-file "${_dir}/.env" wordpress:cli wp "$@"; } local _plugin_url _book_url _aldine_url _publisher_url _plugin_url="$(_pressbooks_latest_zip_url pressbooks)" @@ -608,7 +615,17 @@ PBCOMPOSE # Loads the file written above — see the comment there for why the PHP # itself doesn't live directly in this env var. This line has no "$" in # it at all, so it can't run into Compose's .env interpolation. - local _CONFIG_EXTRA="require '/usr/local/etc/pressbooks/extra-config.php';" + # + # Guarded with file_exists rather than a bare require: this same + # wp-config.php (baked once, on the persistent html/ volume) is also + # loaded by every ephemeral "docker run wordpress:cli ..." wp-cli + # invocation below, which only mounts html/ itself — a bare require + # here would fatal in any such container unless it also mounts + # extra-config.php at this exact path. Confirmed live: that fatal was + # swallowing wp-cli's own internal "is this a valid subcommand" probe, + # so "core install" ran as a literal, nonexistent "core" binary instead + # of being handed to wp-cli at all ("core: not found"). + local _CONFIG_EXTRA="if (file_exists('/usr/local/etc/pressbooks/extra-config.php')) { require '/usr/local/etc/pressbooks/extra-config.php'; }" backup_if_exists .env cat > .env << PBENV @@ -656,7 +673,8 @@ PBENV sleep 1; _tries=$((_tries + 1)) done - _wpcli() { docker run --rm --network "$WP_NET" -v "$DIR/html:/var/www/html" --env-file "$DIR/.env" wordpress:cli "$@"; } + # "wp" spelled out explicitly — see _pb_wpcli's comment above for why. + _wpcli() { docker run --rm --network "$WP_NET" -v "$DIR/html:/var/www/html" -v "$DIR/extra-config.php:/usr/local/etc/pressbooks/extra-config.php:ro" --env-file "$DIR/.env" wordpress:cli wp "$@"; } log_info "Running wp-cli core install..." if ! _wpcli core install \ @@ -667,7 +685,9 @@ PBENV --admin_email="$PB_ADMIN_EMAIL" \ --skip-email; then log_error "wp-cli core install failed — WordPress may not have been ready yet. Retry manually:" - log_error " docker run --rm --network $WP_NET -v $DIR/html:/var/www/html --env-file $DIR/.env wordpress:cli core install ..." + log_error " docker run --rm --network $WP_NET -v $DIR/html:/var/www/html \\" + log_error " -v $DIR/extra-config.php:/usr/local/etc/pressbooks/extra-config.php:ro \\" + log_error " --env-file $DIR/.env wordpress:cli wp core install ..." return 1 fi @@ -771,6 +791,7 @@ refreshes the Pressbooks plugin/themes to their latest release. ## wp-cli \`\`\`bash docker run --rm --network $WP_NET -v $DIR/html:/var/www/html \\ + -v $DIR/extra-config.php:/usr/local/etc/pressbooks/extra-config.php:ro \\ --env-file $DIR/.env wordpress:cli wp \`\`\`