Skip to content

Add Cloud Run + Terraform deployment (alongside Firebase)#90

Closed
pstaylor-patrick wants to merge 1 commit into
mainfrom
infra/cloud-run-terraform
Closed

Add Cloud Run + Terraform deployment (alongside Firebase)#90
pstaylor-patrick wants to merge 1 commit into
mainfrom
infra/cloud-run-terraform

Conversation

@pstaylor-patrick

Copy link
Copy Markdown
Collaborator

Summary

Migrates region-pages off Firebase App Hosting onto vanilla GCP Cloud Run, defined as Terraform infrastructure-as-code in this repo. This is the first step toward eventually folding region-pages into the F3 Nation monorepo.

The new stack is already deployed and verified in the region-pages GCP project and runs alongside the existing Firebase App Hosting backend. No production DNS change is maderegions.f3nation.com continues to serve via Firebase until cutover.

  • Live (non-prod) Cloud Run URL: https://f3-region-pages-mx5ollfbiq-uc.a.run.app

Changes

  • next.config.tsoutput: 'standalone' for a slim container image.
  • Dockerfile / .dockerignore — multi-stage build (Node 20, pnpm 9). POSTGRES_URL + F3_DATA_WAREHOUSE_URL are mounted as BuildKit secrets so generateStaticParams can prerender ~530 region pages at build time (never baked into a layer).
  • infra/terraform/cloud-run/ — Artifact Registry repo, runtime service account (+roles/cloudsql.client for the warehouse connector), the 9 runtime secrets, the public Cloud Run service (port 8080, scale 0→4), and an optional external HTTPS load balancer (static IP + serverless NEG + Google-managed cert + HTTP→HTTPS redirect) for the custom domain. Remote state in gs://region-pages-tfstate.

Custom domain / DNS

The custom domain is fronted by an external HTTPS load balancer rather than a Cloud Run domain mapping — this avoids Search Console / Webmaster domain verification. The managed cert validates automatically once DNS resolves to the LB IP, so the hand-off is a single A record:

A   regions.f3nation.com   ->   8.233.224.179   (TTL 300)

To be coordinated with the F3 Nation dev team (Tackle), who own the DNS zone.

Migration debt (the "messy middle")

  • The 9 runtime secrets are recreated as Terraform-managed *-tf Secret Manager secrets, coexisting with the Firebase-managed originals. Once Cloud Run is the production path and Firebase is decommissioned, delete the un-suffixed originals.
  • Cron ingest (Upstash QStash → /api/ingest) is unchanged.

Verification

  • terraform validate clean; full stack applied successfully.
  • Cloud Run URL: / → 200, /abilene → 200 (warehouse-backed SSG), POST /api/ingest → 401 without CRON_SECRET, unknown slug → 404.

🤖 Generated with Claude Code

Migrate region-pages off Firebase App Hosting onto vanilla GCP Cloud Run,
defined as Terraform IaC in the repo. Runs alongside the existing Firebase
App Hosting backend during the migration; makes no DNS change.

- next.config.ts: emit standalone output for the container
- Dockerfile/.dockerignore: multi-stage build; build-time DB secrets via
  BuildKit so generateStaticParams can prerender region pages
- infra/terraform/cloud-run: Artifact Registry, runtime SA (+cloudsql.client),
  9 secret-backed env vars (recreated as -tf secrets), public Cloud Run service,
  and an optional external HTTPS load balancer (serverless NEG + managed cert)
  for the custom domain — avoids Search Console domain verification

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pstaylor-patrick

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by F3-Nation/f3-nation#302, which brings region-pages into the monorepo and already carries this Cloud Run + Terraform infra under apps/region-pages/infra/terraform/cloud-run/. The standalone-repo deploy work is redundant once region-pages consolidates into the monorepo. Reopen if we decide to keep the standalone repo deploying independently until the DNS cutover.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant