steid

@jamesgill /

steid/README.md
Markdown18.5 KBRendered·Source·Blame·History·Raw
1# Steid
2
3A personal gitforge, in Rust. It hosts your repositories, and it is meant to become the
4place your work as a whole lives — code, writing, projects — under one identity you
5control.
6
7Steid is **portfolio-first**. Gitea and Forgejo are GitHub scaled down; their unit is the
8repository and the profile is a directory listing bolted to the side. Steid inverts that:
9the profile page at `/{handle}` is the product, and git repositories are one kind of
10thing that appears on it. That framing wins every tie-break in the design.
11
12It runs as a single binary with a SQLite database, shells out to `git` for everything
13git-shaped, and is small enough to host on the cheapest VPS you can find.
14
15## What works today
16
17Honestly and only:
18
19- **Identity and sessions.** One user. The instance is claimed on first run with a setup
20 token, then you sign in with a password. There is no registration — see
21 [limitations]#current-limitations.
22- **The profile page** at `/{handle}`, listing what you have.
23- **Repositories.** Created through the browser, or imported by cloning a URL. Stored as
24 bare repos on disk and records in SQLite. Public or private, renameable, pinnable,
25 archivable, deletable, with a default branch you choose.
26- **Clone and push over HTTPS**, through `git http-backend`, authenticated with personal
27 access tokens over HTTP Basic. Private repositories require a token to clone; public
28 ones are anonymous.
29- **Personal access tokens** — issue with an expiry (30 days, 90, a year, or never), see
30 when each was last used, revoke, at `/{handle}/settings/tokens`.
31- **Browsing** — file tree with a per-file **last-commit column**, file contents with
32 syntax highlighting, commit log, a commit and its **highlighted diff**, a three-dot
33 comparison of two revisions, blame, branches and tags, and the README rendered on the
34 repository page with `#12` and bare shas linked to the issue and commit they name.
35- **A file's own history** at `/{handle}/repos/{name}/log/{rev}/-/{path}`, which
36 **follows renames**, so a file's past does not stop where its name changed.
37- **Markdown files render as documents**, with `?view=source` for the text; headings get
38 ids, so a link to `notes.md#usage` lands on the section it names. Submodule rows link
39 to their upstream at the sha they are pinned to, and symlink rows say where they point.
40- **Code search** over a revision, at `/{handle}/repos/{name}/search`.
41- **Archive download** — `zip` and `tar.gz` of any revision, and of every tag.
42- **Issues** — open, comment, edit, close and reopen, with labels from a palette of
43 eight colours, and filtering by label and state.
44- **Pull requests** — branch to branch inside one repository, with a Conversation, the
45 commits and the changed files under their own tabs, the same labels the issues wear,
46 and a merge box that says whether the branches actually merge before it offers a
47 button. Merge as a merge commit, a fast-forward or a squash, optionally deleting the
48 source branch afterwards; a merge fires the same webhooks a push does, and
49 `Closes #4` in the title or body closes issue 4 and says so on it.
50- **Webhooks** — a signed JSON POST per push, with a delivery log you can page through,
51 redeliver an attempt from, and switch a hook off in.
52- **Atom feeds** — a repository's commits and its issues, and the owner's push activity
53 across repositories, linked from the pages they belong to and autodiscovered.
54- **Every long list pages**, with `?page=N`, clamped to the nearest page that exists
55 rather than refused.
56- **A JSON API** — `/api/me`, `/api/users/{handle}`, `/api/users/{handle}/repos`. Not a
57 separate product; every use case gets a second surface where that makes sense, which is
58 what keeps the use-case layer honest.
59
60Writing (markdown posts), multi-user, organizations, code review and SSH transport are
61**not built yet**. The plan for them is in [`plans/ROADMAP.md`]plans/ROADMAP.md.
62
63## Requirements
64
65- Linux, x86_64 or aarch64, with systemd. The releases are built against glibc 2.31, so
66 Debian 11 and Ubuntu 20.04 or newer.
67- **`git` on `PATH`.** Not optional: Steid runs `git init --bare` to create a repository
68 and `git http-backend` to serve every clone and push. One `apt-get install git`.
69 **git 2.38 or newer to merge a pull request from the web** — that is when `git
70 merge-tree --write-tree` arrived, which is how a merge is computed without a working
71 tree; everything else works on any git, and where it is older the merge box says so
72 instead of offering a button. Debian 12 and Ubuntu 22.04 and newer are fine.
73- **A TLS-terminating reverse proxy, and a domain name for it.** Also not optional.
74 Steid speaks plain HTTP — the web framework it is built on (Topcoat 0.5) has no TLS
75 support at all: no rustls, no ACME, no HTTPS listener. And because git authenticates
76 with HTTP Basic, an instance served over plain HTTP leaks your access token to every
77 hop on the network, on every push. The installer sets Caddy up for you.
78- About 100 MB of disk before any repositories, plus whatever you push.
79
80## Install
81
82### One command
83
84```sh
85curl -fsSL https://REPLACE-ME.example.com/steid/install.sh | sh -s -- --domain git.example.com
86```
87
88Point the domain's DNS at the machine first, and make sure ports 80 and 443 are open —
89Caddy needs both to obtain a certificate.
90
91That does the following, and nothing else:
92
931. installs `git`, `curl` and `ca-certificates`
942. downloads the release tarball for your architecture and **verifies its SHA-256**
953. unpacks it to `/opt/steid` — the binary with its `assets/` directory beside it
964. creates a `steid` system user and `/var/lib/steid` for state, owned by it
975. writes `/etc/steid/steid.env`, and a systemd unit that listens on `127.0.0.1:3000`
986. installs Caddy and writes a Caddyfile that terminates TLS for your domain and proxies
99 to that loopback port
1007. starts both
101
102Re-run it with a newer `--version` to upgrade. It is idempotent: it replaces the binary
103and assets, leaves `/var/lib/steid` alone, and will not overwrite `/etc/steid/steid.env`
104once it exists.
105
106Options: `--version`, `--port`, `--flavour musl|gnu` (`gnu` is what is built), and
107`--no-caddy` if you are bringing your own proxy. `sh install.sh --help` lists them.
108
109**On piping a URL into a shell.** It is a real trust decision, and "it's convenient" is
110not an answer to it. Download and read it first if you would rather:
111
112```sh
113curl -fsSL https://REPLACE-ME.example.com/steid/install.sh -o install.sh
114less install.sh
115sudo sh install.sh --domain git.example.com
116```
117
118Or do it by hand — the manual path below is the same steps, written out.
119
120### Manually
121
122Every command as root, on Debian or Ubuntu. Adjust paths and package manager to taste;
123nothing here is specific to a distribution except `apt-get`.
124
125```sh
126# 1. Prerequisites. git is mandatory — Steid shells out to it for everything.
127apt-get update
128apt-get install -y git curl ca-certificates
129
130# 2. Fetch and verify the release for your architecture.
131VERSION=0.1.0
132TARGET=x86_64-unknown-linux-gnu # or aarch64-unknown-linux-gnu
133BASE=https://REPLACE-ME.example.com/steid/releases/download
134curl -fsSLO "$BASE/v$VERSION/steid-$VERSION-$TARGET.tar.gz"
135curl -fsSLO "$BASE/v$VERSION/steid-$VERSION-$TARGET.tar.gz.sha256"
136sha256sum -c "steid-$VERSION-$TARGET.tar.gz.sha256"
137tar -xzf "steid-$VERSION-$TARGET.tar.gz"
138
139# 3. Install. `assets/` MUST end up beside the binary: at startup Steid walks up
140# from its own executable looking for `assets/manifest.toml`, and exits if it
141# is not there. Moving the binary on its own gives you a program that will not
142# boot.
143mkdir -p /opt/steid
144cp "steid-$VERSION-$TARGET/steid" /opt/steid/steid
145cp -r "steid-$VERSION-$TARGET/assets" /opt/steid/assets
146chmod 755 /opt/steid/steid
147
148# 4. A user to run as, and one directory for all state.
149useradd --system --home-dir /var/lib/steid --shell /usr/sbin/nologin steid
150mkdir -p /var/lib/steid/repos
151chown -R steid:steid /var/lib/steid
152chmod 750 /var/lib/steid
153
154# 5. Configuration.
155mkdir -p /etc/steid
156cat > /etc/steid/steid.env <<'EOF'
157STEID_DATABASE_URL=sqlite:/var/lib/steid/steid.db?mode=rwc
158STEID_DATA_DIR=/var/lib/steid/repos
159HOST=127.0.0.1
160PORT=3000
161EOF
162chmod 640 /etc/steid/steid.env
163chown root:steid /etc/steid/steid.env
164
165# 6. The service. deploy/steid.service in this repo is the file to copy.
166cp deploy/steid.service /etc/systemd/system/steid.service
167systemctl daemon-reload
168systemctl enable --now steid
169
170# 7. The proxy. deploy/Caddyfile is a working starting point — change the
171# hostname on its first line to yours.
172apt-get install -y caddy # or follow https://caddyserver.com/docs/install
173cp deploy/Caddyfile /etc/caddy/Caddyfile
174$EDITOR /etc/caddy/Caddyfile
175systemctl reload caddy
176```
177
178There is **no migration step**. Steid runs its migrations itself on every boot.
179
180## First run: claiming the instance
181
182A fresh instance has no owner. On startup it prints a setup token to its log:
183
184```
185 This steid has no owner yet. Claim it at /auth/setup with:
186
187 <token>
188```
189
190Two things about that token that will bite you otherwise:
191
192- It is printed **only while the instance is unclaimed**. Once you have claimed it, it is
193 never shown again — because it no longer exists.
194- It lives **in memory only**. Every restart mints a new one, and the one in an older log
195 line is dead.
196
197So read it from the current run's journal:
198
199```sh
200journalctl -u steid --no-pager | tail -n 30
201```
202
203Then open `https://git.example.com/auth/setup`, paste it in, and choose your handle and
204password. After that, `/auth/login`.
205
206### Or set the token yourself
207
208If reading a log line during the first minute of a scripted install is awkward, set the
209token instead and skip the race:
210
211```sh
212STEID_SETUP_TOKEN=$(head -c 32 /dev/urandom | base64)
213```
214
215It is only consulted while the instance is unclaimed, it is never printed, and Steid
216**refuses to start** if it is weak — at least 32 characters, no whitespace, and at least
217eight distinct characters, so `abababab…` is rejected rather than accepted.
218
219## Using it
220
2211. Create a repository at `/{handle}/repos/new`. Public or private.
2222. Issue a personal access token at `/{handle}/settings/tokens`. It is shown once.
2233. Push:
224
225```sh
226git remote add origin https://git.example.com/me/repos/my-project.git
227git push -u origin main
228```
229
230Git will ask for a username and password. The token goes in the **password** field; the
231username is ignored (a token pasted as the username with an empty password also works,
232because people do that).
233
234You only type it once. Git's credential helper stores it and answers every later push —
235which is the whole reason pushing to GitHub feels like it needs no credentials. Use the
236one that keeps secrets in your operating system's keystore:
237
238```sh
239git config --global credential.helper osxkeychain # macOS (usually already set)
240git config --global credential.helper manager # Windows
241git config --global credential.helper libsecret # Linux
242```
243
244**Not `credential.helper store`.** It writes the token in clear text to
245`~/.git-credentials`, and a token is a password that never expires. Steid keeps only a
246hash of it precisely so that a stolen database contains nothing anyone can present;
247storing the plaintext on your laptop hands back what that was protecting.
248
249**Do not put the token in the remote URL** (`https://user:token@host/...`) either. It
250goes into `.git/config` in clear text and shows up in `git remote -v`, in shell history,
251and in any log that records the URL.
252
253Cloning a public repository needs no credentials at all.
254
255## Configuration
256
257Environment variables, read from `/etc/steid/steid.env` by the systemd unit.
258
259| Variable | Default | What it is |
260|---|---|---|
261| `STEID_DATABASE_URL` | `sqlite:steid.db?mode=rwc` | SQLite connection string. The directory must be writable, not just the file — SQLite writes `-wal` and `-shm` siblings. |
262| `STEID_DATA_DIR` | `./data` | Where bare repositories live, as `{data_dir}/{handle}/{name}.git`. |
263| `STEID_INSECURE_COOKIES` | unset (false) | **Never set this in production.** It strips `Secure` from the session cookie so it survives plain-HTTP localhost, and exists only for local development. |
264| `HOST` | `127.0.0.1` in the shipped unit | Bind address. Read by the framework, so deliberately *not* `STEID_`-prefixed. Keep it on loopback; the proxy is the way in. |
265| `PORT` | `3000` | Likewise not `STEID_`-prefixed. |
266
267Restart after editing: `systemctl restart steid`.
268
269## Backup and restore
270
271The entire backup surface is **two paths**:
272
273- `/var/lib/steid/steid.db` — the SQLite database (users, repositories, tokens, sessions)
274- `/var/lib/steid/repos` — the bare git repositories
275
276Which is to say: back up `/var/lib/steid`. `rsync` is enough.
277
278```sh
279systemctl stop steid
280rsync -a /var/lib/steid/ backup-host:/backups/steid/
281systemctl start steid
282```
283
284Stopping first is the honest version: SQLite in WAL mode leaves `-wal` and `-shm` files,
285and copying them while a write is in flight can capture a torn state. If you would rather
286not stop the service, snapshot the database properly and copy the repositories live —
287they are only written during a push:
288
289```sh
290sqlite3 /var/lib/steid/steid.db ".backup '/tmp/steid-backup.db'"
291rsync -a /tmp/steid-backup.db /var/lib/steid/repos backup-host:/backups/steid/
292```
293
294To restore: install Steid as above, stop it, drop both paths back into `/var/lib/steid`,
295`chown -R steid:steid /var/lib/steid`, start it. Migrations run on boot, so a database
296from an older version is brought forward automatically.
297
298## Building from source
299
300```sh
301cargo install topcoat-cli --version 0.5.0 --locked
302topcoat asset bundle --release
303```
304
305**`cargo build --release` on its own is not enough.** It produces a binary that will not
306boot: `AssetBundle::load()` walks up from the executable looking for
307`assets/manifest.toml`, and `build.rs` does not write one. `topcoat asset bundle` runs
308`cargo build` itself and then writes the bundle to `target/assets`. The binary at
309`target/release/steid` needs that directory beside it.
310
311Requires rustc ≥ 1.95 — Topcoat 0.5 demands it, and on an older toolchain `cargo add
312topcoat` silently resolves to an empty `v0.0.0` placeholder instead of failing.
313
314For development, `topcoat dev` does the bundling for you, and a local `.env` with
315`STEID_INSECURE_COOKIES=true` is needed for the session cookie to survive plain-HTTP
316localhost.
317
318### Cutting a release
319
320```sh
321./release.sh --target x86_64-unknown-linux-gnu
322```
323
324Produces `dist/steid-<version>-<target>.tar.gz` and a `.sha256` beside it. The tarball
325extracts to a self-contained directory: the binary, `assets/`, and this README. Building
326a Linux artefact on macOS needs a container (the script uses Docker) or a cross
327toolchain; `--native` builds for the host instead, which is useful for checking the
328artefact layout and not for releasing.
329
330A container image also exists — see [`Dockerfile`]Dockerfile — but the supported
331artefact is the plain binary.
332
333## Current limitations
334
335Deliberately blunt. Steid is early.
336
337- **Single user.** One account, claimed on first run. No registration, no invites, no
338 organizations yet. Issues exist, but only the owner may open or comment on one, which
339 is the same assumption showing.
340- **No TLS of its own.** A reverse proxy is mandatory, not recommended — see
341 [requirements]#requirements.
342- **No encryption at rest.** The database and repositories are plain files. Anyone with
343 the disk has everything. Token *values* are hashed, and passwords are Argon2, but
344 repository contents are not encrypted.
345- **Rate limiting covers `/auth/login`, `/auth/setup` and token authentication on the
346 git routes** — 10 attempts a minute per client for the first two, 60 for the third,
347 each with a global backstop. An anonymous clone of a public repository is not limited
348 at all, and neither is an archive download, which is the most expensive thing a
349 stranger can ask for.
350- **Rate limiting keys on forwarded headers, because Topcoat 0.5 does not expose the
351 peer address at all.** Behind a reverse proxy — the supported deployment — that works.
352 Exposed directly to the internet with no proxy, a caller can vary the header and get a
353 fresh budget each time, leaving only the global cap. Run it behind the proxy.
354- **Nothing sweeps expired tokens and nothing warns before one expires.** A token that
355 has expired authenticates exactly like one that never existed, and the tokens page is
356 where you find out.
357- **No CI/CD**, no code review, no SSH transport, no federation. Pull requests exist but
358 are bare: no assignees, reviewers or milestones, and only the owner may open or merge
359 one — the single-user assumption again.
360- **No writing yet** — posts and markdown are the next milestone, and they are the point
361 of the whole thing.
362- **Light mode is half-checked.** The repository landing page, a tree and a blob were
363 looked at and were fine; the profile, the settings pages and the log were not. Either
364 way there is no way for a visitor to choose — the layout is hardcoded dark.
365- **Not battle-tested.** It has not run under load, has not been audited, and has been
366 deployed by approximately one person. Do not put anything irreplaceable in it that is
367 not also somewhere else.
368
369More, in unflattering detail, in [`plans/current.md`]plans/current.md.
370
371## Project layout
372
373`plans/` is the source of truth for intent, not the code:
374
375| File | Holds |
376|---|---|
377| [`plans/ROADMAP.md`]plans/ROADMAP.md | vision, stack, the milestone ladder |
378| [`plans/current.md`]plans/current.md | the active milestone, and every known gap |
379| [`plans/progress.md`]plans/progress.md | what shipped, and the decisions worth not rediscovering |
380| [`plans/architecture.md`]plans/architecture.md | layer rules and conventions |
381| [`plans/decisions/`]plans/decisions/ | ADRs |
382
383The code is a single crate in three layers — `domain`, `application`, `infrastructure` —
384with dependencies pointing inward. Every use case takes an `Actor` and authorizes before
385any side effect.
386
387## Licence
388
389Copyright (C) 2026 James Gill.
390
391Steid is free software under the **GNU Affero General Public License v3.0** — see
392[LICENSE]LICENSE. You may use, modify and redistribute it, including commercially.
393
394The reason for AGPL rather than a permissive licence is section 13: if you modify Steid
395and offer it to others **over a network**, you must make your modified source available
396to those users. Running an unmodified copy — which is what self-hosting is — carries no
397such obligation. In other words: host it for yourself freely, fork it privately for
398yourself freely, but a modified public service has to share what it changed.
399
400Worth being straightforward about what this does *not* do: it does not stop anyone
401running Steid as a commercial hosted service. AGPL is a copyleft licence, not a
402non-compete.
403