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 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; the keys are under The site's own network):
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).
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_EMAILsecret: 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
responsiblegets an account at start and a place inRESPONSIBLE_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://<PORTAL_HOST>/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.keybeside its store, made the first time a program is named. gdo and kron are told it, and where the site listens, asPORTAL_DHD=<site key>@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, inDHD_KEYS=<gdo's key>=mail,note;<kron's key>=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, a tag or a commit of uhhm/gdo that the image is built from (gdo/Dockerfile says why), 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) |
PORTAL_BACKUP_TO, GARAGE_BACKUPS_BUCKET |
variable | repo | optional: an age public key and a bucket, for sealed copies of the store (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: <owner>/<style>; unset, mapbox/streets-v12 |
DNSCONTROL_VERSION |
variable | repo | the DNS workflow's dnscontrol |
RAUTHY_ENC_KEY, RAUTHY_SECRET_RAFT, RAUTHY_SECRET_API |
secret | repo | Rauthy's own: made once, never changed (the key encrypts its database) |
OIDC_ISSUER |
variable | repo | where the site signs in: https://konto.tomtervel.no/auth/v1/ |
RAUTHY_BOOTSTRAP_API_KEY, RAUTHY_BOOTSTRAP_API_KEY_SECRET |
secret | repo | optional, Rauthy's first start only: a short-lived key (base64 of {"name","exp","access"}, secret 64+ alphanumerics) that makes the OIDC clients through the API; read into an empty database, ignored after |
RAUTHY_API_KEY, RAUTHY_LANGUAGE |
secret, variable | repo | portal makes accounts in Rauthy (<name>$<secret>, made in Rauthy's admin), in nb |
VIPPS_LOGIN_CLIENT_ID, VIPPS_LOGIN_CLIENT_SECRET |
variable, secret | repo | Vipps Login (the login sales unit's keys from portal.vippsmobilepay.no): the deploy keeps Vipps as a sign-in provider in Rauthy with them (rauthy-providers.sh) |
PAY_HOST |
variable | repo | where the money service answers: betaling.tomtervel.no (DNS in dns/, a kasse Caddy block) |
VIPPS_MSN |
variable | repo | the Medlemskap sales unit's merchant serial number, 1192072 |
VIPPS_CLIENT_ID, VIPPS_CLIENT_SECRET, VIPPS_SUBSCRIPTION_KEY |
secret | repo | the Medlemskap sales unit's ePayment keys (For developers, API keys, production), read by kron alone. With all four set kron asks the site for nothing |
VIPPS_WEBHOOK_SECRET |
secret | repo | what Vipps signs its webhooks with, from vipps-webhook.sh register; unset, kron refuses webhooks and asks Vipps about each open payment every minute instead |
A variable is printed wherever a workflow echoes it, and this repo's run logs are public: a value that must not be read is a secret.
What is not a value stays on the host, made there once: Garage's node secret.
Colours in Rauthy
rauthy-theme.sh puts the site's palette (custom.css in the content
repo) on Rauthy's sign-in, account and admin pages, for Rauthy's own
client and the portal's, on every deploy. It needs the portal API key to
have Clients read and update; until it does, the step says so and
changes nothing, and the theme can be set by hand in the admin
(Clients, the client, Branding).
Payments
The money service is kron, in the
stack under the pay profile (COMPOSE_PROFILES=pay). Portal
decides when money is owed: a household entering open or fornyes in
the content's aggregates owes the fee, and the request waits in the
site's payments outbox. kron dials the site, takes it, and answers
with a link of its own,
https://betaling.tomtervel.no/pay/<reference>, which portal shows on
the person's own page and mails; opening it makes a Vipps payment for
the Medlemskap sales unit and sends the person into Vipps, and a fresh
one each time the last ran out (Vipps's own expire after ten minutes).
Once they have paid, kron captures the reserved amount and tells the
site paid; portal moves the household to betalt, grants
medlemmer, and mails them. Vipps's keys live in kron.env: with all
four set kron asks the site for nothing. (kron can ask the site's
owners for them instead; that way is not tried here.) Portal never
holds a value and never calls Vipps. kron's ledger of what is being
paid is kron.redb in the kron_data volume. PAY_URL in
portal.env is what lets the content leave by_hand: true out of a
payment:; portal never calls that address either.
Going live, in order:
- Set
PAY_HOST, and the keys:VIPPS_MSNand the three key secrets (table above; inpassastomtervel/vipps/medlemskap). The host script must knowkron.env(this repo'sdeploy-tomtervel, optional files): on kasse,sudo install -m 0755 -o root -g root /srv/tomtervel/infrastructure/deploy-tomtervel /usr/local/bin/deploy-tomtervelafter the pull, since the installed copy does not update itself. - Merge the DNS record (
dns/dnsconfig.js,betaling) and run the DNS workflow; add thebetaling.tomtervel.noblock fromhost-caddy/tomtervel.noto kasse's Caddy. - Set
COMPOSE_PROFILES=payandKRON_RELEASE(a uhhm/kron version,0.1.0: the image is project.uhhm.no/uhhm/kron), then Run workflow.https://betaling.tomtervel.no/healthzanswersok. - Register the webhook:
./vipps-webhook.sh registeron a machine withpass(it puts the secret in pass), thengt secret set VIPPS_WEBHOOK_SECRETas it says, and Run workflow once more. Until then kron settles by polling, a minute behind. - Drop
by_hand: truefrom the content'spayment:states (the content repo's lint readsPAY_URLthe same way).
Nothing here touches the Vippsnummer (500396): people may keep paying there, and the treasurer marks those by hand as before.
Rauthy
Rauthy at RAUTHY_HOST
(konto.tomtervel.no): sign-in, passkeys, account pages and account
mail, in Norwegian (nb) and English. A passkey belongs to the name it
was made on, so RAUTHY_HOST stays: a new name means new passkeys for
everyone.
On a new host:
- The secrets, made once and never changed (the key encrypts its
database):
Optionally a short-lived key for making the clients through the API (
echo "$(openssl rand -hex 4)/$(openssl rand -base64 32)" | gt secret set RAUTHY_ENC_KEY -R tomtervel/infrastructure openssl rand -hex 24 | gt secret set RAUTHY_SECRET_RAFT -R tomtervel/infrastructure openssl rand -hex 24 | gt secret set RAUTHY_SECRET_API -R tomtervel/infrastructureRAUTHY_BOOTSTRAP_API_KEY, see the table), read on the first start only. - Deploy. The first admin is
SEED_ADMIN_EMAIL; its password is in the log once:podman compose logs rauthy | grep -A2 -i password. Signed in, it sets up a passkey. - In Rauthy's admin (
https://konto.tomtervel.no/auth/v1/admin), or with the bootstrap key: the clientportal(authorization_code,S256, scopesopenid profile email groups, redirecthttps://tomtervel.no/auth/callback; withoutgroupsRauthy leaves the groups out of the sign-in, and portal sees everyone in none: no board, no committee) andchat(alsorefresh_token, redirecthttps://samtaler.tomtervel.no/auth/callback), their secrets intoOAUTH2_CLIENT_SECRETandCHAT_OAUTH2_CLIENT_SECRET, and an API keyportalwith read, create and update on users, groups, roles and auth providers intoRAUTHY_API_KEY(a committee's leaders get a role that goes with managing it). A key Rauthy no longer knows, or one past its expiry, answers 401 to everything, and every invite fails ("the account could not be made just now";rauthy: reading the groups: http 401in the log).
Rauthy's mail leaves through kasse's postfix like gdo's, and Rauthy stops if it cannot reach it.
Previews
Every content branch pushed to tomtervel/questions gets its own preview
before it is merged, on https://<branch>.forhandsvisning.tomtervel.no,
for five days after its last push; forhandsvisning.tomtervel.no lists
the ones there are. The content repo runs them
(.gitea/preview/preview.sh, from lint-and-reload once the lint
passes): a container tomtervel-preview-<branch> from this site's own
image (localhost/tomtervel-portal:<PORTAL_RELEASE>), beside a throwaway
NATS (tomtervel-preview-nats) where each branch has a SITE_NAME of its
own, and a small Caddy, tomtervel-preview-router on 127.0.0.1:3066, that
picks the container by the name asked for. At most five run at once; the
one that expires first goes when a sixth arrives. The content repo's
preview-cleanup workflow removes them when they expire (hourly) and when
their branch is deleted.
A preview has no gdo, so nothing mails anyone, and no sign-in, so desks stay shut and the public pages show. A form sent on it lands in the throwaway NATS and nowhere else. The commit gets a "forhåndsvisning" status with the link, which a PR shows among its checks. Main is never previewed: it is the site.
On kasse this needs the DNS records in dns/dnsconfig.js (the bare name
and *.forhandsvisning), the two blocks in host-caddy/tomtervel.no, and
the on_demand_tls global option described there, in
/etc/caddy/Caddyfile.
Backups
- The site's store is one file,
site.redbin theportal_datavolume: every record and its history, the mail and payments that wait, the sessions. WithPORTAL_BACKUP_TO(an age public key, made withage-keygenon a machine that is not this host; the private half never comes here) andGARAGE_BACKUPS_BUCKET(a bucket the site's garage key may write), the site seals a copy of it every six hours and keeps the newest fourteen. Neither is set yet: until they are, the volume is the only copy. To restore, stop the site and put the opened copy in the store's place (age -d -i backup-key.txt <copy>.redb.age > site.redb). - Rauthy's database is the
rauthy_datavolume: the accounts, passkeys and clients. Snapshot the volume. - kron's ledger is the
kron_datavolume; gdo's key thegdo_dataone. A lost key is a new one named inDHD_KEYS. - The uploads are the
garage_datavolume. nats_datais what portal 0.19 kept: it stays until going back is no longer wanted (move-1.0/README.md).- Caddy's certificates regenerate; nothing to keep.
What is not here
Mail (a person's reset link is a token you hand them), monitoring, and the vel's current website at tomtervel.no, which stays where it is until the vel points the apex at PORTAL_HOST.
DNS
tomtervel.no's records are dns/dnsconfig.js, applied to Cloudflare
with DNSControl: the site, the login and the chat pointing here, Zoho's
mail, and SPF, DKIM and DMARC for the mail the site sends. How to run
it, the token it needs, and the order of a move are in
dns/README.md.
Portal decides what to send - a mail: on a state in the content, or an
invite - and keeps it in its mail outbox. gdo dials the site, is
handed what waits there, and hands it to a mail server, and it runs here, in the vel's own stack, so the vel's mail
leaves on the vel's own terms.
It has no mail server of its own. It relays through the host's, which on
kasse is Klingenberg Bygg's postfix on port 25, reached from the container
as host.containers.internal. That is the one thing in this stack the vel
borrows, and the one thing that changes if the vel ever moves to a host of
its own: point SMTP_HOST at whatever that host runs.
site.yaml in the content repo needs a mail.from, or portal has nothing
to send from and says so in its log.
Replies are not read yet: JMAP_URL, JMAP_TOKEN and MAIL_REPLY_DOMAIN
turn a reply into a note on the record it answers, and none of them are set
here.
Mail leaving the host
gdo hands the vel's mail to kasse's own postfix over the container
network, so postfix has to be willing to relay from it: mynetworks
on kasse includes 172.16.0.0/12 and 10.88.0.0/16 (set 2026-09-30,
the original is in /etc/postfix/main.cf.before-containers). Without
it every address outside the host's own domains is refused with
"Relay access denied", and gdo retries a minute apart until it is.
Uploads
Pictures and documents a desk attaches, and what portal import brings
in, go to Garage in this project. go-live.sh garage renders
garage/garage.toml with this node's own rpc secret (gitignored), makes
the bucket tomtervel-attachments and the key tomtervel-portal-uploads,
and puts GARAGE_S3_ENDPOINT, GARAGE_ACCESS_KEY, GARAGE_SECRET_KEY and
GARAGE_UPLOADS_BUCKET in portal.env. Without them an upload field
fails closed. Nothing of Garage is published on the host.