Two separate leaks were causing the same cosmetic-but-annoying warning to
survive every previous fix attempt:
1. Compose's own `secrets:` block reads the referenced file's *content*
as part of its config model, and applies the same interpolation
warning to it — even with DB_PASSWORD fully removed from every ${VAR}
and --env-file path. Switched from Compose's native `secrets:` to plain
bind mounts at the same /run/secrets/* paths: a bind mount only ever
touches the file's path, never its content, so it's immune. (Verified
this precisely with an isolated repro before rolling it out — the two
mechanisms behave differently even though they look equivalent.)
2. caddy's `env_file: .env.staging` (a leftover from the since-removed
basic-auth setup) loaded the *raw*, unfiltered env file directly,
bypassing deploy.sh/backup.sh/restore.sh's filtered-copy mechanism
entirely. Caddy only ever needed SITE_DOMAIN; switched to passing that
one value directly instead of the whole file.
Also fixed Caddyfile.staging: the site address had no explicit scheme, so
Caddy's automatic-HTTPS logic still applied to a private IP (registering
its own internal CA and redirecting HTTP->HTTPS) — not the "plain HTTP
only" behavior I'd assumed and told the user earlier. Prefixed with
`http://` to genuinely disable automatic HTTPS for this LAN-only box.
Verified end-to-end: fresh deploy with dollar-sign DB passwords produces
zero warnings, serves HTTP 200 on plain http:// with no redirect, and the
DB connection genuinely authenticates.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
122 lines
4.8 KiB
YAML
122 lines
4.8 KiB
YAML
# wordpress and cron are the same image and MUST share the same
|
|
# environment: the official image's wp-config.php reads getenv() live, at
|
|
# PHP runtime, in whichever container is executing — it does not bake
|
|
# values into the file once. If cron's env drifts from wordpress's (e.g.
|
|
# WORDPRESS_CONFIG_EXTRA missing), cron silently loses WP_REDIS_HOST,
|
|
# DISABLE_WP_CRON, etc. The anchor below is what prevents that drift.
|
|
# DB_PASSWORD/DB_ROOT_PASSWORD are deliberately NOT passed via ${VAR} here.
|
|
# Docker Compose's own interpolation mangles any value containing a `$`
|
|
# followed by a letter (confirmed with a bcrypt hash earlier, and again with
|
|
# a plain generated password: "$BRjTx3tlmSpz" got silently blanked out,
|
|
# breaking the DB connection). The official mariadb/wordpress images both
|
|
# support a `_FILE` convention specifically for this — point at a file path
|
|
# (never risky) and the container reads the raw contents itself, bypassing
|
|
# Compose's interpolation entirely. deploy.sh writes these files fresh from
|
|
# .env.<environment> before every `up`.
|
|
#
|
|
# These are plain bind mounts, NOT Compose's native `secrets:` block —
|
|
# Compose's `secrets:` construct reads the referenced file's *content* as
|
|
# part of its own config model and applies the same interpolation warning
|
|
# to it (confirmed: it still warned on "$BRjTx3tlmSpz" even after that
|
|
# value was fully removed from every ${VAR} and --env-file path). A plain
|
|
# bind mount never touches the file's content, only its path, so it's
|
|
# immune to this entirely.
|
|
#
|
|
# The supplier/payment keys below are still passed the old ${VAR} way and
|
|
# remain exposed to the same class of bug — nothing consumes them yet
|
|
# (bookstore-core is still a stub), so when that code is written it should
|
|
# read `_FILE` variants the same way.
|
|
x-bookstore-env: &bookstore-env
|
|
WORDPRESS_DB_HOST: db
|
|
WORDPRESS_DB_NAME: ${DB_NAME}
|
|
WORDPRESS_DB_USER: ${DB_USER}
|
|
WORDPRESS_DB_PASSWORD_FILE: /run/secrets/db_password
|
|
WORDPRESS_TABLE_PREFIX: ${WP_TABLE_PREFIX:-wp_}
|
|
MAIL_CATCHER_HOST: mailhog
|
|
MAIL_CATCHER_PORT: 1025
|
|
WORDPRESS_CONFIG_EXTRA: |
|
|
define('DISABLE_WP_CRON', true);
|
|
define('WP_REDIS_HOST', 'redis');
|
|
define('WP_MEMORY_LIMIT', '256M');
|
|
# Passed through for the bookstore-core plugin's supplier adapters /
|
|
# payment integration (design doc §04/§05) — not read by WordPress core.
|
|
ACTIVE_SUPPLIER_ADAPTERS: ${ACTIVE_SUPPLIER_ADAPTERS:-gutenberg_test}
|
|
BOOKSRUN_API_KEY: ${BOOKSRUN_API_KEY:-}
|
|
INGRAM_API_KEY: ${INGRAM_API_KEY:-}
|
|
INGRAM_ACCOUNT_ID: ${INGRAM_ACCOUNT_ID:-}
|
|
HELCIM_API_TOKEN: ${HELCIM_API_TOKEN:-}
|
|
HELCIM_ACCOUNT_ID: ${HELCIM_ACCOUNT_ID:-}
|
|
MAILERLITE_API_KEY: ${MAILERLITE_API_KEY:-}
|
|
|
|
services:
|
|
db:
|
|
image: mariadb:11
|
|
restart: unless-stopped
|
|
environment:
|
|
MARIADB_DATABASE: ${DB_NAME}
|
|
MARIADB_USER: ${DB_USER}
|
|
MARIADB_PASSWORD_FILE: /run/secrets/db_password
|
|
MARIADB_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
|
|
volumes:
|
|
- db_data:/var/lib/mysql
|
|
- ./secrets/${ENVIRONMENT}/db_password:/run/secrets/db_password:ro
|
|
- ./secrets/${ENVIRONMENT}/db_root_password:/run/secrets/db_root_password:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "mariadb-admin ping -h 127.0.0.1 -u$$MARIADB_USER -p\"$$(cat /run/secrets/db_password)\" --silent"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
restart: unless-stopped
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
|
|
wordpress:
|
|
build:
|
|
context: ./docker/php
|
|
restart: unless-stopped
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
environment: *bookstore-env
|
|
volumes:
|
|
- wp_core:/var/www/html
|
|
- wp_uploads:/var/www/html/wp-content/uploads
|
|
- wp_themes:/var/www/html/wp-content/themes
|
|
- ./wp-content/plugins/bookstore-core:/var/www/html/wp-content/plugins/bookstore-core
|
|
- ./wp-content/mu-plugins:/var/www/html/wp-content/mu-plugins
|
|
- ./secrets/${ENVIRONMENT}/db_password:/run/secrets/db_password:ro
|
|
|
|
cron:
|
|
build:
|
|
context: ./docker/php
|
|
restart: unless-stopped
|
|
depends_on:
|
|
- wordpress
|
|
entrypoint: ["/bin/sh", "/usr/local/bin/cron-entrypoint.sh"]
|
|
environment: *bookstore-env
|
|
volumes:
|
|
- wp_core:/var/www/html
|
|
- wp_uploads:/var/www/html/wp-content/uploads
|
|
- wp_themes:/var/www/html/wp-content/themes
|
|
- ./wp-content/plugins/bookstore-core:/var/www/html/wp-content/plugins/bookstore-core
|
|
- ./wp-content/mu-plugins:/var/www/html/wp-content/mu-plugins
|
|
- ./docker/cron/entrypoint.sh:/usr/local/bin/cron-entrypoint.sh:ro
|
|
- ./secrets/${ENVIRONMENT}/db_password:/run/secrets/db_password:ro
|
|
|
|
volumes:
|
|
db_data:
|
|
redis_data:
|
|
wp_core:
|
|
wp_uploads:
|
|
wp_themes:
|