Files
redefined-designs/docker-compose.qa.yml
T
bermudalamb 0710cccac1 fix(qa): give the container the environment variables it now requires (#107)
QA refuses to start: "UPLOADS_DIR is required and is not set."

#64 made UPLOADS_DIR always required, on the reasoning that its fallback of /app/uploads is correct inside the container and wrong everywhere else, so nothing should inherit it silently. That reasoning stands — but docker-compose.qa.yml had never set it either. QA was relying on exactly the fallback that change set out to stop people relying on, so the first deploy after it merged is the first one to fail.

That is an incomplete check, and one that looked confident. #64 verified both CI workflows set every always-required variable and said so. CI is not what deploys. The compose file, which is, was never opened.

ADMIN_GATE_SECRET was missing for a different reason, and the container reported it unset even after it was added to the Portainer stack. That is not a mistake, it is how compose works: stack variables are substituted into this file as ${VAR}, not handed to the container. A service receives exactly what its environment block lists. #87 already wrote that down; this is the first time it has bitten.

The two get different treatment for a reason. UPLOADS_DIR is hardcoded because it is not a secret and because it has to match the right-hand side of the volume mapping — splitting one value across two places in the same file is how they drift apart. ADMIN_GATE_SECRET is interpolated from the stack so the secret itself never enters the repository, and the header comment now lists it among the required stack variables.

Verified by feeding the environment docker compose config actually renders into validateEnv, the same function that was rejecting it: zero errors and zero warnings, the absence of warnings confirming the admin gate is now configured rather than merely quiet.

Production runs from a stack outside this repository with the same history and will refuse to boot on its next rebuild unless UPLOADS_DIR is set there first. This commit does not fix that.

Closes #107
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 17:24:55 -05:00

161 lines
7.6 KiB
YAML

# QA stack — a disposable copy of the app for reviewing merged-but-undeployed
# changes online. See issue #25.
#
# Deployed as its own Portainer stack, separate from production. Every value
# that could collide with production has been changed: container names, host
# port, volume paths, database name, and image tag. Do not copy a path or port
# back from the production stack — a shared Postgres data directory would mean
# QA writing into production's database files.
#
# Name the Portainer stack `redefined-designs-qa`, NOT `redefined-designs`.
# The stack name becomes the compose project name. Reusing production's name
# would make compose treat this as the same project and reconcile the two
# against each other — it would happily remove the production containers
# because they are not declared in this file.
#
# DEPLOY THIS AS A GIT REPOSITORY STACK, not from the web editor.
#
# Repository: https://gitea.bermudalamb.synology.me/bermudalamb/redefined-designs
# Reference: refs/heads/main
# Compose path: docker-compose.qa.yml
#
# The repository is public, so no credentials are needed. Portainer then does
# the whole cycle from one button: it pulls the repo, builds the image from the
# Dockerfile below, and recreates the containers. Nothing is built by hand on
# the NAS, and no image has to be pushed anywhere first.
#
# `pull_policy: build` matters. Without it the stack reuses whatever is already
# tagged redefined-designs:qa, which is how a redeploy can appear to succeed
# while still running old code. Leave any Portainer option that re-pulls images
# turned OFF — there is no registry to pull this image from.
#
# Required stack environment variables:
# QA_DB_PASSWORD — deliberately not named DB_PASSWORD, so pasting the
# production stack's variables here does nothing silently.
# PUBLIC_URL — the QA hostname, e.g.
# https://qa-redefined-designs.bermudalamb.synology.me
# QA_SMTP_USER — Brevo SMTP login. Named QA_ for the same reason as the
# QA_SMTP_PASSWORD database password: pasting production's variables in here
# QA_SMTP_FROM must not silently work.
# ADMIN_GATE_SECRET — the shared secret Nginx Proxy Manager injects as the
# X-Admin-Gate header on the gated location. Both sides must
# hold the same value or the admin API returns 403. See #63.
services:
redefined-designs-qa:
# Built from this repository by Portainer rather than pulled. The context is
# the repo root, which is where the Dockerfile lives — the same Dockerfile
# production uses, so QA and production images differ only in configuration.
build:
context: .
dockerfile: Dockerfile
image: redefined-designs:qa
# Always build; never reuse the existing tag.
pull_policy: build
container_name: redefined-designs-qa-syn
environment:
- TZ=America/Chicago
- PORT=3000
- PGHOST=redefined-designs-qa-db-syn
- PGPORT=5432
- PGUSER=redefined_qa
- PGPASSWORD=${QA_DB_PASSWORD}
- PGDATABASE=redefined_qa
# No PayPal credentials at all. DEMO_MODE lets the full cart and checkout
# flow run without them, so QA can exercise the whole purchase path with
# no way to reach live PayPal. Never set PAYPAL_ENV=live here. To test a
# real PayPal integration change, add sandbox credentials and set
# PAYPAL_ENV=sandbox — never the live ones.
- DEMO_MODE=true
# SMTP *is* configured here, unlike PayPal above, because the four mail
# flows — verification, password reset, favorite-sold alerts and the
# cart-reminder cron — cannot be regression tested without it. See #87.
#
# Host, port and secure are not secrets and are pinned here rather than
# inherited: the mailer's fallbacks are Gmail's (smtp.gmail.com, 465,
# TLS) and Brevo needs 587 with STARTTLS, which is why SMTP_SECURE is
# false. Getting these wrong fails at send time, not at boot.
- SMTP_HOST=smtp-relay.brevo.com
- SMTP_PORT=587
- SMTP_SECURE=false
- SMTP_USER=${QA_SMTP_USER}
- SMTP_PASSWORD=${QA_SMTP_PASSWORD}
- SMTP_FROM=${QA_SMTP_FROM}
# What keeps a QA run from emailing a real customer now that it *can*
# send. Only these recipients are ever delivered to; anything else is
# skipped with a [mail-blocked] warning naming the address.
#
# Hardcoded rather than read from a stack variable, deliberately. This is
# the entire safety property, and it must not depend on somebody
# remembering to set something in Portainer — an unset variable would
# mean unrestricted sending from an environment full of test fixtures.
#
# An entry covers its plus-suffixed variants, so `+whatever` addresses
# work without editing this. Removing the line does NOT disable mail; it
# disables the restriction. Production is a separate stack that does not
# read this file, which is why it is unrestricted and correct to be.
- MAIL_ALLOWLIST=thomlamb@gmail.com
- SITE_CURRENCY=USD
- RESERVATION_MINUTES=15
- PUBLIC_URL=${PUBLIC_URL}
# Required since #64, and previously inherited from the code's fallback —
# which is exactly what that change set out to stop. Hardcoded rather than
# taken from a stack variable because it is not a secret and because it
# has to match the right-hand side of the volume mapping below; splitting
# it across two files is how they drift apart.
- UPLOADS_DIR=/app/uploads
# Interpolated from the stack environment so the secret itself never
# enters the repository. Note that setting it in Portainer alone is not
# enough: stack variables are substituted into this file, not handed to
# the container, so a variable with no line here never reaches the app.
- ADMIN_GATE_SECRET=${ADMIN_GATE_SECRET}
volumes:
# Separate uploads directory. Sharing production's would let a QA run
# write into, and a QA teardown delete, real product images.
- /volume1/configs/redefined-designs-qa/uploads:/app/uploads
ports:
# 32751, not production's 32750.
- 32751:3000
depends_on:
redefined-designs-qa-db-syn:
condition: service_healthy
# Not `unless-stopped`: QA is meant to be up only while a review is
# happening. `unless-stopped` would silently bring it back after every NAS
# reboot and leave it running indefinitely.
restart: "no"
# Docker's default json-file driver has no size cap. POST /api/client-errors
# is unauthenticated, so an unrotated log is a disk-filling vector on its
# own — see the error-boundary design doc's backend section. This does not
# cover production, which is a separate Portainer stack outside this repo;
# the same logging options need to be added there directly.
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
redefined-designs-qa-db-syn:
image: postgres:16
container_name: redefined-designs-qa-db-syn
environment:
- POSTGRES_USER=redefined_qa
- POSTGRES_PASSWORD=${QA_DB_PASSWORD}
- POSTGRES_DB=redefined_qa
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
# Distinct data directory from production's
# /volume1/configs/redefined-designs/postgres. This is the single most
# important difference in this file.
- /volume1/configs/redefined-designs-qa/postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U redefined_qa -d redefined_qa"]
interval: 10s
timeout: 5s
retries: 10
restart: "no"