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
- Create a Discord application and note its token, application ID, public key and client secret.
- Clone the repository and copy
server/.env.exampletoserver/.env. Fill in the Discord values and an encryption key (openssl rand -base64 32). SetINVARN_PUBLIC_URLto where people will open Invarn, for examplehttps://invarn.example.com. - Start it:
cd server && docker compose up -d --buildOpen http://localhost:24100/app/. To serve it elsewhere, put a reverse proxy that terminates TLS in
front of port 24100.
Configuration
| Variable | What it does |
|---|---|
INVARN_DATABASE_URL | PostgreSQL connection string. |
INVARN_PUBLIC_URL | The origin people use; sign-in redirects and links in Discord use it. |
INVARN_DISCORD_TOKEN, _APP_ID, _PUBLIC_KEY, _CLIENT_SECRET | The Discord application. |
INVARN_ENCRYPTION_KEY | 32 bytes, base64: encrypts stored Discord tokens. |
INVARN_SHARDS | all (default), none (serve HTTP and jobs only) or i/n (this process is i of n). |
INVARN_SHARD_COUNT | Gateway shards; empty uses Discord's recommendation. |
INVARN_SMTP_URL, INVARN_MAIL_FROM | Email for appeal updates (smtp://user:pass@host:port, or smtps://). Optional. |
INVARN_STRIPE_* | Payments. Without them, every server gets everything. |
INVARN_SENTRY_DSN | Error 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.