Runbook
Attempt #2's only setup instructions lived in a plan file describing an architecture that had already been deleted, so they were actively wrong. Keep this file honest: if a command here doesn't work, fix it or delete it.
Status
The app boots and serves. Everything marked (#2) is carried from the previous attempt and has not been re-verified against Topcoat — treat it as a sketch.
Requirements
- rustc ≥ 1.95 — Topcoat 0.5 requires it, and on an older toolchain
cargo add topcoatsilently resolves to an emptytopcoat v0.0.0placeholder rather than failing. Verified on 1.97.1. gitonPATH(from Milestone 3 —git init --barecreates repos, and from Milestone 4git http-backendserves the protocol).cargo testneeds it too:DiskGitStorage's tests run realgit init, so a machine withoutgitfails the suite, not just the app.
Dev setup
topcoat dev builds, bundles assets, watches sources, and live-reloads pages that
include topcoat::dev::script(). Press r to force a rebuild.
Configuration
STEID_-prefixed env vars via dotenvy + envy, read into AppConfig. Every value
has a default, so a bare cargo run works with no environment at all.
Live now:
STEID_DATABASE_URL=sqlite:steid.db?mode=rwc # default
STEID_DATA_DIR=./data # default; bare repos, read from M3
STEID_INSECURE_COOKIES=false # default; see below
STEID_ALLOW_PRIVATE_WEBHOOKS=false # default; see below
STEID_OWNER_EMAIL= # unset; with the next one, see below
STEID_OWNER_HANDLE= # unset; both or neither
STEID_OWNER_ORG= # unset; optional, needs the two above
STEID_OWNER_ORG_NAME= # unset; optional, needs the one above
There is deliberately no owner password in configuration — the owner is created through the claim flow instead. See 0002.
STEID_OWNER_EMAIL / STEID_OWNER_HANDLE — the boot-time owner
Set together, they create that owner on the first boot that finds the instance
unclaimed, before a single request is served. Nothing is printed at /auth/setup, no
setup token is minted, and there is never a moment when a stranger could claim the box.
This is what makes an unattended install safe; a self-hoster gets the same thing by hand.
- Both or neither. One without the other refuses to start (exit 4) with a line naming the one that is missing. The alternative — coming up unclaimed — is exactly the state these exist to prevent, so it cannot be the fallback.
- The seeded owner has no usable password. Steid hashes 32 random bytes generated at
boot and dropped, so
loginverifies through the normal path and answers "wrong password" in the usual time. There is no sentinel and no second code path. The way in issteid reset-password <handle>on the box, or Milestone 7's identity when it lands. - Inert once claimed. A restart with them still set does nothing and says nothing, the way the setup token is inert once an owner exists — so they stay in the environment file for the life of the instance.
- A reserved or malformed handle, or a bad email, refuses to start, with the domain
rule's own message.
adminis reserved; the full list is indomain/org.rs.
STEID_OWNER_ORG / STEID_OWNER_ORG_NAME — the organisation the instance is for
Optional, and read only when the two above are set — an organisation with nobody to own
it is not a state Steid has, so on its own STEID_OWNER_ORG is ignored rather than
refused. With it, the first boot creates the organisation, makes the seeded owner its
owner, and sets it as the home page, so the root lands on /{org} and the setup
wizard's second screen has nothing left to ask.
STEID_OWNER_ORGis the handle —acme. Validated like any other: malformed, reserved, or already taken (the owner's own handle, say) refuses to start, exit 4, for the same reason half an owner does.STEID_OWNER_ORG_NAMEis the display name —Acme Inc. Quote it; it may have spaces.- Without them the instance comes up with no home chosen, and the root falls back to the seeded owner's own page. That is what a one-person instance wants.
install.sh --owner-email <addr> --owner-handle <name> writes them, and refuses one
without the other. --owner-org <handle> and --owner-org-name <name> write the
organisation into the same block; --owner-org refuses without the owner flags, and
--owner-org-name refuses without --owner-org.
Choosing the home page by hand
The root of an instance lands on its home page — the organisation it is for. It is
set in three ways, and read by
home_handle:
- the setup wizard's second screen,
/auth/setup/organisation, on the first claim; - the "Make this the home page" box on
/orgs/new, or the button in the Home section of/{handle}/settings— both need you to own that handle; STEID_OWNER_ORGat boot, above.
With none of them, no home is stored and the root falls back to the sole user's handle,
which is how every instance behaved before 0.8.0. There is no way to unset it, only to
point it somewhere else. See
0011. They are written only when /etc/steid/steid.env is first
created, like every other setting there, so an upgrade cannot re-seed anything — the
installer says so if you pass them to a re-run.
It does not reopen 0002: what that refused to put in configuration is the owner's password, and this puts no credential anywhere.
The bind address is not a STEID_ variable — Topcoat owns it:
HOST=0.0.0.0 PORT=8080
That supersedes attempt #2's STEID_LISTEN_ADDR.
STEID_INSECURE_COOKIES — development only
Topcoat's session cookie is __Host- prefixed and Secure. Secure means the browser
only keeps it over a trustworthy origin, and browsers disagree about whether
plain-HTTP localhost qualifies. Where it doesn't, the failure is completely
silent: the server issues a session and records the row, the browser discards the
cookie, and every page renders signed out with no error anywhere. This cost an
afternoon; the symptom looks exactly like broken auth logic.
Setting STEID_INSECURE_COOKIES=true swaps in InsecureCookieTokenStore — the same
cookie without Secure and without the prefix, named steid-dev-session so it can
never be confused with a hardened one. HttpOnly and SameSite=Lax are kept. Boot
prints a warning while it's on.
Never set this on a deployed instance. Without Secure the session cookie travels
unencrypted and anyone on the network path can lift it and become that user. Behind
TLS, leave it unset.
A gitignored .env in the repo root sets it for local work. Keep .env and
.env.prod out of git — both are gitignored.
STEID_ALLOW_PRIVATE_WEBHOOKS — development only
A webhook URL is refused if it points at this machine or its own private network, in two
places: WebhookUrl::new when it is saved, and again on every resolved address before the
request is dialled. That is the SSRF defence, and it is also what makes the end-to-end
webhook check impossible to run — proving that a real push signs and delivers a real
payload needs a receiver, and the receiver is a script on 127.0.0.1.
STEID_ALLOW_PRIVATE_WEBHOOKS=true relaxes only the address rules, in both halves at
once so the form and the sender cannot disagree. The scheme, credentials in the authority,
the port, the length and the packed spellings of an address (127.1, 2130706433) are
refused with it on exactly as without: those are wrong wherever they point.
Never set this on a deployed instance. With it on, anyone who can add a hook can make the server issue requests inside its own network and read the response body back off the deliveries page — the metadata endpoint of a cloud instance included. Boot prints a warning while it is on.
It exists because the alternative was worse: the check previously needed a temporary patch to the source, and a patch is invisible and easy to leave in place.
First run
An unclaimed instance prints a setup token and redirects every route to /auth/setup.
Paste the token, choose a handle, email, and password, and the owner is created and
signed in.
The password must be at least 12 characters — one rule, no composition rules, applied
by domain::Password to the claim, a reset and a change alike. The form and the reset and
settings pages all print the same sentence on refusal; POST /api/setup refuses with its
usual opaque 404 and puts the reason in the log, so that the response cannot be used as a
token oracle. Existing passwords are not re-checked, so an account made before the rule
still signs in.
A restart also invalidates every CSRF token, so a form somebody had open before it
answers 403 with "This form was submitted from somewhere else" when they submit. They
reload the page and retype. The secret is minted per boot on purpose —
0008 — so this applies to
deploy.sh, to systemctl restart, and to every topcoat dev rebuild in development.
The token is held in memory only, so every restart mints a new one — including
each rebuild under topcoat dev. Use the most recent one printed. Once claimed, no
token is minted at all and /auth/setup redirects away.
Sign in at /auth/login with the email, not the handle.
Repo layout on disk (Milestone 3)
Bare repos at {STEID_DATA_DIR}/{handle}/{name}.git, created with no template (so no
.sample hooks) and HEAD pinned to refs/heads/main regardless of the host's
init.defaultBranch. See 0006.
Created empty — no initial commit and no branch, like GitHub.
Creating one refuses rather than reusing a directory that already exists. An orphan
left by a create, rename or import that died mid-way is moved aside on the next boot, to
{STEID_DATA_DIR}/orphaned/<seconds>-<name>, which frees the name and keeps the objects
(sweep_orphan_directories, run by sweep_on_boot — see
architecture.md). Nothing deletes what is
there; that is by hand.
Git transport (Milestone 4)
Smart HTTP, delegated to git http-backend, authenticated with personal access tokens
over HTTP Basic — see 0001. No SSH, no host
keys, no authorized_keys.
Fill in the token workflow and the body_limit setting once this is built.
Deployment (container)
A Dockerfile at the repo root builds a self-contained image. Two stages: rust:1.97-bookworm
compiles and bundles, debian:bookworm-slim runs. ~206 MB.
Verified end to end on 2026-08-29: the image builds, boots, applies migrations,
creates /data/steid.db, serves /auth/setup with its stylesheet, and git init --bare succeeds inside /data/repos as the non-root user.
The build needs topcoat asset bundle, not just cargo build
cargo build --release alone produces a binary that fails to boot. main calls
AssetBundle::load(), which walks up from the executable looking for
assets/manifest.toml; without one it returns NotFound and the process exits before
serving anything. build.rs does not write that bundle — it only runs Tailwind and
stages icons into OUT_DIR, where they are embedded in the binary.
The bundle comes from the CLI, which the builder stage installs:
It writes target/assets/, which must be copied next to the binary in the runtime
image — /app/steid finds /app/assets. This is the same step topcoat dev performs
for you, and the reason a hand-built binary serves stale CSS.
Two build-time consequences worth knowing:
- The build needs network access:
build.rsdownloads the standalone Tailwind CLI from GitHub releases, and the bundler downloads any remote asset. - The image is Debian, not Alpine, on both sides. Those Tailwind binaries are
glibc-linked, so a musl builder fails during
cargo build.
The builder mounts the cargo registry and target/ as BuildKit caches. There is
deliberately no dummy-main.rs dependency-caching trick: build.rs scans the real
sources for Tailwind classes, and a faked source tree yields a stale stylesheet — a
wrong answer that still builds, which is the worst kind.
Configuration in a container
The image sets these defaults, so the docker run above needs no -e flags at all:
STEID_DATABASE_URL=sqlite:/data/steid.db?mode=rwc
STEID_DATA_DIR=/data/repos
HOST=0.0.0.0 # Topcoat's, not STEID_-prefixed — see Configuration above
PORT=3000
No public URL is configured anywhere: the origin is derived from the Host header and
X-Forwarded-Proto, so a proxy that forwards both needs nothing further.
STEID_INSECURE_COOKIES is deliberately unset in the image and must stay unset.
The session cookie is Secure, which means the deployment needs TLS — assume a
terminating proxy in front (Caddy, nginx, a platform router). Setting the variable to
paper over a missing certificate hands every session cookie to anyone on the network
path. .dockerignore excludes .env for the same reason: the dev .env sets it, and
copying it in would silently unharden a deployed image.
State is one volume
Everything that must survive a restart lives under /data: the SQLite database as a
file directly in it, the bare repositories under /data/repos. VOLUME ["/data"] is
declared, so a container started without -v still keeps its state — in an anonymous
volume that is easy to lose track of. Name it.
/data itself must be writable, not just the database file: SQLite creates -wal and
-shm siblings next to it.
The container runs as uid 10001 (steid). A named volume inherits that ownership
from the image on first use. A bind mount does not — -v /srv/steid:/data starts
root-owned and the app fails to write, so chown 10001:10001 /srv/steid on the host
first.
Claiming a deployed instance
The setup token is printed to stdout only, and only while the instance is unclaimed. It is held in memory, so every restart — including every redeploy — mints a new one, and a claimed instance mints none at all.
There is no way to recover it other than the platform's logs:
|
Read the token from the most recent boot, then claim at https://your-host/auth/setup.
Until it is claimed every route redirects there, so an instance left unclaimed on a
public address is an open door — claim it immediately after the first deploy.
Manual verification checklist (#2)
Attempt #2 verified these by hand each milestone but never wrote down the steps. They are the smoke test for Milestones 4–5. The auth rows assumed SSH keys; the shape of the check still holds with tokens substituted:
- Create a repo via the web UI → bare repo appears at
{data_dir}/{handle}/{name}.git(Milestone 3; also checked that the name normalises, that a duplicate re-renders the form, and that a private repo 404s for a signed-out visitor) git clonean empty repo → succeedsgit clonea repo with history → succeedsgit clonea non-existent repo → clean error, not a hang or panic- First push to an empty repo → succeeds
- Push to a repo with history → succeeds
- Push a repo large enough to exercise the
body_limitcap → succeeds - Clone with no credentials → rejected, and the prompt is comprehensible
- Clone with a valid token → succeeds
- Revoke the token → subsequent clone rejected at auth
- Clone a private repo as a non-member → rejected
- Push as a non-owner member → rejected
Worth automating as an integration test rather than re-running by hand a fourth time.
.gitignore
Applied: /target, /data, *.db*, .env, .env.prod.
Do not add /plans. Attempt #2 did, and that is why these docs had to be
hand-carried between repos.
Deploying this instance
The operator's path, as opposed to README.md, which is written for a stranger
installing their own. jpgill.dev served two roles from one box: this instance,
and the place everyone else downloaded Steid from. The second is now
releases.steid.dev, and the box keeps a mirror — see Publishing a release below.
Order matters
Provision — AWS Lightsail, Debian 13 blueprint (12 also works). Lightsail rather than EC2 deliberately: it is AWS's VPS product, where EC2 makes you assemble the same box out of a VPC, security groups, an EBS volume and an Elastic IP, with per-GB egress on top. Either architecture works — releases are built for
x86_64andaarch64, andinstall.shpicks between them fromuname -m, so a Graviton instance is fine.Not Amazon Linux, which Lightsail pre-selects:
install.shis Debian-family, and it stops with a clear message on anything withoutapt-getrather than half-installing. Ubuntu 22.04/24.04 work too. Debian 13 and 12 are both verified end to end in a container — including that Caddy installs, since its apt repository URL is codename-independent and that was the only plausible difference between them.Three Lightsail-specific things, each of which breaks the deployment silently if missed:
- Attach a static IP. A Lightsail instance takes a new public IP on stop/start. Without one, a reboot changes the address, DNS points at nothing, and Caddy's certificate renewals start failing with no obvious cause. Free while attached to a running instance.
- Open 80 and 443 in the instance's Networking tab. Only 22 is open by default, and Let's Encrypt validates over port 80 — a firewall that allows 443 alone fails at certificate issuance, not at first request.
- Snapshots are not backups. They are whole-disk and live in the same AWS account. The two state paths still want copying somewhere else.
DNS first, then install.
dig +short jpgill.devmust return the box's IP beforeinstall.shruns. Caddy requests a certificate on startup; if DNS has not propagated it fails and backs off, and the resulting error points nowhere useful.First install uses
--tarball. There is a bootstrap: this instance is what will serve the releases, so at that moment there is nowhere to download from.
Then curl https://jpgill.dev/healthz — over https, with a real certificate.
Publishing a release
Since 0.6.0 the release host is https://releases.steid.dev — the steid-releases
bucket behind CloudFront, in the Steid Cloud account
(decision 0009). jpgill.dev
keeps serving the same files as a mirror, because every link handed out between
0.4.0 and 0.6.0 points at it; the mirror goes when the control plane's milestone 2 moves
this instance onto the fleet.
--publish-s3-only is the one to reach for. --publish on its own deploys the live
site as well, which is a separate decision from cutting a release.
What the S3 half does, in order: uploads dist/steid-<version>-<target>.tar.gz and the
.sha256 beside it to v<version>/, uploads install.sh to the bucket root,
invalidates /install.sh and /v<version>/* on the distribution and waits for the
invalidation, then fetches every published URL back over HTTPS and fails on anything
that is not a 200.
Three things worth knowing before it surprises you:
- The credential is a named profile,
--profile ${STEID_AWS_PROFILE:-steid}, which assumes a role into the Steid Cloud account. Nothing in this repository holds a key, an account id or a role ARN — it is public. - The distribution id is looked up by alias, not stored.
--distribution <id>orSTEID_RELEASES_DISTRIBUTIONif the lookup is ever wrong. - Content types are set explicitly (
--no-guess-mime-type). Left to guess, the CLI labels a.tar.gzwithContent-Encoding: gzip, browsers silently decompress it on download, and the checksum then fails — which looks exactly like tampering.
The mirror on this box
Only this instance does this. The two handle blocks in
deploy/Caddyfile must be uncommented; ./deploy.sh --publish
scps the artefacts into a versioned directory (the box has no rsync), matching the
URL install.sh built before 0.6.0
(https://jpgill.dev/jamesgill/repos/steid/releases/v${VERSION}/…). --no-mirror
skips it.
Those Caddy paths shadow Steid. Nothing lives at
/{handle}/repos/{name}/releases today, so nothing breaks — but when Steid grows a real
release feature at that URL, Caddy will keep winning and the feature will look broken.
Delete the blocks then. The URL is deliberately the one that feature will use, so links
published now survive it.
/install.sh at the root is safe permanently rather than by luck: OrgName allows only
[a-z0-9-], so no handle can contain a dot and none can ever collide with it. A
root-level /releases would not be safe — it is a valid handle shape.
What is verified, and what is not
Verified in a Debian 12 container with systemctl stubbed: prerequisites install, the
tarball extracts, /opt/steid and /var/lib/steid get the right owners and modes, the
steid user is created with nologin, the env file and unit and Caddyfile are written,
and the binary starts as the steid user. The artifact itself was booted on Debian
11 (glibc 2.31) and served pages.
Not verified anywhere but a real box: the systemd unit lifecycle, and Caddy's ACME certificate issuance. Expect the first real run to need a fix or two.
One bug already found this way
install.sh defaulted to a musl target while release.sh had moved to gnu. The
symptom was checksum mismatch — because the installer was looking for a tarball that
was never built. The two defaults must agree; both now say so in a comment.
Operator surface
Set
STEID_OPERATOR_TOKENto turn it on. Without it these routes answer 404, not 401 — an instance that was never given a token advertises nothing. The token is compared in constant time and is never a session: an operator is not a user of the site. Generate one withopenssl rand -hex 32and put it in the systemd unit's environment file beside the otherSTEID_values — or, since 0.7.0, passinstall.sh --operator-token "$(openssl rand -hex 32)"and let the installer write it before Steid first starts. That flag is the only thing a re-run of the installer rewrites insteid.env, and only when it is given; pass it again to rotate. The value is never printed.
GET /api/instanceSince 0.7.0 the operator shape carries
disk:"disk":The data directory walked, and
statvfson the filesystem it sits on — so this answers about/var/lib/steid/repos's volume, not the root disk, which matters the moment state is on a volume of its own.filesystem_free_bytesisf_bavail, what is free to the unprivilegedsteiduser rather than to root.The walk is cached for a minute. Measured on the author's laptop, a synthetic tree of 20 repositories × 1,000 loose objects (20,000 files, 78 MB) walks in 115–160 ms, and a real 4,150-file
.gitin 13 ms warm. A poll every few seconds would otherwise make monitoring the most expensive thing the instance does; a number a minute old is indistinguishable from a fresh one at the resolution anybody reads it.There is no
/metricsgauge for it. The consumer is a console showing one instance's storage, and adding it to the scrape would mean a walk on the collector's schedule too.
GET /metricsPrometheus text exposition, version 0.0.4. Zero subprocesses, so it is cheap to poll.
$ curl -H "Authorization: Bearer $STEID_OPERATOR_TOKEN" https://git.example.com/metrics # HELP steid_uptime_seconds Seconds since this process started serving. # TYPE steid_uptime_seconds gauge steid_uptime_seconds 241.901 steid_http_requests_total{class="page",status="2xx"} 25 steid_git_processes_total{command="log"} 11 steid_cat_file_requests_total 88 ...Nothing in the output names a repository, a handle or a path — every label is a fixed constant — so the scrape is safe to ship to a collector that is less trusted than the instance.
A scrape config for Prometheus:
scrape_configs: - job_name: steid scheme: https metrics_path: /metrics scrape_interval: 15s static_configs: - targets: authorization: type: Bearer # `credentials_file` rather than `credentials`, so the token is not in the # config that ends up in a git repository. credentials_file: /etc/prometheus/steid-operator-tokenWhat to alert on.
rate(steid_http_requests_total{status="5xx"}[5m])above zero;steid_imports_failed_totalrising;steid_webhook_deliveries_total{outcome!="delivered"}rising;steid_rate_limit_rejections_total{limiter="metrics"}rising, which means somebody is guessing the operator token.What the classes mean.
pageis HTML,apiis/api/…,gitis the smart-HTTP transport,archiveis a tarball download,feedis an Atom feed,otheris/healthz,/robots.txt,/metricsand static assets.Unauthorized requests to
/metricsare rate limited to 30 per client per minute (300 across all clients). An authorized scrape is never counted against that, so a flood of wrong tokens cannot stop your collector.
For ui.md
Nothing. /metrics serves text/plain with no layout, no cookie and no HTML — it is not a
page and has no entry point anywhere in the interface. The only user-visible change is that
error responses now carry the security headers they always should have.
STEID_SMTP_URL (smtps://user:pass@host:465, smtp://host?tls=required for STARTTLS
on 587, bare smtp://host:port for a local plaintext sink) and STEID_MAIL_FROM
(Steid <steid@example.com>). Both or neither: without them the forgot-password page
says the instance cannot send email and names steid reset-password <handle>, which
prints a one-time link on the box. Quote any .env value with spaces or angle
brackets — an unquoted one makes dotenvy drop every variable after it, silently.
STEID_PUBLIC_URL is read only by that command, to print a whole link.