# Deployment The site runs on [Render](https://render.com) as a container image. Every push to `main` that changes more than documentation runs `.toboggan/workflows/deploy.yml`: ``` check ── image ── deploy ``` 1. **check** (instance runner): `bun run check`, `bun run test`, `bun run build`. 2. **image** (`starfleet-podman` runner): `scripts/publish-image.sh --push` builds `deploy/Containerfile` and smoke-tests the image. The test checks that it boots, that `/healthz` answers with its version, and that `/login` renders. It then pushes `toboggan.cloud/starfleet/starfleet-ui:` and `:latest` with the job's own token. 3. **deploy** (instance runner, `production` environment): points the Render service's configured image at that exact tag and deploys it through Render's API. Without an API key it falls back to the deploy hook (`imgURL=`), with a warning. It then polls `$RENDER_URL/healthz` until the site reports the commit (15 minutes at most). A manual run on `main` (`tob workflow run deploy.yml`) redeploys. ## Why it works this way - **Render pulls a public image.** Render's registry credentials cover GitHub, GitLab, Docker Hub, Google Artifact Registry and AWS ECR, not toboggan. So the repository is public, and the package a workflow pushes inherits that. The image holds no secrets: each player's API key lives in their own cookie. - **A podman runner of our own.** toboggan.cloud's podman runner serves the toboggan repository only, and `corellia-starfleet-podman` is scoped to starfleet-api. - **The service's configured image must be the deployed one.** Render starts every new instance from the service's configured image: a free instance waking from sleep, a restart. A deploy hook's `imgURL` deploys an image once but leaves that setting alone. On 2026-11-07 the setting was still `:latest`, and instances started after the deploy served the old image while the dashboard showed the new one live. So the job sets the image (`PATCH /v1/services/{id}`) before deploying it. - **The deploy hook is a secret.** Its URL carries a key. It lives in the `production` environment, which only runs on the default branch can read. It never appears on a command line or in the log. ## One-time setup 1. **A runner for this repository.** Run `tob runner token -R starfleet/starfleet-ui` to get a registration token. On the CI host, register it with the label `starfleet-podman`, the same way starfleet-api's runner is set up (toboggan `docs/registry.md`, "Building in CI"). Alternatively, register one runner for the whole `starfleet` igloo on `/runners` so both repositories share it. 2. **The first image.** Push `main`. With no `RENDER_URL` set yet, the run publishes the image and skips the deploy job. 3. **The Render service.** Create a Web Service from the existing image `toboggan.cloud/starfleet/starfleet-ui:latest` with no credential, and set its health check path to `/healthz`. No environment variables are needed, because Render sets `PORT`. Optionally set `STARFLEET_API_URL` to point at another game server. 4. **The hook and the address.** Copy the service's deploy hook (Settings → Deploy Hook), then: - `tob secret set RENDER_DEPLOY_HOOK --env production --body-file -` and paste the hook, then Ctrl-D. Reading it from stdin keeps it out of your shell history. - `tob variable set RENDER_URL --body https://.onrender.com`. 5. **The API key and the service id**, so a deploy also pins the service's image (see "Why it works this way"). Create an API key in Render (Account settings → API Keys), then: - `tob secret set RENDER_API_KEY --env production --body-file -`, paste the key, then Ctrl-D. - `tob variable set RENDER_SERVICE_ID --body srv-…` (the dashboard shows the service ID). 6. **Deploy.** Run `tob workflow run deploy.yml`, or push. ## Running the image locally ```sh scripts/publish-image.sh local # build + smoke test, no push podman run --rm -p 3000:3000 toboggan.cloud/starfleet/starfleet-ui:local ``` ## Configuration | Variable | Default | | |---|---|---| | `STARFLEET_API_URL` | `https://starfleet.glo.quebec` | game API the server proxies to | | `PORT` / `HOST` | `3000` / `0.0.0.0` (image) | Render sets `PORT` | | `STARFLEET_UI_VERSION` | `dev` | stamped by `publish-image.sh`; `/healthz` answers it | | `CONNECTION_IDLE_TIMEOUT` | `60` | seconds; must exceed the API's 15 s SSE keepalive | Variables are declared in `src/env.ts`. SvelteKit 3 inlines any variable that isn't declared there at build time.