Sabha deploys with Kamal, which gives you zero-downtime Docker deploys and a free Let’s Encrypt certificate. Everything Sabha needs runs on one server: the app, its SQLite database, background jobs and the AnyCable WebSocket server. You pay only for the server.
What you need
- A server running Ubuntu with Docker. Any VPS provider works (DigitalOcean, Hetzner, Linode and so on).
- A domain name, such as
chat.yourdomain.com, with a DNS record pointing at the server. - Docker and Kamal on your own computer. Install Kamal with
gem install kamal. - An account on a container registry, such as GitHub Container Registry. Kamal builds the image on your computer and pushes it there.
- A Resend account with a verified sending domain, if you want sign-in codes and notification emails.
| Resource | Minimum | Recommended |
|---|---|---|
| RAM | 2 GB | 4 GB |
| CPU | 1 core | 2 cores |
| Disk | 40 GB | 80 GB or more |
| OS | Ubuntu 22.04 | Ubuntu 24.04 |
Deploy with Kamal
Prepare the server
Install Docker and create the folder that will hold your data. Sabha runs as an unprivileged user inside its container (UID 999), so that user has to own the folder:
ssh root@your-server "curl -fsSL https://get.docker.com | sh && mkdir -p /disk/sabha && chown -R 999:999 /disk/sabha"Get the code
git clone https://github.com/sabha-co/sabha.git cd sabhaPoint Kamal at your registry
config/deploy.ymlpushes to the Sabha project’s own registry. Changeimage,registryand the build cache to your account, andarchto match your server:config/deploy.ymlyaml image: your-user/sabha registry: server: ghcr.io username: your-user password: - KAMAL_REGISTRY_PASSWORD builder: arch: amd64 # arm64 for an ARM server cache: type: registry image: your-user/sabha-build-cacheOr delete the
cacheblock: builds then take a few minutes longer.Set your configuration
.kamal/secretsreads every value from your shell environment. Copy.env.sampleto.env, fill it in (see Configuration below), and add the three values Kamal itself needs:.envbash SERVER_IP=203.0.113.10 PROXY_HOST=chat.yourdomain.com KAMAL_REGISTRY_PASSWORD=your_registry_tokenThen load it into your shell:
set -a; source .env; set +aDeploy
kamal setupKamal installs its proxy on the server, gets a certificate for
PROXY_HOST, builds and pushes the image, and starts Sabha and its WebSocket server.Create your account
Open
https://chat.yourdomain.com. The first visit shows a setup form. Name the workspace, choose Workspace (internal, for people who work together) or Community (public-facing, for a group or audience), which can’t be changed later, and enter the name, email and password of its first administrator.With
AUTH_METHOD=ssothere’s no form: the first person to sign in through your parent app becomes the administrator. See Single sign-on.
Configuration
Sabha is configured with environment variables. Set them in .env and run kamal deploy to apply a change. Sabha won’t start without APP_HOST, SECRET_KEY_BASE and ANYCABLE_SECRET.
# Your domain
APP_HOST=chat.yourdomain.com
COOKIE_DOMAIN=chat.yourdomain.com
# Security (generate each with: openssl rand -hex 64)
SECRET_KEY_BASE=your_secret_key_here
ANYCABLE_SECRET=your_anycable_secret
# Email (API key from resend.com)
RESEND_API_KEY=your_resend_api_key
MAILER_FROM_EMAIL=noreply@yourdomain.com
# Web Push (generate with: npx web-push generate-vapid-keys)
VAPID_PUBLIC_KEY=your_public_key
VAPID_PRIVATE_KEY=your_private_key
# Sign-in: "password" (default), "otp" (email codes) or "sso"
AUTH_METHOD=password| Variable | What it does |
|---|---|
APP_HOST |
Required. Your domain, without https://. Used in links, emails and the WebSocket address, and the only host Sabha answers to. |
SECRET_KEY_BASE |
Required. Signs sessions and cookies, and encrypts stored secrets. Keep it secret and keep it stable. |
ANYCABLE_SECRET |
Required. Secures the link between Sabha and its WebSocket server. |
COOKIE_DOMAIN |
The domain session cookies are set for. Usually the same as APP_HOST. |
RESEND_API_KEY |
Sends email through Resend. Without it, email features stay off, and email-code sign-in can’t work. |
MAILER_FROM_EMAIL |
The address emails come from, verified with your email provider. Defaults to noreply@ your APP_HOST. The sender’s name is the workspace’s. |
VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY |
Signs push notifications. |
AUTH_METHOD |
password (email and password), otp (a code sent by email) or sso (single sign-on). |
The workspace’s name, logo and color are set in the app; the analytics and embedding variables are in Branding. A few more are optional:
| Variable | What it does |
|---|---|
CLOUDFLARE_TURNSTILE_SITE_KEY, CLOUDFLARE_TURNSTILE_SECRET_KEY |
Adds a Cloudflare Turnstile check to the sign-up page. |
DICEBEAR_ENABLED, DICEBEAR_HOST, DICEBEAR_STYLE |
Generated default avatars. On by default using the public DiceBear API; set DICEBEAR_ENABLED=false to use initials instead. |
SENTRY_DSN |
Sends errors to your Sentry project. |
DESKTOP_NOTIFICATIONS_ENABLED |
Set to true to send notifications and badge counts to the Sabha desktop app. |
SABHA_HUB_SECRET |
Turns on Continue with sabha.co. |
WebSockets
Live updates, typing indicators, presence and push decisions all run through AnyCable, a WebSocket server that runs beside the app. The Kamal setup already includes it: an anycable accessory that serves /cable on your domain. You only need to set ANYCABLE_SECRET.
Sabha needs AnyCable-Go 1.6.9 or newer. The anycable/anycable-go:1.6 image in config/deploy.yml pulls the latest 1.6 release.
If you want the client-facing tokens signed with a different secret from the server-to-server link, set ANYCABLE_JWT_SECRET and ANYCABLE_STREAMS_SECRET to the same new value, on both the app and the anycable accessory, and add both to env.secret and .kamal/secrets. Unset, they fall back to ANYCABLE_SECRET.
Running without Kamal
Each release is published as a Docker image at ghcr.io/sabha-co/sabha, for amd64 and arm64. If you run it some other way, you need to wire up what the Kamal setup provides:
- A persistent volume mounted at
/rails/storage. It holds the database and uploaded files. - The app container listens on port 3000 and answers health checks at
/up. - An
anycable/anycable-go(1.6.9 or newer) container withANYCABLE_RPC_HOSTpointing at the app’s/_anycableendpoint (for examplehttp://sabha-web:3000/_anycable),ANYCABLE_PATH=/cable,ANYCABLE_BROADCAST_ADAPTER=http,ANYCABLE_HTTP_BROADCAST_PORT=8080,ANYCABLE_BROKER=memory,ANYCABLE_PRESENCE_TTL=45,ANYCABLE_HEADERS=cookie,authorizationand the sameANYCABLE_SECRETas the app. Withoutauthorizationin the headers, apps can’t connect. ANYCABLE_BROADCAST_URLon the app, pointing at AnyCable’s/_broadcastendpoint (it defaults tohttp://sabha-anycable:8080/_broadcast).- A reverse proxy with HTTPS that sends
/cableto AnyCable, keeping the/cableprefix on the request, and everything else to the app. Run a single AnyCable instance: presence lives in its memory.
HTTPS isn’t optional: over plain HTTP, people can sign in but can’t post.
config/deploy.yml in the repository is the reference for every setting above.
Updating
Get the new version’s code, then deploy it:
git pull
kamal deployKamal builds the new version from your checkout, starts it, and switches traffic over once it’s healthy.
kamal deploy doesn’t restart the WebSocket server. To pick up a newer AnyCable release, or a changed ANYCABLE_SECRET, restart it too:
kamal accessory reboot anycableEveryday commands
kamal logs # Follow the app's logs
kamal console # Open a Rails console
kamal dbc # Open a database console
kamal shell # Open a shell inside the app container
kamal app stop # Stop the app
kamal app boot # Start it againBackups
Everything Sabha stores lives in /disk/sabha on the server: its two SQLite databases (the main one and the job queue) and uploaded files. Back it up regularly, and copy the backups somewhere off the server, such as S3 or R2.
To take a consistent backup, stop the app for the moment it takes to archive the folder:
kamal app stop
ssh root@your-server "tar -czf /root/sabha-backup-$(date +%Y%m%d).tar.gz -C /disk/sabha ."
kamal app bootTo restore, stop the app, unpack the archive over the folder and start it again:
kamal app stop
ssh root@your-server "tar -xzf /root/sabha-backup.tar.gz -C /disk/sabha"
kamal app bootA daily cron job on the server that archives /disk/sabha and uploads it to object storage is a good default.
Monitoring
Check that Sabha is up:
curl -f https://chat.yourdomain.com/up && echo "OK" || echo "FAIL"Check the server’s memory, disk and container usage:
ssh root@your-server "docker stats --no-stream && df -h && free -h"Database maintenance
Sabha uses SQLite in WAL mode. To confirm the mode, or to compact the database after deleting a lot of data:
# Should print "wal"
kamal app exec 'bin/rails runner "puts ActiveRecord::Base.connection.execute(%(PRAGMA journal_mode)).first[%(journal_mode)]"'
# Compact the database
kamal app exec 'bin/rails runner "ActiveRecord::Base.connection.execute(%(VACUUM))"'To see how much space your data takes:
ssh root@your-server "du -sh /disk/sabha"sabha.co and the desktop app
Sabha’s desktop app, and sabha.co for workspaces already in a member’s list, find your server through GET /api/manifest. There’s nothing to configure beyond a reachable HTTPS address.
Continue with sabha.co
A workspace can let members sign in with their sabha.co account, as one more option beside your own password or email-code sign-in. A Sabha Cloud Deploy server is connected when it’s built. sabha.co doesn’t add other self-hosted workspaces by address, so the steps below apply only to a workspace that’s already in your sabha.co list:
Get a secret
On sabha.co, open your account’s Workspaces page, and choose Set up Continue with sabha.co from the workspace’s ⋯ menu. sabha.co shows a secret once.
Give your server the secret
Add it to
.envasSABHA_HUB_SECRETand runkamal deploy.Verify
Click Verify on sabha.co. It checks that your workspace is running with the secret, then switches the option on.
Your rules still apply. Someone new still needs your invite link. An existing member is never matched to a sabha.co account by email: they connect it from their own profile after signing in the usual way. sabha.co tells your workspace a member’s name and email only after that member approves it once.
To rotate the secret, use Get a new secret from the same menu, deploy with the new secret and click Verify straight away; the option stops working in between. To turn it off, use Disconnect from sabha.co. Members keep your workspace in their list and sign in the usual way. Workspaces using their own single sign-on can’t use this option.
Desktop notifications
The Sabha desktop app can show notifications and a badge count, following the same rules as push notifications. It’s off until you set DESKTOP_NOTIFICATIONS_ENABLED=true.