The stack for portal 1.0: a store of its own, gdo and kron dialling the site

Portal 1.0 keeps everything in one file (portal_data) and has no NATS.
gdo and kron dial it over dhd/1 from loopback, so the three share one
network namespace, held by a container of its own: held by portal, a
restart of portal cut the other two off. NATS stays behind a profile
nothing turns on, for going back; the chat (cnats) is out.

The deploy writes DHD_KEYS and the hash of LOAD_TOKEN, and no NATS or
chat settings. gdo is built from uhhm/gdo at GDO_RELEASE, since the gdo
that dials a site is not in the registry. move.sh reads the programs'
keys and prints what the deploy wants.

Run on kasse beside the live stack, on other ports, with made-up
records: mail out, a payment settled, content loaded over /dhd/1/load,
and both programs back after portal was restarted and made anew.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDjTQg4CJsNqEo7hhE7
This commit is contained in:
blandClaude committed 2026-11-24 12:40:41 +01:00
1 parent d1106dc1b8
commit 1f37681696
8 files changed
+368 -260

No files matched your search

+113 -91
View File
@@ -1,10 +1,13 @@
# Tomter Vel's own platform: portal + its own Rauthy and NATS as podman
# containers. The content (pages, forms, desks) is not here: portal fetches
# it from tomtervel/questions on prosjekt.klingenbergbygg.no and hot-reloads
# it over NATS. This repo owns identity, the bus, and which portal version
# runs. TLS depends on where it runs: on a standalone host the bundled Caddy
# (`--profile edge`) terminates it; on kasse the host Caddy already owns
# 80/443 and reverse-proxies vel.klingenbergbygg.no -> portal (127.0.0.1:3050).
# Tomter Vel's own platform: portal, its own Rauthy, and the programs
# beside the site (gdo for mail, kron for Vipps) as podman containers.
# The content (pages, forms, desks) is not here: portal fetches it from
# tomtervel/questions on prosjekt.klingenbergbygg.no, at start and when
# that repo's CI asks it to (POST /dhd/1/load). This repo owns identity,
# which portal version runs, and where the site keeps what is its own:
# one file, in the volume portal_data. TLS depends on where it runs: on a
# standalone host the bundled Caddy (`--profile edge`) terminates it; on
# kasse the host Caddy already owns 80/443 and reverse-proxies
# tomtervel.no -> portal (127.0.0.1:3050).
#
# Everything it runs with is an Actions variable or secret, written by
# the deploy workflow (README.md); `podman compose up -d --build` is
@@ -36,30 +39,27 @@ services:
- portal
- rauthy
# The NATS portal 0.19 kept everything on. Nothing of the 1.0 stack
# reads it: it is here, behind a profile nothing turns on, so its
# container and its volume (nats_data) stay as they are for as long as
# going back to 0.19 should be possible (move-1.0/README.md). Take it
# out, and the volume, once it is not.
nats:
profiles: ["nats-0-19"]
image: nats:2.14.6-alpine
restart: unless-stopped
command: ["-c", "/etc/nats/nats.conf"]
# NATS_PASSWORD, which nats.conf reads from the environment.
env_file: nats.env
env_file:
- path: nats.env
required: false
volumes:
- ./nats/nats.conf:/etc/nats/nats.conf:ro
- nats_data:/data
# Published on the host so the reload job (`nats pub portal.content.reload ""`)
# can reach it; password-protected (see nats.conf). Host port 4223, not 4222:
# on kasse the shared platform NATS already owns 127.0.0.1:4222 and the vel
# runs its own NATS in isolation, so the reload workflow targets 4223 there.
# (Standalone, nothing else owns 4222, but 4223 is harmless.)
ports:
- "127.0.0.1:4223:4222"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
interval: 10s
timeout: 5s
retries: 3
# Rauthy: who is who. Sign-in, account pages and account mail, in
# Norwegian; portal and the chat sign in here (OIDC_ISSUER) and portal
# Norwegian; portal signs in here (OIDC_ISSUER) and portal
# makes accounts here (RAUTHY_API_KEY). Its database is embedded
# (hiqlite), in rauthy_data. Host-published for kasse's host Caddy
# (RAUTHY_HOST -> here).
@@ -82,6 +82,36 @@ services:
ports:
- "127.0.0.1:8090:8080"
# The network the site and the programs beside it share. gdo and kron
# dial the site from loopback to loopback (DHD_BIND, 127.0.0.1:4300
# unless set), so the three must be in one network namespace, and it
# must outlive each of them: held by portal itself, a restart of portal
# left gdo and kron in the namespace it had, cut off, until they were
# made anew. This container does nothing but hold it. What any of the
# three needs of the network is said here: the published ports, the
# way to the host's mail server, and the name `portal` on the project's
# network.
net:
image: docker.io/library/alpine:3.22
restart: unless-stopped
command: ["sleep", "infinity"]
# sleep as the first process hears no SIGTERM.
stop_signal: SIGKILL
extra_hosts:
- "host.containers.internal:host-gateway"
networks:
default:
aliases:
- portal
ports:
# Host-published for kasse's host Caddy (tomtervel.no -> portal).
# With --profile edge the bundled Caddy proxies portal:3000
# internally instead, but publishing loopback-only is harmless
# there.
- "127.0.0.1:3050:3000"
# kron (betaling.tomtervel.no -> here).
- "127.0.0.1:3080:3080"
portal:
build:
context: ./portal
@@ -100,117 +130,107 @@ services:
LEPTOS_HASH_FILES: "true"
LEARN_CACHE: /app/learn-cache
OLLAMA_HOST: http://100.64.0.1:11434
# The namespace of everything this site keeps on NATS from portal 0.9.
# Must not change: a new name is a new, empty site.
# What the site calls itself to the programs beside it. Must not
# change: kron and the mail name the site by it.
SITE_NAME: tomtervel
# Everything the site keeps: its records and their history, the
# mail and payments that wait, the sessions. One file, opened by
# this container alone; site.key beside it is the site's key on
# dhd/1. A new volume is a new, empty site.
PORTAL_STORE: /data/site.redb
volumes:
- learn_cache:/app/learn-cache
ports:
# Host-published for kasse's host Caddy (vel.klingenbergbygg.no -> here).
# With --profile edge the bundled Caddy proxies portal:3000 internally
# instead, but publishing loopback-only is harmless there.
- "127.0.0.1:3050:3000"
- portal_data:/data
network_mode: "service:net"
depends_on:
nats:
condition: service_healthy
net:
condition: service_started
rauthy:
condition: service_started
# The mailer. Portal decides what to send - a `mail:` on a state in the
# content, or an invite - and publishes it on this NATS; gdo is what
# actually hands it to a mail server. It is in the vel's own stack rather
# than shared, so the vel's mail leaves on the vel's own terms, but 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. That is the one thing
# here the vel borrows.
# content, or an invite - and keeps it in its own `mail` outbox; gdo
# dials the site over dhd/1 (PORTAL_DHD), is handed what waits there,
# and hands each to a mail server. It has none of its own: it relays
# through the host's, which on kasse is Klingenberg Bygg's postfix on
# port 25. That is the one thing here the vel borrows.
#
# The site must name gdo's key in DHD_KEYS as `<key>=mail,note`; gdo
# says the key as it starts, and move-1.0/move.sh reads it out.
gdo:
build:
context: ./gdo
args:
GDO_RELEASE: ${GDO_RELEASE}
# Named, so move-1.0/move.sh can start it once to read its key.
image: localhost/tomtervel-gdo:${GDO_RELEASE}
restart: unless-stopped
# NATS_URL, with the password: made by bootstrap.sh, never committed.
env_file: nats.env
network_mode: "service:net"
environment:
# The host, from inside the container. Podman resolves this to the
# gateway; the host's postfix listens on 0.0.0.0:25.
PORTAL_DHD: ${PORTAL_DHD:-}
# Its key on dhd/1, kept across rebuilds: a new key is one the
# site does not know.
GDO_KEY: /var/lib/gdo/gdo.key
# Set, so gdo sends through it and asks the site's owners for
# nothing. The host, from inside the container: podman resolves
# this to the gateway (extra_hosts on net); the host's postfix
# listens on 0.0.0.0:25.
SMTP_HOST: host.containers.internal
SMTP_PORT: "25"
# A strict server refuses a bare container hostname in EHLO.
SMTP_HELO: ${PORTAL_HOST}
extra_hosts:
- "host.containers.internal:host-gateway"
volumes:
- gdo_data:/var/lib/gdo
depends_on:
nats:
condition: service_healthy
- portal
# The money service (uhhm/kron): portal asks for a payment on this
# NATS as a household owes its fee, kron gives it a link to pay by,
# talks to Vipps's ePayment API for the Medlemskap sales unit, and
# says `paid` back on the same bus. Vipps's keys are in kron.env and
# nowhere else; portal never calls Vipps. Host-published for kasse's
# host Caddy (betaling.tomtervel.no -> here): the pay links, the page
# people come back to from Vipps, and Vipps's webhooks. A profile, since
# it needs kron.env: COMPOSE_PROFILES gains `pay` once the keys are set.
# The money service (uhhm/kron): a household that owes its fee waits
# in portal's `payments` outbox; kron dials the site over dhd/1, takes
# the request, gives it a link to pay by, talks to Vipps's ePayment API
# for the Medlemskap sales unit, and tells the site `paid` as a move on
# the payment. Vipps's keys are in kron.env and nowhere else; portal
# never calls Vipps. Its ledger is a file of its own in kron_data.
# Reached by kasse's host Caddy on the published 3080
# (betaling.tomtervel.no): the pay links, the page people come back to
# from Vipps, and Vipps's webhooks. A profile, since it needs kron.env:
# COMPOSE_PROFILES has `pay` once the keys are set.
#
# The site must name kron's key in DHD_KEYS as `<key>=payments`.
kron:
profiles: ["pay"]
image: project.uhhm.no/uhhm/kron:${KRON_RELEASE:-no-tag-set}
restart: unless-stopped
network_mode: "service:net"
env_file:
- nats.env
- kron.env
environment:
PORTAL_DHD: ${PORTAL_DHD:-}
# Must be the portal's own: a request names its site.
SITE_NAME: tomtervel
PROVIDER: vipps
VIPPS_ENV: prod
PUBLIC_URL: https://${PAY_HOST:-no-host-set}
LISTEN_ADDR: 0.0.0.0:3000
# kron's own identity, made on first start: what the Vipps keys
# given through portal (the treasurer's "Tjenester som venter")
# are sealed to. On its own volume, never copied anywhere. With
# no VIPPS_* in kron.env, kron waits to be given them.
# 3080, not 3000: in the shared network 3000 is portal's.
LISTEN_ADDR: 0.0.0.0:3080
# Its key on dhd/1 and, beside it, its ledger (kron.redb).
KRON_KEY: /var/lib/kron/kron.key
# With the four VIPPS_* in kron.env kron asks the site for
# nothing, and this identity is not used.
KRON_IDENTITY_FILE: /var/lib/kron/identity
KRON_LANG: nb
volumes:
- kron_data:/var/lib/kron
ports:
- "127.0.0.1:3080:3000"
depends_on:
nats:
condition: service_healthy
- portal
# The Gitea Actions runner is a host service on kasse (pacman gitea-runner),
# registered against prosjekt.klingenbergbygg.no. It reaches this NATS via the
# published 127.0.0.1:4222 port above, so no in-compose runner — and no
# docker.sock/podman.sock mount — is needed here.
# The Gitea Actions runner is a host service on kasse (pacman
# gitea-runner), registered against prosjekt.klingenbergbygg.no. The
# content repo's reload reaches the site over HTTPS, so no in-compose
# runner - and no docker.sock/podman.sock mount - is needed here.
# The vel's conversations: every group the content names is a room,
# portal speaks in them and decides who gets in. Its history is on the
# vel's own NATS (stream tomtervel_CHAT); there is no Postgres. A
# profile, since it needs chat.env: go-live sets COMPOSE_PROFILES=chat
# in .env once it is there. Host-published for kasse's host Caddy
# (chat.vel.klingenbergbygg.no -> here).
cnats:
profiles: ["chat"]
image: docker.io/bendik/cnats:${CNATS_TAG:-no-tag-set}
restart: unless-stopped
env_file:
- nats.env
- path: chat.env
required: false
environment:
# Must be the portal's own: a new name is a new, empty chat.
SITE_NAME: tomtervel
# Rauthy: https://<RAUTHY_HOST>/auth/v1/
OIDC_ISSUER: ${OIDC_ISSUER}
PUBLIC_URL: https://${CHAT_HOST}
COOKIE_SECURE: "true"
ports:
- "127.0.0.1:3070:3000"
depends_on:
nats:
condition: service_healthy
# The vel's conversations are not in this stack for now: the chat that
# ran here (cnats) spoke to portal over NATS, and the one that dials a
# 1.0 site (uhhm/kino) is not published as an image yet.
# Where uploads go: the pictures and documents a desk attaches, and what
# `portal import` brings in. One node on this host, reachable only inside
@@ -226,6 +246,8 @@ services:
volumes:
garage_data:
portal_data:
gdo_data:
kron_data:
caddy_data:
caddy_config: