| 1 | # Runbook |
| 2 | |
| 3 | > Attempt #2's only setup instructions lived in a plan file describing an architecture |
| 4 | > that had already been deleted, so they were actively wrong. Keep this file honest: |
| 5 | > if a command here doesn't work, fix it or delete it. |
| 6 | |
| 7 | ## Status |
| 8 | |
| 9 | The app boots and serves. Everything marked **(#2)** is carried from the previous |
| 10 | attempt and has **not** been re-verified against Topcoat — treat it as a sketch. |
| 11 | |
| 12 | ## Requirements |
| 13 | |
| 14 | - **rustc ≥ 1.95** — Topcoat 0.5 requires it, and on an older toolchain `cargo add |
| 15 | topcoat` silently resolves to an empty `topcoat v0.0.0` placeholder rather than |
| 16 | failing. Verified on 1.97.1. |
| 17 | - `git` on `PATH` (from Milestone 3 — `git init --bare` creates repos, and from |
| 18 | Milestone 4 `git http-backend` serves the protocol). **`cargo test` needs it too**: |
| 19 | `DiskGitStorage`'s tests run real `git init`, so a machine without `git` fails the |
| 20 | suite, not just the app. |
| 21 | |
| 22 | ## Dev setup |
| 23 | |
| 24 | ```bash |
| 25 | cargo run |
| 26 | cargo test |
| 27 | ``` |
| 28 | |
| 29 | ```bash |
| 30 | cargo install topcoat-cli |
| 31 | topcoat dev |
| 32 | ``` |
| 33 | |
| 34 | `topcoat dev` builds, bundles assets, watches sources, and live-reloads pages that |
| 35 | include `topcoat::dev::script()`. Press `r` to force a rebuild. |
| 36 | |
| 37 | ## Configuration |
| 38 | |
| 39 | `STEID_`-prefixed env vars via `dotenvy` + `envy`, read into `AppConfig`. Every value |
| 40 | has a default, so a bare `cargo run` works with no environment at all. |
| 41 | |
| 42 | Live now: |
| 43 | |
| 44 | ``` |
| 45 | STEID_DATABASE_URL=sqlite:steid.db?mode=rwc # default |
| 46 | STEID_DATA_DIR=./data # default; bare repos, read from M3 |
| 47 | STEID_INSECURE_COOKIES=false # default; see below |
| 48 | STEID_ALLOW_PRIVATE_WEBHOOKS=false # default; see below |
| 49 | STEID_OWNER_EMAIL= # unset; with the next one, see below |
| 50 | STEID_OWNER_HANDLE= # unset; both or neither |
| 51 | ``` |
| 52 | |
| 53 | There is deliberately **no owner password in configuration** — the owner is created |
| 54 | through the claim flow instead. See |
| 55 | [0002](decisions/0002-first-run-claim-not-config-bootstrap.md). |
| 56 | |
| 57 | ### `STEID_OWNER_EMAIL` / `STEID_OWNER_HANDLE` — the boot-time owner |
| 58 | |
| 59 | Set together, they create that owner on the first boot that finds the instance |
| 60 | unclaimed, before a single request is served. Nothing is printed at `/auth/setup`, no |
| 61 | setup token is minted, and there is never a moment when a stranger could claim the box. |
| 62 | This is what makes an unattended install safe; a self-hoster gets the same thing by hand. |
| 63 | |
| 64 | - **Both or neither.** One without the other **refuses to start** (exit 4) with a line |
| 65 | naming the one that is missing. The alternative — coming up unclaimed — is exactly the |
| 66 | state these exist to prevent, so it cannot be the fallback. |
| 67 | - **The seeded owner has no usable password.** Steid hashes 32 random bytes generated at |
| 68 | boot and dropped, so `login` verifies through the normal path and answers "wrong |
| 69 | password" in the usual time. There is no sentinel and no second code path. The way in |
| 70 | is `steid reset-password <handle>` on the box, or Milestone 7's identity when it lands. |
| 71 | - **Inert once claimed.** A restart with them still set does nothing and says nothing, |
| 72 | the way the setup token is inert once an owner exists — so they stay in the environment |
| 73 | file for the life of the instance. |
| 74 | - **A reserved or malformed handle, or a bad email, refuses to start**, with the domain |
| 75 | rule's own message. `admin` is reserved; the full list is in `domain/org.rs`. |
| 76 | |
| 77 | `install.sh --owner-email <addr> --owner-handle <name>` writes them, and refuses one |
| 78 | without the other. They are written **only when `/etc/steid/steid.env` is first |
| 79 | created**, like every other setting there, so an upgrade cannot re-seed anything — the |
| 80 | installer says so if you pass them to a re-run. |
| 81 | |
| 82 | It does not reopen [0002](decisions/0002-first-run-claim-not-config-bootstrap.md): what |
| 83 | that refused to put in configuration is the owner's *password*, and this puts no |
| 84 | credential anywhere. |
| 85 | |
| 86 | The bind address is **not** a `STEID_` variable — Topcoat owns it: |
| 87 | |
| 88 | ```bash |
| 89 | HOST=0.0.0.0 PORT=8080 cargo run |
| 90 | ``` |
| 91 | |
| 92 | That supersedes attempt #2's `STEID_LISTEN_ADDR`. |
| 93 | |
| 94 | ### `STEID_INSECURE_COOKIES` — development only |
| 95 | |
| 96 | Topcoat's session cookie is `__Host-` prefixed and `Secure`. `Secure` means the browser |
| 97 | only keeps it over a trustworthy origin, and browsers disagree about whether |
| 98 | plain-HTTP `localhost` qualifies. Where it doesn't, **the failure is completely |
| 99 | silent**: the server issues a session and records the row, the browser discards the |
| 100 | cookie, and every page renders signed out with no error anywhere. This cost an |
| 101 | afternoon; the symptom looks exactly like broken auth logic. |
| 102 | |
| 103 | Setting `STEID_INSECURE_COOKIES=true` swaps in `InsecureCookieTokenStore` — the same |
| 104 | cookie without `Secure` and without the prefix, named `steid-dev-session` so it can |
| 105 | never be confused with a hardened one. `HttpOnly` and `SameSite=Lax` are kept. Boot |
| 106 | prints a warning while it's on. |
| 107 | |
| 108 | **Never set this on a deployed instance.** Without `Secure` the session cookie travels |
| 109 | unencrypted and anyone on the network path can lift it and become that user. Behind |
| 110 | TLS, leave it unset. |
| 111 | |
| 112 | A gitignored `.env` in the repo root sets it for local work. Keep `.env` and |
| 113 | `.env.prod` out of git — both are gitignored. |
| 114 | |
| 115 | ### `STEID_ALLOW_PRIVATE_WEBHOOKS` — development only |
| 116 | |
| 117 | A webhook URL is refused if it points at this machine or its own private network, in two |
| 118 | places: `WebhookUrl::new` when it is saved, and again on every resolved address before the |
| 119 | request is dialled. That is the SSRF defence, and it is also what makes the **end-to-end |
| 120 | webhook check impossible to run** — proving that a real push signs and delivers a real |
| 121 | payload needs a receiver, and the receiver is a script on `127.0.0.1`. |
| 122 | |
| 123 | `STEID_ALLOW_PRIVATE_WEBHOOKS=true` relaxes **only the address rules**, in both halves at |
| 124 | once so the form and the sender cannot disagree. The scheme, credentials in the authority, |
| 125 | the port, the length and the packed spellings of an address (`127.1`, `2130706433`) are |
| 126 | refused with it on exactly as without: those are wrong wherever they point. |
| 127 | |
| 128 | **Never set this on a deployed instance.** With it on, anyone who can add a hook can make |
| 129 | the server issue requests inside its own network and read the response body back off the |
| 130 | deliveries page — the metadata endpoint of a cloud instance included. Boot prints a |
| 131 | warning while it is on. |
| 132 | |
| 133 | It exists because the alternative was worse: the check previously needed a temporary patch |
| 134 | to the source, and a patch is invisible and easy to leave in place. |
| 135 | |
| 136 | ## First run |
| 137 | |
| 138 | ```bash |
| 139 | cargo run |
| 140 | ``` |
| 141 | |
| 142 | An unclaimed instance prints a setup token and redirects every route to `/auth/setup`. |
| 143 | Paste the token, choose a handle, email, and password, and the owner is created and |
| 144 | signed in. |
| 145 | |
| 146 | **The password must be at least 12 characters** — one rule, no composition rules, applied |
| 147 | by `domain::Password` to the claim, a reset and a change alike. The form and the reset and |
| 148 | settings pages all print the same sentence on refusal; `POST /api/setup` refuses with its |
| 149 | usual opaque 404 and puts the reason in the log, so that the response cannot be used as a |
| 150 | token oracle. Existing passwords are not re-checked, so an account made before the rule |
| 151 | still signs in. |
| 152 | |
| 153 | **A restart also invalidates every CSRF token**, so a form somebody had open before it |
| 154 | answers 403 with "This form was submitted from somewhere else" when they submit. They |
| 155 | reload the page and retype. The secret is minted per boot on purpose — |
| 156 | [0008](decisions/0008-csrf-double-submit-bound-to-the-session.md) — so this applies to |
| 157 | `deploy.sh`, to `systemctl restart`, and to every `topcoat dev` rebuild in development. |
| 158 | |
| 159 | The token is **held in memory only**, so every restart mints a new one — including |
| 160 | each rebuild under `topcoat dev`. Use the most recent one printed. Once claimed, no |
| 161 | token is minted at all and `/auth/setup` redirects away. |
| 162 | |
| 163 | Sign in at `/auth/login` with the **email**, not the handle. |
| 164 | |
| 165 | ## Repo layout on disk (Milestone 3) |
| 166 | |
| 167 | Bare repos at `{STEID_DATA_DIR}/{handle}/{name}.git`, created with no template (so no |
| 168 | `.sample` hooks) and `HEAD` pinned to `refs/heads/main` regardless of the host's |
| 169 | `init.defaultBranch`. See [0006](decisions/0006-git-binary-behind-narrow-ports.md). |
| 170 | |
| 171 | Created empty — no initial commit and no branch, like GitHub. |
| 172 | |
| 173 | Creating one refuses rather than reusing a directory that already exists, so an orphan |
| 174 | left by a create that died mid-way blocks that name until it is removed by hand. |
| 175 | |
| 176 | ## Git transport (Milestone 4) |
| 177 | |
| 178 | Smart HTTP, delegated to `git http-backend`, authenticated with personal access tokens |
| 179 | over HTTP Basic — see [0001](decisions/0001-git-over-http-not-ssh.md). No SSH, no host |
| 180 | keys, no `authorized_keys`. |
| 181 | |
| 182 | ```bash |
| 183 | git clone http://host/{handle}/repos/{name}.git |
| 184 | ``` |
| 185 | |
| 186 | Fill in the token workflow and the `body_limit` setting once this is built. |
| 187 | |
| 188 | ## Deployment (container) |
| 189 | |
| 190 | A `Dockerfile` at the repo root builds a self-contained image. Two stages: `rust:1.97-bookworm` |
| 191 | compiles and bundles, `debian:bookworm-slim` runs. ~206 MB. |
| 192 | |
| 193 | ```bash |
| 194 | docker build -t steid . |
| 195 | docker volume create steid-data |
| 196 | docker run -d --name steid -p 3000:3000 -v steid-data:/data steid |
| 197 | docker logs steid |
| 198 | ``` |
| 199 | |
| 200 | Verified end to end on 2026-08-29: the image builds, boots, applies migrations, |
| 201 | creates `/data/steid.db`, serves `/auth/setup` with its stylesheet, and `git init |
| 202 | --bare` succeeds inside `/data/repos` as the non-root user. |
| 203 | |
| 204 | ### The build needs `topcoat asset bundle`, not just `cargo build` |
| 205 | |
| 206 | `cargo build --release` alone produces a binary that **fails to boot**. `main` calls |
| 207 | `AssetBundle::load()`, which walks up from the executable looking for |
| 208 | `assets/manifest.toml`; without one it returns `NotFound` and the process exits before |
| 209 | serving anything. `build.rs` does not write that bundle — it only runs Tailwind and |
| 210 | stages icons into `OUT_DIR`, where they are embedded in the binary. |
| 211 | |
| 212 | The bundle comes from the CLI, which the builder stage installs: |
| 213 | |
| 214 | ```bash |
| 215 | cargo install topcoat-cli --version 0.5.0 --locked |
| 216 | topcoat asset bundle --release |
| 217 | ``` |
| 218 | |
| 219 | It writes `target/assets/`, which must be copied **next to the binary** in the runtime |
| 220 | image — `/app/steid` finds `/app/assets`. This is the same step `topcoat dev` performs |
| 221 | for you, and the reason a hand-built binary serves stale CSS. |
| 222 | |
| 223 | Two build-time consequences worth knowing: |
| 224 | |
| 225 | - The build **needs network access**: `build.rs` downloads the standalone Tailwind CLI |
| 226 | from GitHub releases, and the bundler downloads any remote asset. |
| 227 | - The image is **Debian, not Alpine, on both sides**. Those Tailwind binaries are |
| 228 | glibc-linked, so a musl builder fails during `cargo build`. |
| 229 | |
| 230 | The builder mounts the cargo registry and `target/` as BuildKit caches. There is |
| 231 | deliberately **no dummy-`main.rs` dependency-caching trick**: `build.rs` scans the real |
| 232 | sources for Tailwind classes, and a faked source tree yields a stale stylesheet — a |
| 233 | wrong answer that still builds, which is the worst kind. |
| 234 | |
| 235 | ### Configuration in a container |
| 236 | |
| 237 | The image sets these defaults, so the `docker run` above needs no `-e` flags at all: |
| 238 | |
| 239 | ``` |
| 240 | STEID_DATABASE_URL=sqlite:/data/steid.db?mode=rwc |
| 241 | STEID_DATA_DIR=/data/repos |
| 242 | HOST=0.0.0.0 # Topcoat's, not STEID_-prefixed — see Configuration above |
| 243 | PORT=3000 |
| 244 | ``` |
| 245 | |
| 246 | No public URL is configured anywhere: the origin is derived from the `Host` header and |
| 247 | `X-Forwarded-Proto`, so a proxy that forwards both needs nothing further. |
| 248 | |
| 249 | **`STEID_INSECURE_COOKIES` is deliberately unset in the image and must stay unset.** |
| 250 | The session cookie is `Secure`, which means the deployment needs TLS — assume a |
| 251 | terminating proxy in front (Caddy, nginx, a platform router). Setting the variable to |
| 252 | paper over a missing certificate hands every session cookie to anyone on the network |
| 253 | path. `.dockerignore` excludes `.env` for the same reason: the dev `.env` sets it, and |
| 254 | copying it in would silently unharden a deployed image. |
| 255 | |
| 256 | ### State is one volume |
| 257 | |
| 258 | Everything that must survive a restart lives under `/data`: the SQLite database as a |
| 259 | file directly in it, the bare repositories under `/data/repos`. `VOLUME ["/data"]` is |
| 260 | declared, so a container started without `-v` still keeps its state — in an anonymous |
| 261 | volume that is easy to lose track of. Name it. |
| 262 | |
| 263 | `/data` itself must be writable, not just the database file: SQLite creates `-wal` and |
| 264 | `-shm` siblings next to it. |
| 265 | |
| 266 | The container runs as uid **10001** (`steid`). A named volume inherits that ownership |
| 267 | from the image on first use. A **bind mount does not** — `-v /srv/steid:/data` starts |
| 268 | root-owned and the app fails to write, so `chown 10001:10001 /srv/steid` on the host |
| 269 | first. |
| 270 | |
| 271 | ### Claiming a deployed instance |
| 272 | |
| 273 | The setup token is printed to **stdout only, and only while the instance is |
| 274 | unclaimed**. It is held in memory, so every restart — including every redeploy — |
| 275 | mints a new one, and a claimed instance mints none at all. |
| 276 | |
| 277 | There is no way to recover it other than the platform's logs: |
| 278 | |
| 279 | ```bash |
| 280 | docker logs steid | tail -20 |
| 281 | ``` |
| 282 | |
| 283 | Read the token from the **most recent** boot, then claim at `https://your-host/auth/setup`. |
| 284 | Until it is claimed every route redirects there, so an instance left unclaimed on a |
| 285 | public address is an open door — claim it immediately after the first deploy. |
| 286 | |
| 287 | ## Manual verification checklist (#2) |
| 288 | |
| 289 | Attempt #2 verified these by hand each milestone but never wrote down the steps. They |
| 290 | are the smoke test for Milestones 4–5. The auth rows assumed SSH keys; the shape of |
| 291 | the check still holds with tokens substituted: |
| 292 | |
| 293 | - [x] Create a repo via the web UI → bare repo appears at |
| 294 | `{data_dir}/{handle}/{name}.git` *(Milestone 3; also checked that the name |
| 295 | normalises, that a duplicate re-renders the form, and that a private repo 404s |
| 296 | for a signed-out visitor)* |
| 297 | - [ ] `git clone` an empty repo → succeeds |
| 298 | - [ ] `git clone` a repo with history → succeeds |
| 299 | - [ ] `git clone` a non-existent repo → clean error, not a hang or panic |
| 300 | - [ ] First push to an empty repo → succeeds |
| 301 | - [ ] Push to a repo with history → succeeds |
| 302 | - [ ] Push a repo large enough to exercise the `body_limit` cap → succeeds |
| 303 | - [ ] Clone with no credentials → rejected, and the prompt is comprehensible |
| 304 | - [ ] Clone with a valid token → succeeds |
| 305 | - [ ] Revoke the token → subsequent clone rejected at auth |
| 306 | - [ ] Clone a private repo as a non-member → rejected |
| 307 | - [ ] Push as a non-owner member → rejected |
| 308 | |
| 309 | Worth automating as an integration test rather than re-running by hand a fourth time. |
| 310 | |
| 311 | ## `.gitignore` |
| 312 | |
| 313 | Applied: `/target`, `/data`, `*.db*`, `.env`, `.env.prod`. |
| 314 | |
| 315 | **Do not add `/plans`.** Attempt #2 did, and that is why these docs had to be |
| 316 | hand-carried between repos. |
| 317 | |
| 318 | ## Deploying this instance |
| 319 | |
| 320 | The operator's path, as opposed to `README.md`, which is written for a stranger |
| 321 | installing their own. `jpgill.dev` served two roles from one box: this instance, |
| 322 | and the place everyone else downloaded Steid from. The second is now |
| 323 | `releases.steid.dev`, and the box keeps a mirror — see *Publishing a release* below. |
| 324 | |
| 325 | ### Order matters |
| 326 | |
| 327 | 1. **Provision — AWS Lightsail**, **Debian 13** blueprint (12 also works). Lightsail rather than EC2 |
| 328 | deliberately: it *is* AWS's VPS product, where EC2 makes you assemble the same box out |
| 329 | of a VPC, security groups, an EBS volume and an Elastic IP, with per-GB egress on top. |
| 330 | Either architecture works — releases are built for `x86_64` and `aarch64`, and |
| 331 | `install.sh` picks between them from `uname -m`, so a Graviton instance is fine. |
| 332 | |
| 333 | **Not Amazon Linux**, which Lightsail pre-selects: `install.sh` is Debian-family, and |
| 334 | it stops with a clear message on anything without `apt-get` rather than half-installing. |
| 335 | Ubuntu 22.04/24.04 work too. Debian 13 and 12 are both verified end to end in a |
| 336 | container — including that Caddy installs, since its apt repository URL is |
| 337 | codename-independent and that was the only plausible difference between them. |
| 338 | |
| 339 | Three Lightsail-specific things, each of which breaks the deployment silently if |
| 340 | missed: |
| 341 | |
| 342 | - **Attach a static IP.** A Lightsail instance takes a *new* public IP on stop/start. |
| 343 | Without one, a reboot changes the address, DNS points at nothing, and Caddy's |
| 344 | certificate renewals start failing with no obvious cause. Free while attached to a |
| 345 | running instance. |
| 346 | - **Open 80 and 443** in the instance's Networking tab. Only 22 is open by default, |
| 347 | and **Let's Encrypt validates over port 80** — a firewall that allows 443 alone |
| 348 | fails at certificate issuance, not at first request. |
| 349 | - **Snapshots are not backups.** They are whole-disk and live in the same AWS account. |
| 350 | The two state paths still want copying somewhere else. |
| 351 | 2. **DNS first, then install.** `dig +short jpgill.dev` must return the box's IP |
| 352 | *before* `install.sh` runs. Caddy requests a certificate on startup; if DNS has not |
| 353 | propagated it fails and backs off, and the resulting error points nowhere useful. |
| 354 | 3. **First install uses `--tarball`.** There is a bootstrap: this instance is what will |
| 355 | serve the releases, so at that moment there is nowhere to download from. |
| 356 | |
| 357 | ```sh |
| 358 | scp dist/steid-0.1.0-x86_64-unknown-linux-gnu.tar.gz install.sh root@<ip>:/root/ |
| 359 | ssh root@<ip> './install.sh --domain jpgill.dev \ |
| 360 | --tarball ./steid-0.1.0-x86_64-unknown-linux-gnu.tar.gz' |
| 361 | ``` |
| 362 | |
| 363 | Then `curl https://jpgill.dev/healthz` — over https, with a real certificate. |
| 364 | |
| 365 | ### Publishing a release |
| 366 | |
| 367 | Since 0.6.0 the release host is **`https://releases.steid.dev`** — the `steid-releases` |
| 368 | bucket behind CloudFront, in the Steid Cloud account |
| 369 | ([decision 0009](decisions/0009-releases-from-releases-steid-dev.md)). `jpgill.dev` |
| 370 | keeps serving the same files as a **mirror**, because every link handed out between |
| 371 | 0.4.0 and 0.6.0 points at it; the mirror goes when the control plane's milestone 2 moves |
| 372 | this instance onto the fleet. |
| 373 | |
| 374 | ```sh |
| 375 | ./release.sh --all |
| 376 | ./deploy.sh --publish-s3-only |
| 377 | ./deploy.sh --publish |
| 378 | ``` |
| 379 | |
| 380 | `--publish-s3-only` is the one to reach for. `--publish` on its own deploys the live |
| 381 | site as well, which is a separate decision from cutting a release. |
| 382 | |
| 383 | What the S3 half does, in order: uploads `dist/steid-<version>-<target>.tar.gz` and the |
| 384 | `.sha256` beside it to `v<version>/`, uploads `install.sh` to the bucket root, |
| 385 | invalidates `/install.sh` and `/v<version>/*` on the distribution and **waits** for the |
| 386 | invalidation, then fetches every published URL back over HTTPS and fails on anything |
| 387 | that is not a 200. |
| 388 | |
| 389 | Three things worth knowing before it surprises you: |
| 390 | |
| 391 | - **The credential is a named profile**, `--profile ${STEID_AWS_PROFILE:-steid}`, which |
| 392 | assumes a role into the Steid Cloud account. Nothing in this repository holds a key, |
| 393 | an account id or a role ARN — it is public. |
| 394 | - **The distribution id is looked up by alias**, not stored. `--distribution <id>` or |
| 395 | `STEID_RELEASES_DISTRIBUTION` if the lookup is ever wrong. |
| 396 | - **Content types are set explicitly** (`--no-guess-mime-type`). Left to guess, the CLI |
| 397 | labels a `.tar.gz` with `Content-Encoding: gzip`, browsers silently decompress it on |
| 398 | download, and the checksum then fails — which looks exactly like tampering. |
| 399 | |
| 400 | ### The mirror on this box |
| 401 | |
| 402 | Only this instance does this. The two `handle` blocks in |
| 403 | [deploy/Caddyfile](../deploy/Caddyfile) must be uncommented; `./deploy.sh --publish` |
| 404 | scps the artefacts into a **versioned** directory (the box has no rsync), matching the |
| 405 | URL `install.sh` built before 0.6.0 |
| 406 | (`https://jpgill.dev/jamesgill/repos/steid/releases/v${VERSION}/…`). `--no-mirror` |
| 407 | skips it. |
| 408 | |
| 409 | **Those Caddy paths shadow Steid.** Nothing lives at |
| 410 | `/{handle}/repos/{name}/releases` today, so nothing breaks — but when Steid grows a real |
| 411 | release feature at that URL, Caddy will keep winning and the feature will look broken. |
| 412 | Delete the blocks then. The URL is deliberately the one that feature will use, so links |
| 413 | published now survive it. |
| 414 | |
| 415 | `/install.sh` at the root is safe permanently rather than by luck: `OrgName` allows only |
| 416 | `[a-z0-9-]`, so no handle can contain a dot and none can ever collide with it. A |
| 417 | root-level `/releases` would **not** be safe — it is a valid handle shape. |
| 418 | |
| 419 | ### What is verified, and what is not |
| 420 | |
| 421 | Verified in a Debian 12 container with `systemctl` stubbed: prerequisites install, the |
| 422 | tarball extracts, `/opt/steid` and `/var/lib/steid` get the right owners and modes, the |
| 423 | `steid` user is created with `nologin`, the env file and unit and Caddyfile are written, |
| 424 | and **the binary starts as the `steid` user**. The artifact itself was booted on Debian |
| 425 | 11 (glibc 2.31) and served pages. |
| 426 | |
| 427 | **Not verified anywhere but a real box:** the systemd unit lifecycle, and Caddy's ACME |
| 428 | certificate issuance. Expect the first real run to need a fix or two. |
| 429 | |
| 430 | ### One bug already found this way |
| 431 | |
| 432 | `install.sh` defaulted to a `musl` target while `release.sh` had moved to `gnu`. The |
| 433 | symptom was `checksum mismatch` — because the installer was looking for a tarball that |
| 434 | was never built. The two defaults must agree; both now say so in a comment. |
| 435 | |
| 436 | > ## Operator surface |
| 437 | > |
| 438 | > Set `STEID_OPERATOR_TOKEN` to turn it on. Without it these routes answer **404, not |
| 439 | > 401** — an instance that was never given a token advertises nothing. The token is |
| 440 | > compared in constant time and is never a session: an operator is not a user of the site. |
| 441 | > Generate one with `openssl rand -hex 32` and put it in the systemd unit's environment |
| 442 | > file beside the other `STEID_` values. |
| 443 | > |
| 444 | > ### `GET /metrics` |
| 445 | > |
| 446 | > Prometheus text exposition, version 0.0.4. Zero subprocesses, so it is cheap to poll. |
| 447 | > |
| 448 | > ```console |
| 449 | > $ curl -H "Authorization: Bearer $STEID_OPERATOR_TOKEN" https://git.example.com/metrics |
| 450 | > # HELP steid_uptime_seconds Seconds since this process started serving. |
| 451 | > # TYPE steid_uptime_seconds gauge |
| 452 | > steid_uptime_seconds 241.901 |
| 453 | > steid_http_requests_total{class="page",status="2xx"} 25 |
| 454 | > steid_git_processes_total{command="log"} 11 |
| 455 | > steid_cat_file_requests_total 88 |
| 456 | > ... |
| 457 | > ``` |
| 458 | > |
| 459 | > Nothing in the output names a repository, a handle or a path — every label is a fixed |
| 460 | > constant — so the scrape is safe to ship to a collector that is less trusted than the |
| 461 | > instance. |
| 462 | > |
| 463 | > A scrape config for Prometheus: |
| 464 | > |
| 465 | > ```yaml |
| 466 | > scrape_configs: |
| 467 | > - job_name: steid |
| 468 | > scheme: https |
| 469 | > metrics_path: /metrics |
| 470 | > scrape_interval: 15s |
| 471 | > static_configs: |
| 472 | > - targets: ["git.example.com"] |
| 473 | > authorization: |
| 474 | > type: Bearer |
| 475 | > # `credentials_file` rather than `credentials`, so the token is not in the |
| 476 | > # config that ends up in a git repository. |
| 477 | > credentials_file: /etc/prometheus/steid-operator-token |
| 478 | > ``` |
| 479 | > |
| 480 | > **What to alert on.** `rate(steid_http_requests_total{status="5xx"}[5m])` above zero; |
| 481 | > `steid_imports_failed_total` rising; `steid_webhook_deliveries_total{outcome!="delivered"}` |
| 482 | > rising; `steid_rate_limit_rejections_total{limiter="metrics"}` rising, which means |
| 483 | > somebody is guessing the operator token. |
| 484 | > |
| 485 | > **What the classes mean.** `page` is HTML, `api` is `/api/…`, `git` is the smart-HTTP |
| 486 | > transport, `archive` is a tarball download, `feed` is an Atom feed, `other` is |
| 487 | > `/healthz`, `/robots.txt`, `/metrics` and static assets. |
| 488 | > |
| 489 | > Unauthorized requests to `/metrics` are rate limited to 30 per client per minute (300 |
| 490 | > across all clients). **An authorized scrape is never counted against that**, so a flood |
| 491 | > of wrong tokens cannot stop your collector. |
| 492 | |
| 493 | ## For `ui.md` |
| 494 | |
| 495 | Nothing. `/metrics` serves `text/plain` with no layout, no cookie and no HTML — it is not a |
| 496 | page and has no entry point anywhere in the interface. The only user-visible change is that |
| 497 | error responses now carry the security headers they always should have. |
| 498 | |
| 499 | ## Mail |
| 500 | |
| 501 | `STEID_SMTP_URL` (`smtps://user:pass@host:465`, `smtp://host?tls=required` for STARTTLS |
| 502 | on 587, bare `smtp://host:port` for a local plaintext sink) and `STEID_MAIL_FROM` |
| 503 | (`Steid <steid@example.com>`). Both or neither: without them the forgot-password page |
| 504 | says the instance cannot send email and names `steid reset-password <handle>`, which |
| 505 | prints a one-time link on the box. **Quote any `.env` value with spaces or angle |
| 506 | brackets** — an unquoted one makes dotenvy drop every variable after it, silently. |
| 507 | `STEID_PUBLIC_URL` is read only by that command, to print a whole link. |