Docker Compose
Prepare a server of your own with Docker Compose behind Caddy, with the images published on each release.
In a project with --deploy docker (the default), pnpm clubedge deploy prepares the project for a server of your own (CLI 0.42.0 or newer). It creates nothing anywhere else: it writes the files, then prints what to run on the server.
pnpm clubedge deploy # writes compose.yaml, the Caddyfile, and the release workflow
pnpm clubedge deploy --dry-run # what it would writeWhat it writes
Three files to commit:
compose.yamlruns each app's image behind Caddy, the only service that publishes ports (80, and 443 over TCP and UDP). Caddy servesDOMAINover HTTPS, with certificates it obtains and renews by itself.Caddyfile: every request forDOMAINgoes to the public app..github/workflows/release-images.yml: each published GitHub release builds every app's image and pushes it to GitHub's container registry (below).
| Project | Services |
|---|---|
| Next.js or TanStack Start | web, from the root Dockerfile |
| A frontend and its API | web, the frontend, which Caddy serves, and api, which stays on the Compose network behind the frontend's /api proxy |
| Without a website (CLI 0.44.0 or newer) | api, from apps/api/Dockerfile, which Caddy serves |
Each service has an image, ${IMAGE_PREFIX:-<project>}-<service>:${TAG:-latest}, and its build: docker compose up -d pulls the released images when IMAGE_PREFIX points at GitHub's registry, and --build builds them on the server. The public URL defaults to https://$DOMAIN: Next.js also gets it as a build argument, and Better Auth as BETTER_AUTH_URL, on a React + Vite frontend or in an API without a website. A mobile app or a native app runs no server, so it has no service.
Release images
The workflow builds each app's image for linux/amd64 and linux/arm64 and pushes it to ghcr.io/<owner>/<repository>-<service>, tagged with its version (1.2.3), 1.2, and latest. Run by hand on the default branch, it pushes edge. It never runs for tag pushes, so a deleted tag leaves no images behind, and it needs no secret: it uses the workflow's own token.
The values an image compiles in come from repository variables: NEXT_PUBLIC_APP_URL for Next.js, the VITE_* values for a React + Vite frontend. Set the ones you use before the first release. The packages start private.
On the server
Point the domain's DNS A and AAAA records at the server, and publish a release. Then on the server, next to compose.yaml, the Caddyfile, and .env.production (the whole project, to build there):
# .env.production: DOMAIN=example.com, the app's variables, and, to run the released images,
# IMAGE_PREFIX=ghcr.io/<owner>/<repository> (TAG=1.2.3 pins a release; latest otherwise)
docker login ghcr.io # while the packages are private: a token with read:packages
docker compose --env-file .env.production run --rm web node /app/migrate.mjs # api when the project has one
docker compose --env-file .env.production up -d # --build builds the images on the serverdeploy prints these steps, with your repository's IMAGE_PREFIX when origin is on GitHub. The variables of .env.example, and of apps/api/.env.example for a frontend and its API, go in .env.production; without a website, those of apps/api/.env.example. docker compose logs --follow shows the logs.
To update, publish a release. Then on the server, run docker compose --env-file .env.production pull (or set TAG to the new version), the migrations, and up -d again.
Run it again
Running deploy again writes the files that are missing and never overwrites one: it keeps a Caddyfile or workflow you changed, and says so, and stops when compose.yaml differs from the one it writes. Move yours away to get the new one.
Compose prefers compose.yaml to the Starter's docker-compose.yml, so run the local one by name: docker compose -f docker-compose.yml up --build. pnpm docker:dev does this from Starter v0.27.0.
Client addresses
Caddy is the one proxy of your own in front of the app, and it sets X-Forwarded-For to the client's address, so compose.yaml gives the public app TRUSTED_PROXY_HOPS=1: the API itself, without a website. A frontend's API, reached only through the frontend's server, gets TRUSTED_PROXY_HOPS=1 too. CLIENT_IP_HEADER or TRUSTED_PROXY_HOPS in .env.production replaces the default, for another proxy in front. See Client addresses.
Before CLI 0.42.0
deploy wrote a compose.yaml only for a frontend and its API, with the frontend's port published and no HTTPS, and refused full-stack projects that deploy with docker. The Starter's deploy workflow published one image instead; see Any container host.
How is this guide?