ADR-0177 — Staging runs on Cloud Run from the production images
Status: Accepted · Date: 2026-11-22 · Track: 013 GTM consolidation
Context
The only deploy path was a single host (operator-one: systemd, Caddy, local
PostgreSQL), reached over SSH from a workflow that built artefacts and then
restarted a unit without copying them. The team needs an environment for
functional validation, visual refinement, cross-platform checks, usability
tests and QA that every device can reach, that is rebuilt from main without a
person, and that cannot be confused with production.
Decision
Staging is a GCP project defined in infra/gcp (Terraform; bootstrap.sh for
a gcloud-only start):
- Cloud Run services
cardsite-api,cardsite-web,cardsite-marketing,cardsite-toolkit, each from the same Dockerfile production uses. - Cloud SQL for PostgreSQL 16. Migrations run as the Cloud Run job
cardsite-migrate(/migrate up) before a new API revision takes traffic; the server never migrates (ADR-0167). Demo data is thecardsite-seedjob, run on request. - Secrets in Secret Manager; uploads on a Cloud Storage bucket mounted into the API. Redis is off by default; the API degrades without it.
.github/workflows/deploy-staging.ymldeploys every push tomain, authenticating with Workload Identity Federation (no key files), then runsscripts/staging/smoke.shagainst the live URLs.
The self-hosted production path in deploy/ and docs/DEPLOYMENT.md is
unchanged.
Consequences
- Every merged change is on staging minutes later at a stable URL for web, Apple builds (the Staging configuration), the marketing site and the toolkit.
- A bad revision is rolled back by moving traffic to the previous one; a bad migration is not, which is why migrations stay forward-only and reviewed.
- Staging costs money while it exists; the guide states the estimate and the teardown.
Alternatives considered
- A second systemd host — rejected: per-person access, no revisions, no rollback by traffic.
- GKE — rejected: a cluster to run for four stateless services.
Source: docs/decisions/0177-staging-runs-on-cloud-run-from-the-production-images.md