This is the runbook for the one canonical, public BotFights arena. Every
node's local instance can proxy match/fighter state to a shared arena via
`ARENA_UPSTREAM_URL` — this document covers deploying the well-known default
one, on the Foundation's VPS2 host.
Nothing here is git-tracked automatically: nginx-proxy-manager's routing
config and the host `.env` (secrets) live only on the VPS2 host. This file is
the only record of how to reproduce or roll back the deployment.
## Architecture: arena-as-relay (read this first)
BotFights' shared-arena design is intentionally decentralized, not
hardcoded to one server:
- **Any node can host a public arena.** It's the exact same container image
any node already runs — a "public arena" is just a BotFights instance with
`ARENA_UPSTREAM_URL`**unset** (standalone mode) that other nodes point at.
- **Each node picks its own community** by setting `ARENA_UPSTREAM_URL` in
its own manifest/environment. Unset = fully standalone, own local SQLite DB.
- **This VPS2 deployment is only the well-known default rendezvous** — like
the vps2 FIPS anchor — not an authority baked into the code. Nothing in
`botfight`'s server or frontend code hardcodes `146.59.87.168`; it is
entirely an environment-variable choice made by whoever configures a node.
- The game UI is always served locally by each node; only match/fighter
state lives wherever `ARENA_UPSTREAM_URL` points.
- **How to host your own arena:** deploy this exact `docker-compose.arena.yml`
pattern (or even the node's normal `docker-compose.yml`) anywhere reachable,
leave `ARENA_UPSTREAM_URL` unset on it, generate your own `JWT_SECRET`, and
point whichever nodes you want in your community at
`ARENA_UPSTREAM_URL=http://<your-host>:<port>`. There is no registration or
allowlist step — the protocol is "point at a URL that speaks the BotFights
API."
## Current canonical instance
| Field | Value |
|---|---|
| Host | VPS2, `debian@146.59.87.168` (docker, not podman — this is host infra, not an Archipelago node) |
| Directory | `/opt/botfights-arena/` |
| Compose file | `/opt/botfights-arena/docker-compose.yml` (copied from this repo's `docker-compose.arena.yml`, not symlinked — re-copy after edits) |
| Container name | `botfights-arena` |
| Image | `localhost:3000/lfg2025/botfights:1.1.0` (Gitea registry on the same host; `localhost:3000` resolves without any insecure-registry config because Docker trusts loopback registries by default — this is why the compose file uses `localhost:3000`, not the public `146.59.87.168:3000`, as the image ref) |
| Port | **9100** (verified free before binding; now bound — see `ss -tlnp` output in this phase's execution log) |
| Data volume | named volume `botfights-arena-data` → `/app/server/data` inside the container (host mountpoint: `docker volume inspect botfights-arena_botfights-arena-data --format '{{.Mountpoint}}'`) |
`http://146.59.87.168:9100` to `https://botfights.archipelago-foundation.org` — DONE 2026-07-30: the user created the DNS A record and the NPM proxy host with a Let's Encrypt cert; `TRUSTED_PROXY=1` was enabled on the arena at the same time (it now sits behind NPM).
| Digest | `sha256:854ea299...26e144` (short form; full digest recorded in `.planning/phases/09-botfights-platform-upgrade/09-05-SUMMARY.md` — re-derive any time with `skopeo inspect` above) |
| Built from | `botfight` repo `main` @ the commit carrying the `GET /api/fights/poll` route-order fix below (`2a343ac` + fix commit) |
| Local smoke test | `/api/health` → `{"status":"ok",...}`; `/api/docs/prompt` → 200 `text/markdown`; `/api/auth/me` (no auth) → 401; `/api/fights/poll` (registered bot) → 200 `{"pending":false}` |
**Deviation fixed in the same build pass:**`GET /api/fights/poll` (the
polling protocol BOT-02's unified prompt documents) was pre-existing-broken
— a `GET /:id` dynamic route registered earlier in `server/src/routes/fights.ts`
shadowed the later-registered static `GET /poll` route, so any polling bot's
poll request was matched as a fight-id lookup for id `"poll"` and always
returned `404 {"error":"Fight not found."}`. Reproduced independently on a
throwaway container with a fresh DB (not an artifact of the arena's seeded
data) before fixing. Fixed by moving the `/poll` and `/poll/respond` route
registrations above `/:id` in the router. This was necessary to meet this
plan's own acceptance criterion (bot auth via `GET /api/fights/poll` against
the public arena) and to make BOT-02's unified prompt's polling-mode
| `POST /api/bots` (anonymous, from off-host) | 200, id+secret issued; bot immediately visible in `GET /api/bots` |
| `GET /api/fights/poll` (bot auth via `Authorization: Bot id:secret`) | 200 `{"pending":false}` — see the `GET /:id` route-order fix above; this was 404 before it |
| `POST /api/queue/join/<botId>` → poll again | matched into a real fight within seconds; poll returned the live challenge payload |
| `GET /api/fights/<id>/stream` (SSE) | Incremental delivery confirmed: `spectator_count`/`ping` events at connection open, a second `ping` ~15s later, then `round_end`/`round_start`/`poll_challenge` in a fresh cluster ~4-5s after that — spread over a live 25s capture window, not buffered until stream close |
| `JWT_SECRET` survived the roll | `/opt/botfights-arena/.env` mtime predates this session's image rolls (unchanged); container's `JWT_SECRET` env still sources `${JWT_SECRET}` from that same file, not a freshly generated value |
| Data integrity | `GET /api/bots` → 101 (100 original + 1 test bot from an earlier verification pass), `?type=classic` → 15, unchanged/grown from the pre-roll 100+15 |
**Test bots left in the arena, clearly named per this plan's own naming
convention (no bot-deletion API exists in this codebase to remove them
cleanly):** `wavetest2`, `wavetest3` — both anonymous, harmless, real
fighters; consistent with the arena's existing `FIGHT_LOOP_ENABLED=true`
mock-bot background activity. `wavetest3` fought one live match as part of
(never touching) the installed `botfights` app on port 9100 (image 1.1.0).
| Check | Result |
|---|---|
| Proxy instance has no local data of its own | Startup still seeds a local 100+15 mock-bot DB (unrelated background code path that runs regardless of `ARENA_UPSTREAM_URL`) — but every `/api/*` request is intercepted by `arena-proxy` before it ever reaches a local route handler, so that local data is never exposed through the API |
| `GET /api/bots` via the proxy instance | Returned 103 bots, including `wavetest2` and `wavetest3` — both registered directly against the arena in Task 2, never touching this instance. **This is the D1 proof: a fighter registered on one host is visible through a different instance that never stored it.** |
| Reverse direction: register via the proxy instance | `POST http://127.0.0.1:9101/api/bots {"name":"wavetest4"}` succeeded, and `wavetest4` was immediately visible in `GET https://botfights.archipelago-foundation.org/api/bots` directly |
| SSE through the proxy instance | `wavetest3` matched into a real fight; `GET http://127.0.0.1:9101/api/fights/<id>/stream` delivered `spectator_count`/`ping` at connection open and a second `ping` ~15s later — incremental, not buffered |
| `/api/health` bypass during a deliberate arena outage | `docker compose stop` on the VPS2 arena (seconds); `GET http://127.0.0.1:9101/api/health` still returned `200 {"status":"ok",...}` throughout — confirmed answered locally per `arena-proxy.ts`'s `LOCAL_BYPASS_PATHS`, never forwarded |
| `/api/bots` during the same outage, via the **canonical HTTPS URL** (fronted by nginx-proxy-manager since 2026-07-30) | `502`, but the body was NPM's own HTML error page, not the app's JSON — because NPM itself answers with a gateway-level 502 before the request ever reaches the stopped container; `fetch()` inside `arena-proxy.ts` succeeds against NPM and passes its response through verbatim. This supersedes the plan's original acceptance wording (written when the arena was still plain-HTTP/no-NPM); NPM 502ing here is expected, correct behavior for a proxy in front of a stopped upstream. |
| `/api/bots` during a second, separate short outage, via the **raw fallback port** (`http://146.59.87.168:9100`, no NPM in front) | `502 {"error":"Arena unreachable."}` — `arena-proxy.ts`'s own JSON degradation path (already unit-tested in 09-01), confirmed live against a real stopped upstream with no intermediary |
| Recovery | `docker compose start` on VPS2 both times; arena `healthy` again within seconds; the proxy instance's own subsequent requests succeeded immediately, no restart needed on the node side |
| Installed app isolation | `podman ps --filter name=botfights` showed the installed `botfights` app (port 9100, image `:1.1.0`) with its original container id and uptime, unaffected throughout; no `botfights-proxytest*` container remains after cleanup |
**Test bots registered during this task, left in the arena (same rationale
as Task 2 — clearly named, no delete API exists):** `wavetest4`.