Any container host
Run the production image on any host that runs containers, or on your own server with Docker Compose behind Caddy, with the migrator before each rollout.
The default docker option deploys the production image to any host or orchestrator that runs containers: Kubernetes, Amazon ECS, Google Cloud Run, Azure Container Apps, a VM with Docker, and others.
Build and push the image
Build it with pnpm docker:build or in CI, then push it to a registry. With Next.js, pass the public URL as a build argument, since Next.js compiles it into the build:
docker build --build-arg NEXT_PUBLIC_APP_URL=https://app.example.com -t registry.example.com/my-app:1.0.0 .
docker push registry.example.com/my-app:1.0.0Release
Before each release, run the migrator from the new image as a one-off task (a Kubernetes Job, an ECS task, or docker run), with DATABASE_URL set to the production database. It skips migrations that are already applied, and a failure stops the release. Then roll out the new containers with the production variables.
Point the platform's health check at /api/health, and readiness probes or load balancers at /api/ready. The app listens on port 3000.
A frontend and its API
With a separate API, build and push both images: the root Dockerfile, with your auth provider's VITE_* values as build arguments, and apps/api/Dockerfile. Then, for each release:
- Run the migrator from the new API image,
node /app/migrate.mjs, as a one-off task withDATABASE_URLset. - Roll out the API on port 3001, with its health check on
/api/health. It needs no public address. - Roll out the frontend on port 3000, with
API_URLset to the API's address on your private network and its health check on/.
The modules' variables go to the API. Stripe's webhooks and Inngest's calls reach the API through the frontend's public URL.
pnpm clubedge deploy writes a compose.yaml that does this with Docker Compose.
Without a website
A project without a website (Starter v0.28.0 or newer) has one image, the API's. Build and push apps/api/Dockerfile, then for each release run its migrator, node /app/migrate.mjs, as a one-off task with DATABASE_URL set, and roll it out on port 3001, with its health check on /api/health. Clients reach the API directly, so give it a public address, and set its host's client address setting.
A server of your own
On a server you run, pnpm clubedge deploy (CLI 0.42.0 or newer) sets this up with Docker Compose. It writes three files, and never overwrites one you changed:
compose.yamlruns the app's image behind Caddy, the only service that publishes ports: Caddy serves your domain over HTTPS, with certificates it obtains and renews by itself. With a frontend and its API, it runs both images, and the API stays on the Compose network behind the frontend. Without a website, it runs the API's image, which Caddy serves.Caddyfileis Caddy's configuration..github/workflows/release-images.ymlpublishes the images (below).
It then prints the remaining steps: DOMAIN and the production variables in .env.production, the domain's DNS records, a release, the migrator, and docker compose --env-file .env.production up -d. Behind Caddy, the app reads the client's address from X-Forwarded-For with TRUSTED_PROXY_HOPS=1.
Release images
.github/workflows/release-images.yml builds every app's image for linux/amd64 and linux/arm64 on each published GitHub release, and publishes it to the repository's GitHub Container Registry as ghcr.io/<owner>/<repository>-<service>, tagged with the version (1.2.3), <major>.<minor> (1.2), and latest. Run by hand on the default branch, it publishes edge. It uses the workflow's own token, so no secret is needed, and the packages start private.
The values an image compiles in come from repository variables: NEXT_PUBLIC_APP_URL with Next.js, and the VITE_* values of a React + Vite frontend. Run the migrator from the new image before rolling it out.
Projects from Starter v0.26.1 and earlier have a Deploy job instead, in .github/workflows/deploy.yml: run by hand, it publishes one image, the root Dockerfile's, as ghcr.io/<owner>/<repository>, tagged with the commit and latest. From Starter v0.27.0, a Docker project has no deploy workflow, and upgrade deletes it if you never changed it.
How is this guide?