Invarn Docs

Self-hosting

Run your own Invarn with Docker Compose.

Invarn is a server (invarn serve, invarn migrate), its dashboard, and PostgreSQL 16 or later. The dashboard is its own image: Caddy serving it at /app and passing every other path to the server.

With Docker Compose

  1. Create a Discord application and note its token, application ID, public key and client secret.
  2. Clone the repository and copy server/.env.example to server/.env. Fill in the Discord values and an encryption key (openssl rand -base64 32). Set INVARN_PUBLIC_URL to where people will open Invarn, for example https://invarn.example.com.
  3. Start it:
cd server && docker compose up -d --build

Open http://localhost:24100/app/. To serve it elsewhere, put a reverse proxy that terminates TLS in front of port 24100.

Configuration

VariableWhat it does
INVARN_DATABASE_URLPostgreSQL connection string.
INVARN_PUBLIC_URLThe origin people use; sign-in redirects and links in Discord use it.
INVARN_DISCORD_TOKEN, _APP_ID, _PUBLIC_KEY, _CLIENT_SECRETThe Discord application.
INVARN_ENCRYPTION_KEY32 bytes, base64: encrypts stored Discord tokens.
INVARN_SHARDSall (default), none (serve HTTP and jobs only) or i/n (this process is i of n).
INVARN_SHARD_COUNTGateway shards; empty uses Discord's recommendation.
INVARN_SMTP_URL, INVARN_MAIL_FROMEmail for appeal updates (smtp://user:pass@host:port, or smtps://). Optional.
INVARN_STRIPE_*Payments. Without them, every server gets everything.
INVARN_SENTRY_DSNError reports (Sentry or Bugsink). Optional.

Scaling

Every process serves HTTP and runs background jobs; processes don't talk to each other, they meet in Postgres. Gateway shards are split between processes with INVARN_SHARDS: never let two processes run the same shard on one token. On shutdown a process saves its gateway sessions, so the next one resumes them instead of missing events.

Set the application's Interactions Endpoint URL to https://<your host>/interactions to answer commands and buttons over HTTP from any process; without it, they arrive over the gateway.

On this page