Skip to content

Add CapRover PR preview deployment - #136

Open
asyncawaitpromise wants to merge 1 commit into
mainfrom
dev/caprover-preview
Open

Add CapRover PR preview deployment#136
asyncawaitpromise wants to merge 1 commit into
mainfrom
dev/caprover-preview

Conversation

@asyncawaitpromise

Copy link
Copy Markdown
Member

Summary

Adds CapRover-based PR preview deployments, replacing the approach in #104/#106.

  • Self-contained multi-stage Dockerfile — builds the Next.js static export inside the image, rather than expecting a host-built out/ (which is gitignored, so caprover deploy/tarball builds against PR Preview feature for CapRover #104's Dockerfile would never have worked).
  • captain-definition + scripts/deploy-tar.sh / scripts/scaffold.sh — lets anyone with CapRover CLI access iterate locally (deploy in ~90s) with no CI or container registry needed.
  • .github/workflows/preview.yml — per-PR ephemeral CapRover app, builds+pushes to GHCR, comments the preview URL on the PR, tears down on close.
  • .github/workflows/cleanup-previews.yml — cron sweep that expires inactive previews after 6h.
  • nginx.conf — fixes a routing gap where extensionless static-export routes (e.g. /eventsevents.html) 403 under default nginx config.

Verified end-to-end against a live CapRover server: caprover deploy built and served the site correctly (home, static routes, dynamic event detail pages, 404s, static assets all returned correct status codes).

Why this instead of #104

#104's Dockerfile assumed a pre-built out/ in the build context, which is gitignored — so it only worked via the CI path (build on runner → push image → CapRover pulls it), with no way to test locally without a full CI round-trip. This PR's Dockerfile builds from source inside Docker, so the exact same Dockerfile works for instant local iteration (caprover deploy) and for CI.

Secrets required (repo Settings → Secrets and variables → Actions)

Secret Used by
CAPROVER_URL preview.yml, cleanup-previews.yml
CAPROVER_PASSWORD preview.yml, cleanup-previews.yml
CAPROVER_APP_DOMAIN preview.yml (constructs the preview URL)

NEXT_PUBLIC_SUPABASE_URL/NEXT_PUBLIC_SUPABASE_ANON_KEY are already present and public (baked into the Dockerfile as fallback defaults too, matching check.yml).

Test plan

  • docker build succeeds locally
  • Container serves home page, extensionless routes, dynamic event pages, 404s, static assets (_next/static) — all verified with curl
  • caprover deploy (tarball) to a live CapRover server succeeds and the deployed app serves the same routes correctly over HTTPS
  • Add the three secrets above so preview.yml/cleanup-previews.yml can run in CI
  • Open a test PR against this repo to confirm the GitHub Actions preview flow end-to-end

Self-contained multi-stage Dockerfile (builds the static export inside
the image itself, rather than expecting a host-built out/ dir) so the
same Dockerfile works for both caprover deploy/tarball testing and CI.
Includes scripts/deploy-tar.sh and scripts/scaffold.sh for fast local
iteration against a CapRover server with no CI/registry round-trip,
plus GitHub Actions workflows for per-PR preview deploys (PR comment
with the preview URL) and cron-based cleanup of expired previews.

Verified end-to-end against a live CapRover instance: caprover deploy
built and served the site correctly (home, static routes, dynamic
event pages, 404s, static assets).

Supersedes #104 and #106.
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