# Deploying Superbot ``` push to main ──► tangled spindle (.tangled/workflows/deploy.yml) docker build (type check + tests + dashboard build) docker push atcr.io/superbot.evil.gay/superbot:{latest,} │ TrueNAS SCALE ◄──────────┘ watchtower checks atcr.io every 60s and restarts app "superbot" Superbot on a new :latest ▲ VPS (Caddy) superbot.evil.gay ──tailnet──► truenas-scale:30087 superbot.mmatt.net ──301──► superbot.evil.gay ``` Nothing reaches into the NAS. CI only publishes an image, and the NAS pulls it. tangled's runners can't reach private or tailnet addresses, so this is the only direction that works. ## One-time setup 1. **App passwords for `superbot.evil.gay`** (bsky.app → Settings → Privacy and security → App passwords): - `superbot-ci`: CI uses it to push images. - `superbot-truenas`: the app uses it to sign the bot in and to pull images. 2. **Spindle secret:** on the tangled repo, go to Settings → Pipelines, pick the hosted spindle, then Secrets → Add `ATCR_APP_PASSWORD` = the `superbot-ci` password. 3. **First image:** push to `main` (or retry the latest pipeline). Check that `atcr.io/superbot.evil.gay/superbot:latest` exists. 4. **DNS:** in Cloudflare, on the `evil.gay` zone: - `A` record `superbot` → `178.156.148.234` (the VPS), DNS only (grey cloud). It overrides the `*.evil.gay` wildcard that points at the PDS. - `TXT` record `_atproto.superbot` → `did=did:plc:ulrdcgudase5ksj7cay2zhqt`, so the bot's handle still resolves now that the hostname no longer reaches the PDS. Keep the old `A` record `superbot.mmatt.net` → `178.156.148.234` (DNS only) for the redirect. 5. **Caddy on the VPS:** the live instance is `caddy-plausible`, with its config in `/etc/caddy/Plausiblefile`. Add: ``` superbot.evil.gay { bind 178.156.148.234 # The bot's handle. The PDS used to answer this, before the hostname moved here. respond /.well-known/atproto-did "did:plc:ulrdcgudase5ksj7cay2zhqt" reverse_proxy 100.113.28.18:30087 } superbot.mmatt.net { bind 178.156.148.234 redir https://superbot.evil.gay{uri} permanent } ``` then run `caddy-plausible validate --config /etc/caddy/Plausiblefile --adapter caddyfile && systemctl reload caddy-plausible`. 6. **TrueNAS registry:** go to Apps → Configuration → Docker Registries → Add Registry. Use `https://atcr.io` as the custom registry URI, `superbot.evil.gay` as the username, and the `superbot-truenas` app password. TrueNAS needs the registry credentials before it can create the Superbot container. 7. **TrueNAS app:** go to Apps → Discover → ⋮ → Install via YAML, name it `superbot`, and paste [`truenas-compose.yaml`](truenas-compose.yaml). Replace `PASTE_BOT_APP_PASSWORD` with the `superbot-truenas` password. The server creates its session secret and OAuth signing key on first boot. They live in the `superbot-data` volume, with the SQLite database. ## Day to day - **Deploy:** push to `main`. About a minute after CI finishes, watchtower restarts Superbot on the new image. - **Roll back:** in the TrueNAS app YAML, change `:latest` to `:` (every build is also tagged with its commit) and save. Watchtower leaves pinned tags alone. Switch back to `:latest` to resume auto-deploys. - **Skip a deploy:** `git push -o skip-ci`. - **Logs:** TrueNAS → Apps → superbot → Logs, for the `superbot` and `watchtower` containers.