Hosting · Overview

Hosting Civility

The Civility server stores and syncs data for Civility apps. It also serves the account pages (/login, /signup, /settings) and the admin panel (/admin). This page shows how to run it, how to deploy it, and which settings it reads.

The server is one process, started with civ api start from the @civility/cli package.

Part Default Alternative
Database SQLite file None
Uploaded files A directory on the local disk An S3-compatible bucket
Email Printed to the server log, not sent Resend or SMTP

Uploaded files ("blobs") and email are changed in the admin panel while the server runs.

Every server serves its own API reference: Swagger UI at /api/v1 and OpenAPI JSON at /api/v1/doc.

Run it on your machine

  1. Install Deno 2.9 or later.

    curl -fsSL https://deno.land/install.sh | sh
    
  2. Install the CLI as civ. The --unstable-cron flag lets the server run its scheduled jobs.

    deno install jsr:@civility/cli -Afg --unstable-cron --name=civ
    
  3. Set the auth secret. The server does not start without it.

    export CIVILITY_AUTH_SECRET="$(civ api gen-secret)"
    

    Save this value. Use the same one every time you start the server. See Environment variables.

  4. Name the account that may open the admin panel.

    export CIVILITY_ADMIN_EMAILS=you@example.org
    
  5. Start the server.

    civ api start
    

    The first run asks for a port, a hostname and a database path, then saves the answers to ~/.config/civility/api.json. Later runs use the saved file without asking.

  6. Open http://localhost:3848/signup and create an account with the email from step 4. Then open http://localhost:3848/admin/.

Until you set up email in /admin/email, the server prints each message to its log and marks new accounts as verified.

Start options

Flag Default What it sets
-p, --port <port> 3848 Port to listen on.
--hostname <hostname> 0.0.0.0 Address to bind to. 0.0.0.0 accepts connections on all interfaces.
--db-path <path> ./.data/civility.db SQLite database file.
--site <path> None A site.json, or a directory holding one, with your own pages. See Site pages.
--site-url <url> None Public address of your site. After checkout, paid sign-ups return to <url>/welcome, so your site needs that page.
--canonical-host <host> The request's host Host that identity handles use (user@<host>). Set it if your reverse proxy changes the Host header.
--reset Ask the setup questions again and overwrite the saved file.

If you pass any flag other than --reset, the server does not ask questions. It uses the saved file (or the defaults), applies your flags on top, and does not change the saved file. Pass at least one flag when you start the server from a script or a service, so that it never waits for input.

civ api start --port 9000
civ api start --hostname 127.0.0.1 --db-path /var/lib/civility/civility.db

The saved file holds the same values as the flags. It holds no secrets.

{
  "port": 3848,
  "hostname": "0.0.0.0",
  "dbPath": "./.data/civility.db"
}

You can add site, siteUrl and canonicalHost by hand.

Environment variables

Variable Required What it does
CIVILITY_AUTH_SECRET Yes Signs sessions and tokens, and encrypts the credentials you save in the admin panel. Generate one with civ api gen-secret.
CIVILITY_ADMIN_EMAILS No Comma-separated emails. An account with one of these emails, once verified, can open /admin after signing in.
CIVILITY_ADMIN_TOKEN No Token for scripts that call /admin. Send it as Authorization: Bearer <token>. Generate one with civ admin token.
CIVILITY_BLOB_PATH No Directory for uploaded files until you save a storage setting in /admin/storage. Default ./.data/blobs.
OTEL_DENO, OTEL_* No Turn on OpenTelemetry. See Observability.

The admin panel is off unless you set CIVILITY_ADMIN_EMAILS or CIVILITY_ADMIN_TOKEN.

Keep CIVILITY_AUTH_SECRET the same for the life of the database, and keep a copy somewhere safe. If it changes, everyone is signed out and the credentials saved in the admin panel (storage, email, billing, services) can no longer be read.

Port, hostname and database path are flags, not environment variables. The Docker template adds its own PORT and DATA_DIR.

Everything else is a setting in the admin panel, stored in the database: blob storage, email, limits, tiers, billing and service credentials.

Deploy

Run one server process per database file. The SQLite file cannot be shared between machines. To give the server more room, use a larger machine and move uploaded files to a bucket in /admin/storage.

Guide What you get
Docker One container and one volume. Includes notes for Docker Compose, Coolify and Fly.io.
Manual deployment A Linux server running civ api start under systemd, behind Caddy for HTTPS.

After you deploy, read the Runbook for upgrades, rollbacks, backups and incidents.

All hosting pages

Deploy and operate:

Features:

  • Admin panel: who can open /admin and what each page does.
  • Authentication: sign-in, MFA, and what the operator controls.
  • Blob storage: where uploaded files are kept, and how to move them.
  • Limits: quotas, retention and rate limits for the whole server.
  • Tiers: the list of plans and their limits.
  • Billing: Stripe setup for paid plans.
  • Services: AI and podcast services, shared credentials and the proxy.
  • Maintenance: scheduled jobs such as pruning and blob cleanup.
  • Observability: OpenTelemetry traces, metrics and logs.
  • Operations: log rotation, capacity planning and data requests.
  • Site pages: serve your own landing pages, docs and blog from the same server.