# Any container host (/docs/starter/deploy/container-host)

The default `docker` option deploys the [production image](../docker.mdx) 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-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:

```sh
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.0
```

## Release [#release]

Before each release, run the [migrator](../docker.mdx#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](./index.mdx#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 [#a-frontend-and-its-api]

With a [separate API](../../cli/frontend-and-api.mdx), build and push [both images](../docker.mdx#a-frontend-and-its-api): the root `Dockerfile`, with your auth provider's `VITE_*` values as build arguments, and `apps/api/Dockerfile`. Then, for each release:

1. Run the migrator from the new API image, `node /app/migrate.mjs`, as a one-off task with `DATABASE_URL` set.
2. Roll out the API on port 3001, with its health check on `/api/health`. It needs no public address.
3. Roll out the frontend on port 3000, with `API_URL` set 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`](../../cli/deploy/docker.mdx) writes a `compose.yaml` that does this with Docker Compose.

## Without a website [#without-a-website]

A project [without a website](../../cli/without-a-website.mdx) (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](../before-deploying.mdx#client-addresses) setting.

## A server of your own [#a-server-of-your-own]

On a server you run, [`pnpm clubedge deploy`](../../cli/deploy/docker.mdx) (CLI 0.42.0 or newer) sets this up with Docker Compose. It writes three files, and never overwrites one you changed:

- `compose.yaml` runs the app's image behind [Caddy](https://caddyserver.com), 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.
- `Caddyfile` is Caddy's configuration.
- `.github/workflows/release-images.yml` publishes the images ([below](#release-images)).

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 [#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.
