# Tomter Vel — infrastructure Everything the vel's own site needs on one host, as containers: portal, the site itself, which keeps its records in one file of its own; Rauthy for who is who; gdo for its mail and kron for Vipps. The content (pages, forms, desks) lives in [tomtervel/questions](https://prosjekt.klingenbergbygg.no/tomtervel/questions) and is fetched from there; this repo owns the host. ``` Internet ──► Caddy (Let's Encrypt) ├── PORTAL_HOST ──► portal:3000 ──► its store (portal_data) + Rauthy (login) ├── RAUTHY_HOST ──► rauthy:8080 ▲ dhd/1, on loopback └── PAY_HOST ─────► kron:3080 ───────────┤ gdo ─────────────────┘──► the host's mail server ``` Nothing about the vel's members or records depends on anyone else's host: the login and the site are the vel's own. The site ran portal 0.19 on NATS until the move to 1.0, which `move-1.0/` is. The chat (cnats) spoke to portal over NATS and went with it; the one that dials a 1.0 site (uhhm/kino) has no image yet. ## First start On a fresh Linux host with podman + podman-compose (run rootful, so Caddy can bind 80/443 and Rauthy sees a stable source IP), with a Gitea runner on it, and the variables and secrets below set (`LOAD_TOKEN` is any long random string: `openssl rand -hex 24`; Rauthy's are under [Rauthy](#rauthy); the keys are under [The site's own network](#the-sites-own-network)): ```sh git clone https://prosjekt.klingenbergbygg.no/tomtervel/infrastructure /srv/tomtervel/infrastructure sudo install -m 0755 /srv/tomtervel/infrastructure/deploy-tomtervel /usr/local/bin/deploy-tomtervel # and the sudoers line in it # Actions -> deploy -> Run workflow # the env files, and the stack up ``` Then make the clients and portal's API key in Rauthy ([Rauthy](#rauthy)). ## Running on kasse (behind the host Caddy) On kasse the host Caddy already owns 80/443, so the bundled Caddy stays off (`profiles: [edge]`). The services publish loopback-only ports for it, and `host-caddy/tomtervel.no` is its file for them (`/etc/caddy/conf.d/tomtervel.no`): - portal → `127.0.0.1:3050` - kron → `127.0.0.1:3080` - rauthy → `127.0.0.1:8090` ## Accounts and groups Rauthy holds the accounts: sign-in, passkeys, the account pages and the account mail, in Norwegian. Portal signs in there (`OIDC_ISSUER`), and portal makes the accounts there itself (`RAUTHY_API_KEY`): - **The first person in.** The `SEED_ADMIN_EMAIL` secret: at start, portal gives them the most privileged group (the board) and makes their account; Rauthy mails them how to set a password or a passkey. The same address is Rauthy's first admin. - **Everyone else** is invited from a desk, or given a place by a case (`grants:`). Portal makes the account if there is none, and Rauthy mails the way in. - **The people who ask the questions.** Everyone a page names as `responsible` gets an account at start and a place in `RESPONSIBLE_GROUP` (`redaktor`). The groups are kept in Rauthy (`PEOPLE_BACKEND=rauthy`): an invite puts the person in the group there, and an invite is a case in `portal_invites` until they come. Who is in `styret` is on the board's desk, "Medlemmer og invitasjoner", where a person is taken out or invited again. Portal decides what a group may do, on the site and in the chat's rooms alike. Records in `portal_memberships` are left from before (Kanidm); nothing new is written there. ## Content changes A push to tomtervel/questions is linted, and its CI then asks the site to load that commit: `POST https:///dhd/1/load` with the org secret `LOAD_TOKEN`. The site fetches the commit, checks it whole and swaps it in; if anything fails, the last good content goes on serving, and the answer says why. The site is given the token's hash alone (`DHD_TOKENS`, written by the deploy). It also reads the branch's head every time it starts. ## The site's own network gdo and kron dial the site over `dhd/1`; the site dials no one. They know each other by key: - **The site's key** is `site.key` beside its store, made the first time a program is named. gdo and kron are told it, and where the site listens, as `PORTAL_DHD=@127.0.0.1:4300`. - **Each program's key** is in its own volume (`gdo_data`, `kron_data`), made the first time it starts. The site names them, and what each may do, in `DHD_KEYS==mail,note;=payments`. Both are Actions variables (public keys; every start says them in the log). `move-1.0/move.sh` makes the keys and prints the two values. A program whose volume is lost gets a new key, which the site does not know until `DHD_KEYS` names it: read it from the program's log. They dial from loopback to loopback, so portal, gdo and kron share one network namespace, which the `net` container holds (`compose.yml` says why it is not portal's own). Tried on kasse, 2026-11-24: after a restart of portal, and after it was made anew, gdo and kron dialled again within half a minute and the mail and the payment that had waited went through. ## Upgrading portal Set the org variable `PORTAL_RELEASE` (a tag of uhhm/portal) and run the deploy workflow. The content repo's lint reads the same variable, so the two cannot drift apart. ## Variables and secrets Every value the stack runs with is an Actions variable or secret in Gitea, never a file in the repo (it is public) and never edited on the host. The deploy workflow writes them into the env files on kasse (`.env`, `portal.env`, `kron.env`, `rauthy.env`) on every run, so a host name or a version is changed in Gitea, and then **Actions -> deploy -> Run workflow**. Set them with `gt` (`gt variable set NAME --body ...`, `gt secret set NAME`, `-o tomtervel` for the org's). | name | kind | where | what | |---|---|---|---| | `PORTAL_HOST`, `RAUTHY_HOST` | variable | repo | the site, the login; each needs DNS (`dns/`) and a kasse Caddy block | | `PORTAL_RELEASE` | variable | **org** | a uhhm/portal tag; the content repo's lint reads the same one | | `GDO_RELEASE`, `KRON_RELEASE` | variable | repo | the mailer's version as the [uhhm] registry has it (`v0.4.0` and on; the build fails when the registry's is another), and the money service's image tag (`0.3.0` and on): the ones that dial a 1.0 site | | `COMPOSE_PROFILES` | variable | repo | `pay` | | `DHD_KEYS`, `PORTAL_DHD` | variable | repo | the programs' keys and what each may do, and the site's key and address ([The site's own network](#the-sites-own-network)) | | `PORTAL_BACKUP_TO`, `GARAGE_BACKUPS_BUCKET` | variable | repo | optional: an age public key and a bucket, for sealed copies of the store ([Backups](#backups)) | | `CONTENT_REPO`, `CONTENT_BRANCH` | variable | repo | the content this site serves | | `SITE_NAME` | variable | repo | `tomtervel`; never changed (kron and the mail name the site by it) | | `PEOPLE_BACKEND`, `RESPONSIBLE_GROUP` | variable | repo | `rauthy`, `redaktor` | | `OAUTH2_CLIENT_ID` | variable | repo | the site's Rauthy client: `portal` | | `GARAGE_S3_ENDPOINT`, `GARAGE_UPLOADS_BUCKET` | variable | repo | uploads | | `LOAD_TOKEN` | secret | **org** | what the content repo's reload posts to the site; the site gets its hash | | `OAUTH2_CLIENT_SECRET` | secret | repo | the site's Rauthy client | | `GARAGE_ACCESS_KEY`, `GARAGE_SECRET_KEY` | secret | repo | uploads | | `SEED_ADMIN_EMAIL`, `SEED_ADMIN_NAME` | secret | repo | the first person in; an address, so not a variable | | `CLOUDFLARE_API_TOKEN` | secret | repo | DNS edit for tomtervel.no only (`dns/`) | | `MAPBOX_TOKEN` | secret | repo | optional: the map tiles portal proxies (the landing hero, location fields); unset, maps are off | | `MAPBOX_STYLE` | variable | repo | optional: `/