Skip to Content

Self-hosting

One-click deploy

Docker Compose

Install Docker Compose 2.24 or later. Run these commands as a regular user who owns the data folder.

git clone --branch release/1.0 https://github.com/ZhehanZhang/SwB.git
cd SwB
(umask 077; cp .env.example .env)
{
  printf 'SWB_UID=%s\n' "$(id -u)"
  printf 'SWB_KEY_OWNER='
  openssl rand -hex 32
} >> .env
printf 'SWB_PUBLIC_URL=http://localhost:8870\n' >> .env
mkdir -p data
docker compose up -d --build --wait
curl -fsS http://127.0.0.1:8870/healthz
docker compose exec -T switchboard swb login-link --url http://127.0.0.1:8000

Open the one-time sign-in link from the terminal within five minutes. Keep the link private.

The browser uses http://localhost:8870 for owner sign-in. The command inside the container uses port 8000. Compose keeps the data in ./data. After you change .env, run docker compose up -d again.

For a remote server, forward its port 8870 to local port 8870 before you open the link.

A signed-out request to /healthz returns status and version. Use an owner session or the owner key for full health details.

Cloudflare Tunnel

A Cloudflare Tunnel gives SwB a public HTTPS address. Cloudflare offers tunnels on its free plan.

Quick tunnel

Use a quick tunnel to try SwB at a temporary address. Run this command on the host with cloudflared, the program that connects SwB to Cloudflare.

cloudflared tunnel --url http://localhost:8870

Set SWB_PUBLIC_URL to the HTTPS address in the terminal. If your config contains public_url, update that setting too. Restart SwB. The address changes each time you start the tunnel. OAuth sign-ins and passkeys use that address. Use a named tunnel for a lasting address.

Named tunnel

Use a free Cloudflare account with your domain. Follow the Cloudflare setup guide to create the tunnel and set up Access. Set SWB_PUBLIC_URL in .env to your public address.

SWB_PUBLIC_URL=https://swb-your-team.example.net

Update the address in public_url if your config contains it. After you start SwB, check the public address.

For a tunnel on the SwB host, point its service address to http://localhost:8870. Set SWB_TRUSTED_PROXIES to the connector's address, such as 127.0.0.1/32 for an IPv4 loopback connection.

For the Compose tunnel, point its service address to http://switchboard:8000. Put the tunnel token in .env as TUNNEL_TOKEN. Add the connector's address or dedicated network to trusted_proxies. Start Compose with the tunnel profile.

docker compose --profile tunnel up -d

Trusted proxies

A reverse proxy passes requests to SwB. Add the proxy's address or dedicated network to trusted_proxies in config/switchboard.yaml. Write network ranges in CIDR format, such as 192.0.2.0/24.

You can also set SWB_TRUSTED_PROXIES in .env. Separate entries with commas. The YAML setting takes precedence.

For a Cloudflare Tunnel on the SwB host or Docker network, add the tunnel connector's address or dedicated network. The connector connects directly to SwB. Use the cloudflare entry for direct connections from Cloudflare edge servers.

Cloudflare Access

Follow the Cloudflare setup guide to configure SwB and set access rules for the owner and for client requests.

Hosted platforms

Use one SwB instance with a persistent disk mounted at /data. See the deployment guide for the Railway, Render and Fly.io templates and the Koyeb script.

Railway

Deploy from the SwB template on Railway. Keep one replica. The template mounts a volume at /data.

Use the Hobby plan for an always-on SwB. Hobby costs $5 a month and includes $5 of usage.

The Free plan includes $1 of usage a month. That amount covers about 100 MB of RAM around the clock. A test SwB instance used about 107 MiB while idle. Free plan services stop when the $1 runs out.

Fly.io

Use the SwB release checkout from the Docker Compose example. Install the Fly.io command line tool. Sign in to Fly.io.

Run sh deploy/fly.sh my-swb from the SwB folder. Replace my-swb with a unique app name. The script uses fly deploy --ha=false to start one Machine.

Open your app's sign-in page. Copy SWB_SETUP_CODE from .env.swb-setup-fly-my-swb in your checkout. Enter it in Setup code. Delete the file after sign-in.

See the Fly.io Free plan and current rates for billing details.

Backups and upgrades

Stop SwB before you copy its data folder. Keep the whole folder together, with the database and its keys, including mcp-events.key and claim-key. Back up your config files and .env too. Keep the backup private. Install or build the new version. Start SwB with the same data folder.

Export memory

Run the export inside the Compose container.

docker compose exec -T switchboard swb export /data/export

The export saves Markdown files by scope under ./data/export on the host. It includes an INDEX.md. Set memory.mirror_dir to keep a current Markdown copy.

On this page