Docker
Development and production images, and the migrator inside them.
Create apps/web/.env.local first. Start the development image with:
pnpm docker:devIt runs docker-compose.yml by name (Starter v0.27.0 or newer), so a compose.yaml from deploy never takes its place. Build a production image and run it with:
pnpm docker:build
pnpm docker:startThe image runs the Next.js standalone output as an unprivileged user.
Ensure the configured database and provider hosts are reachable from the container.
A frontend and its API
A project with a separate API has two production images:
| Image | Runs |
|---|---|
Dockerfile | The frontend, on node:22-alpine: node server.mjs serves the static build on port 3000 and forwards the contract's GET /api/health, /api/ready, and /api/session, and the endpoints of the modules you chose, to API_URL, the API's address. With Better Auth, it also answers /api/auth/* itself. |
apps/api/Dockerfile | The API, on port 3001: Node with Hono, or python:3.12-slim with uv with FastAPI, which installs only the dependency groups of your modules. Both include the migrator. |
The frontend server forwards no other path, and a module's endpoints only when the project has that module, such as the billing routes and Stripe's webhook with --payments stripe. When you add an endpoint to the contract, add it to apiRoutes in apps/web/server.mjs, or set VITE_API_URL so the browser calls the API directly.
Vite compiles the VITE_* variables into the build, so pass them as build arguments. API_URL is read when the server starts:
docker build \
--build-arg VITE_SUPABASE_URL=https://<project>.supabase.co \
--build-arg VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_... \
-t my-app-web .
docker build -f apps/api/Dockerfile -t my-app-api .pnpm docker:dev builds and runs both with docker-compose.yml: the frontend with apps/web/.env.local and API_URL set to the API service, and the API with apps/api/.env.local and TRUSTED_PROXY_HOPS=1, since only the frontend's server reaches it. The frontend's VITE_* values are build arguments, since .env files stay out of the image: Compose reads them from the shell or a .env file next to docker-compose.yml, or run docker compose -f docker-compose.yml --env-file apps/web/.env.local up --build. Projects from Starter v0.24.1 and earlier pass none; add them under the frontend's build.args.
Without a website
A project without a website has one image, the API's, apps/api/Dockerfile, and no docker:build or docker:start. Create apps/api/.env.local first: pnpm docker:dev builds the API's image and runs it with docker-compose.yml, publishing port 3001. Build and run the production image from the repository root with:
docker build -f apps/api/Dockerfile -t my-app-api .
docker run --rm -p 3001:3001 --env-file apps/api/.env.local my-app-apiThe image runs the API as an unprivileged user, and contains the migrator.
Production with Docker Compose
docker-compose.yml is for development. For a server of your own, pnpm clubedge deploy with --deploy docker (CLI 0.42.0 or newer) writes a compose.yaml that runs the app's image behind Caddy, which serves your domain over HTTPS, and .github/workflows/release-images.yml, which publishes the images to GitHub's container registry with each release. With a frontend and its API, it runs both, the API on the Compose network behind the frontend. Without a website, it runs the API's image, which Caddy serves (CLI 0.44.0 or newer).
Compose prefers compose.yaml to docker-compose.yml, so pnpm docker:dev names its file: docker compose -f docker-compose.yml up --build (Starter v0.27.0 or newer). In older projects, run that command instead of pnpm docker:dev once compose.yaml exists.
The migrator
The image also contains the production migrator, which applies every package's migrations with only DATABASE_URL:
docker run --rm --env DATABASE_URL="postgresql://..." <image> node /app/migrate.mjsRun it before a new version starts serving; it skips migrations that are already applied. Deploy shows how each platform runs it.
With a separate API, the migrator is in the API's image, at the same path, with Hono and with FastAPI: run node /app/migrate.mjs from the API image, with a website or without one. The frontend image has none.
How is this guide?