Skip to main content

Deploy Claviger with a template

DEVELOPER GUIDE

Pick one of the four deploy templates, set the secrets, run one instance, and reach it over HTTPS on a stable host name.

Who this guide is for

Developers and self-hosters who put Claviger on a server, a Fly machine, a Kubernetes cluster or Azure Container Apps.

Why it matters

Every template runs one instance, because SQLite allows one writer. Passkeys need HTTPS and a host name that never changes. Both mistakes are costly to fix after people enrol.

What you will do, in one sentence

Copy the template for your platform, set PB_ENCRYPTION_KEY and the admin account, keep the count at one, and enrol people only on the final host name.

Screens are captured from a seeded test system. Every name, address and number on the screens is invented. Prepared 15 November 2026.

1. Choose a template​

The templates live in the deploy/ folder of the Claviger repository. Each folder has its own README.

PlatformFolderHow HTTPS works
Docker Composedeploy/docker-composeOptional Caddy profile with automatic HTTPS.
Fly.iodeploy/flyFly gives https://<app>.fly.dev. Add your own domain with fly certs add.
Kubernetesdeploy/kubernetesAn optional Ingress, with cert-manager or your own TLS secret.
Azure Container Appsdeploy/azure-container-appsAdd a custom domain. Container Apps manages the certificate.

The templates pin an image tag, ghcr.io/doodlemania2/claviger:<version>. Check the releases page for a tag before you deploy.

Run one instance only

Claviger stores data in SQLite. Two writers on one data directory corrupt the database. Never scale a template above one: not docker compose up --scale, not fly scale count 2, not a second Kubernetes pod.

2. Settings every template shares​

SettingNotes
PB_ENCRYPTION_KEYExactly 32 characters. Create it with openssl rand -hex 16. Set it before the first start. Keep a copy. Without it, encrypted settings cannot be read.
PB_ADMIN_EMAIL, PB_ADMIN_PASSWORDCreate the first superuser on the first start. Remove the password after that.
CLAVIGER_METRICS_TOKENOptional. Turns on the Prometheus route.
OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERSOptional. Turn on OTLP export.
LITESTREAM_*Optional. Continuous replication of the database.

After you deploy, check GET /api/health. Then open /_/ and sign in.

Behind a proxy, Claviger sees the proxy's address unless you tell it which header to trust. In the admin screen, open Settings, Application, User IP proxy headers and add the header:

PlatformHeader
Compose with the bundled CaddyfileX-Forwarded-For
FlyFly-Client-IP
KubernetesX-Forwarded-For. Tick Use leftmost IP if a cloud load balancer sits in front of the Ingress.
Azure Container AppsX-Forwarded-For

Otherwise rate limits count every user as one address. Add the header only when every request really passes through your proxy.

3. Docker Compose and Fly​

Docker Compose. Copy .env.example to .env, and set CLAVIGER_VERSION, CLAVIGER_DOMAIN and the admin account. Then start with HTTPS:

docker compose --profile caddy up -d
curl -fsS https://auth.example.org/api/health

For a test on http://127.0.0.1:8090, uncomment ports in compose.yaml and run docker compose up -d. The container has a read-only root file system. It writes only to /pb_data and a /tmp tmpfs.

Back up with a short stop and a tarball of the volume, or enable Litestream. Litestream does not store PB_ENCRYPTION_KEY, so back that up apart.

Fly. Edit fly.toml first. Then create the app and a volume, stage the secrets, and deploy one machine.

fly apps create your-claviger-app
fly volumes create claviger_data --size 1 --region iad --count 1
fly deploy --ha=false

An upgrade replaces the machine without a second one beside it, so there is a short outage. Take a volume snapshot first. The Fly README says fly config validate has not been run on the template, so run it yourself.

4. Kubernetes and Azure Container Apps​

Kubernetes. The manifests are a StatefulSet with one pod, a volume, a Service and an optional Ingress.

kubectl apply -f claviger.yaml
kubectl -n claviger rollout status statefulset/claviger
kubectl apply -f ingress.yaml
  • Do not add an HPA. A ReadWriteOnce volume limits the volume to one node, and two pods on that node can both mount it.
  • Every update or node drain means a short outage. That is the safe behavior for one SQLite writer.
  • Use block storage. Do not put /pb_data on NFS unless it supports POSIX byte-range locks, and never on SMB.
  • The image runs as root. The manifest drops all capabilities and uses a read-only root file system, but it does not set runAsNonRoot.
  • The README says kubectl could not schema-check the manifests. Run kubectl apply --dry-run=server against your cluster first.

Azure Container Apps. The Bicep template builds a Container App, an Azure Files NFS share, a VNet and logs.

az deployment group create -g claviger-rg \
--template-file main.bicep \
--parameters name=claviger clavigerVersion=0.1.0 \
encryptionKey="$(openssl rand -hex 16)" \
[email protected] adminPassword='a-long-random-password'
  • minReplicas and maxReplicas are both 1. Do not change them.
  • During an update two containers have the share mounted for about 40 seconds. The image's entrypoint.sh handles it. The new replica asks the old one to close both databases, and then opens them. PB_HANDOVER_TIMEOUT (default 60 seconds) bounds the wait.
  • Use NFS, not SMB. SQLite in WAL mode needs byte-range locks, and SMB shares lack them.
  • Upgrade with the same encryptionKey. A different value makes the stored settings unreadable.
  • The README says the template compiled with Bicep but was not deployed. Report problems as issues.
Never turn the handover off

PB_HANDOVER_TIMEOUT=0 turns the handover off. That is unsafe on a platform that overlaps replicas.

5. Passkeys: HTTPS and a stable host name​

A passkey is bound to the host name where it was made, the RP ID. If you change the domain, existing passkeys stop working.

  1. Choose your final domain before you enrol anyone.
  2. Add it to the platform first: fly certs add auth.example.org, a Caddy domain, an Ingress host, or az containerapp hostname add.
  3. Set the Application URL to that https address.
  4. Enrol people on that name, never on a temporary one such as fly.dev.

6. Quick reference card​

Every platform​

  1. One instance. Never scale up.
  2. PB_ENCRYPTION_KEY, 32 characters, copy stored.
  3. First superuser from PB_ADMIN_EMAIL and PB_ADMIN_PASSWORD, then remove the password.
  4. GET /api/health returns 200.

Before you enrol people​

  1. HTTPS works on the final host name.
  2. User IP proxy headers is set.
  3. A backup exists.

Back up before every upgrade. A migration may not be reversible.