---
title: Deployment and upgrades
description: >-
  Update the backend and frontend together. Compose runs the images unless pins
  one server release's pair or images built from a checkout. Stop application
  writes and take a matching database and object backup.
---

# Deployment and upgrades

Update the backend and frontend together. Compose runs the `latest` images unless `.env` pins one server release's pair or images built from a checkout.

## Before an update

Stop application writes and take a matching database-and-object backup. The Docker backup records the images the stack runs in `images.env`, since `latest` moves on, and saves images built on this host.

[Storage and backups](https://caelest.is/docs/run-a-server/storage-and-backups.md) explains what each stack needs.

## Docker

In the checkout, stop the applications. Add the `-f` files your stack uses, such as a database or S3 overlay, to every `docker compose` command below. Without them, the applications restart with the default stores.

~~~sh
docker compose stop backend frontend
~~~

Take the backup, then update the checkout so its Compose files run the published images. A checkout from before this change builds from source and names `:local` images, which a pull cannot fetch.

~~~sh
git pull
~~~

If `.env` pins a release, put the target release's image references there; see [Container images](https://caelest.is/docs/run-a-server/docker-reference/container-images.md) for finding them. Then pull the images and start the stack.

~~~sh
docker compose pull backend frontend
docker compose up -d --wait backend frontend
docker compose ps
docker compose logs --tail=100 backend frontend
~~~

Naming `backend frontend` leaves the database, object store and any tunnel running as they are; a recreated Quick Tunnel would get a new URL. `docker compose pull` is the update step. Depending on the Compose version, a plain `docker compose up` can also fetch a newer `latest`, so starting the stack may update it. To restart after a configuration change without updating, add `--pull never`, or pin both images in `.env`.

Do not change database or object-storage adapters as part of a normal version update.

The backend acquires ownership and applies migrations before accepting traffic.

## Docker from a checkout

When `.env` names locally built images, rebuild both from the source version you intend to run, then start the stack as above without `docker compose pull`.

~~~sh
docker build --target backend -t miacx/caelestis-backend:local .
docker build --target frontend -t miacx/caelestis-frontend:local .
~~~

## Helm

Update `my-values.yaml` with the target image pair. Run the migration Job first, then start the backend with the same chart values.

~~~sh
helm upgrade caelestis deploy/helm/caelestis \
  --namespace caelestis -f my-values.yaml \
  --set replicaCount=0,migration.enabled=true \
  --wait --wait-for-jobs --timeout 15m

helm upgrade caelestis deploy/helm/caelestis \
  --namespace caelestis -f my-values.yaml \
  --set replicaCount=1,migration.enabled=false \
  --wait --timeout 10m
~~~

Use the same chart version, namespace, values, storage, and Secrets in both commands. For a published chart, replace the local path with its pinned chart reference.

## Cloudflare

Keep your self-hosted configuration and secrets. Build the target release, apply backend D1 migrations, and deploy the backend before the frontend.

~~~sh
pnpm install --frozen-lockfile
pnpm build
pnpm --dir apps/backend exec wrangler d1 migrations apply DB --remote --config wrangler.self-hosted.toml
pnpm --dir apps/backend exec wrangler deploy --config wrangler.self-hosted.toml
pnpm --dir apps/frontend exec wrangler deploy --config wrangler.self-hosted.toml
~~~

Review release-specific migration instructions before running these commands. A Worker rollback does not restore D1 or R2 data.

## Check the result

Open the dashboard and a known template. Confirm its artwork and progress load. Open the connected server in the Wplace panel and check that shared updates arrive.

On Docker, check the readiness endpoint.

~~~sh
curl --fail http://localhost:3000/health/ready
~~~

Use your configured port if it differs.

## Rollback

Restore the matching backup if a migration prevents the previous version from starting.

Stop the application, restore the pre-update database and matching objects, then start the previous version: for Docker, copy the two lines from the backup's `images.env` into `.env` first, loading its `images.tar` if it has one. A Helm rollback alone does not restore the database.
