Skip to Content
InfraOverview

CazVid Infra — Only‑Main + Fargate Previews

Goals

  • Only‑main trunk: main is always releasable.
  • Build once, promote many: PR → preview → prod uses the same image SHA.
  • Parallel QA: per‑PR preview URLs (web & API), no staging trains.
  • Low‑ops: single ECS cluster, ephemeral Fargate services, auto‑cleanup.
  • Monorepo: unified CI, shared contracts.

Read next → Delivery (CI/CD & Runtime) · Operations (Net/Obs/Cost)


Monorepo Layout

cazvid/ apps/ web/ # Next.js (App Router) api/ # NestJS backend packages/ contracts/ # shared TS types (gradual) config/ # lint, tsconfig, scripts .gitlab-ci.yml turbo.json package.json # workspaces

Transition (no drift)

  • Import histories via git subtree add into apps/web and apps/api.
  • Optional one‑way sync jobs pull latest from old repos during cutover.
  • Flip PRs to monorepo as source of truth after a short proving window.

High‑Level Flow

Dev PR ──▶ CI builds image (web/api) ──▶ push to ECR ├─▶ Create ECS TaskDef + TG + Service (Fargate) │ └─▶ ALB host rule: web-pr-###.qa.domain └─▶ Post preview URL to MR QA validates on preview ──▶ Merge to main ──▶ CI updates prod service to same image ──▶ Tag release TTL job/merge/close ──▶ Destroy preview (rule + TG + service)

Key components

  • ALB: single public ALB + wildcard DNS *.qa.domain → host‑header rules → Target Groups.
  • ECS: one cluster; Fargate launch type for previews (and optionally prod).
  • Logs: CloudWatch log groups per app (/ecs/cazvid-web, /ecs/cazvid-api).

Environments

  • Production: ECS services web-prod, api-prod.
  • Previews (per PR): web-pr-<iid>, api-pr-<iid> + ALB host rules:
    • https://web-pr-<iid>.qa.domain
    • https://api-pr-<iid>.qa.domain
  • Staging (optional): fixed service from main with feature flags.

Day‑0 → Day‑2 Rollout

Day 0

  • Create monorepo & import histories.
  • Add web preview pipeline + wildcard DNS *.qa.domain → ALB.
  • Deploy a sample PR; verify URL.

Day 1

  • Add API preview pipeline; set FE API_BASE_URL to matched API preview.
  • Add TTL cleanup schedule.

Day 2

  • Flip team PRs to monorepo; old repos read‑only.
  • Adopt Conventional Commits & tag on main merges.
  • (Optional) Move shared types into packages/contracts.

Outcome: Monorepo + only‑main + Fargate previews ⇒ fastest path to “fix → preview URL → QA → ship.”

Last updated on