wip: the stack for portal 1.0

This commit is contained in:
bl committed 2026-11-24 12:30:21 +01:00
1 parent d1106dc1b8
commit c0114ae323
6 files changed
+187 -137

No files matched your search

+37 -38
View File
@@ -2,7 +2,8 @@
# Actions variable (vars.*: hosts, versions, where the content comes from) # Actions variable (vars.*: hosts, versions, where the content comes from)
# or secret (secrets.*: passwords, tokens, the first person's address) of # or secret (secrets.*: passwords, tokens, the first person's address) of
# this repo, or of the tomtervel org for what other repos share # this repo, or of the tomtervel org for what other repos share
# (NATS_PASSWORD, which the content repo's reload uses too). The table is # (LOAD_TOKEN, which the content repo's reload posts to the site, and
# PORTAL_RELEASE, which its lint runs). The table is
# in README.md. A new host name or a portal bump is a variable changed and # in README.md. A new host name or a portal bump is a variable changed and
# then Run workflow; a change to the files here deploys on push. # then Run workflow; a change to the files here deploys on push.
# #
@@ -21,7 +22,6 @@ on:
- gdo/** - gdo/**
- rauthy-providers.sh - rauthy-providers.sh
- rauthy-theme.sh - rauthy-theme.sh
- nats/nats.conf
- rauthy/config.toml - rauthy/config.toml
- deploy-tomtervel - deploy-tomtervel
- .gitea/workflows/deploy.yml - .gitea/workflows/deploy.yml
@@ -35,11 +35,9 @@ jobs:
STAGE: /var/lib/gitea-runner/tomtervel-env STAGE: /var/lib/gitea-runner/tomtervel-env
# What the stack is. # What the stack is.
PORTAL_HOST: ${{ vars.PORTAL_HOST }} PORTAL_HOST: ${{ vars.PORTAL_HOST }}
CHAT_HOST: ${{ vars.CHAT_HOST }}
PAY_HOST: ${{ vars.PAY_HOST }} PAY_HOST: ${{ vars.PAY_HOST }}
PORTAL_RELEASE: ${{ vars.PORTAL_RELEASE }} PORTAL_RELEASE: ${{ vars.PORTAL_RELEASE }}
GDO_RELEASE: ${{ vars.GDO_RELEASE }} GDO_RELEASE: ${{ vars.GDO_RELEASE }}
CNATS_TAG: ${{ vars.CNATS_TAG }}
KRON_RELEASE: ${{ vars.KRON_RELEASE }} KRON_RELEASE: ${{ vars.KRON_RELEASE }}
COMPOSE_PROFILES: ${{ vars.COMPOSE_PROFILES }} COMPOSE_PROFILES: ${{ vars.COMPOSE_PROFILES }}
CONTENT_REPO: ${{ vars.CONTENT_REPO }} CONTENT_REPO: ${{ vars.CONTENT_REPO }}
@@ -48,14 +46,24 @@ jobs:
PEOPLE_BACKEND: ${{ vars.PEOPLE_BACKEND }} PEOPLE_BACKEND: ${{ vars.PEOPLE_BACKEND }}
RESPONSIBLE_GROUP: ${{ vars.RESPONSIBLE_GROUP }} RESPONSIBLE_GROUP: ${{ vars.RESPONSIBLE_GROUP }}
OAUTH2_CLIENT_ID: ${{ vars.OAUTH2_CLIENT_ID }} OAUTH2_CLIENT_ID: ${{ vars.OAUTH2_CLIENT_ID }}
CHAT_OAUTH2_CLIENT_ID: ${{ vars.CHAT_OAUTH2_CLIENT_ID }}
NATS_ADOPT_LEGACY: ${{ vars.NATS_ADOPT_LEGACY }}
GARAGE_S3_ENDPOINT: ${{ vars.GARAGE_S3_ENDPOINT }} GARAGE_S3_ENDPOINT: ${{ vars.GARAGE_S3_ENDPOINT }}
GARAGE_UPLOADS_BUCKET: ${{ vars.GARAGE_UPLOADS_BUCKET }} GARAGE_UPLOADS_BUCKET: ${{ vars.GARAGE_UPLOADS_BUCKET }}
# The programs beside the site (README.md, "The site's own
# network"): each one's key and what it may do, and the site's own
# key and where it listens. Public keys, said in the logs; set
# once, from what move-1.0/move.sh prints.
DHD_KEYS: ${{ vars.DHD_KEYS }}
PORTAL_DHD: ${{ vars.PORTAL_DHD }}
# Optional: sealed copies of the site's store, every six hours
# (README.md, "Backups"). PORTAL_BACKUP_TO is an age public key
# whose private half is kept off this host.
PORTAL_BACKUP_TO: ${{ vars.PORTAL_BACKUP_TO }}
GARAGE_BACKUPS_BUCKET: ${{ vars.GARAGE_BACKUPS_BUCKET }}
# What it runs with. # What it runs with.
NATS_PASSWORD: ${{ secrets.NATS_PASSWORD }} # The token the content repo's reload posts; the site is given
# its hash alone.
LOAD_TOKEN: ${{ secrets.LOAD_TOKEN }}
OAUTH2_CLIENT_SECRET: ${{ secrets.OAUTH2_CLIENT_SECRET }} OAUTH2_CLIENT_SECRET: ${{ secrets.OAUTH2_CLIENT_SECRET }}
CHAT_OAUTH2_CLIENT_SECRET: ${{ secrets.CHAT_OAUTH2_CLIENT_SECRET }}
GARAGE_ACCESS_KEY: ${{ secrets.GARAGE_ACCESS_KEY }} GARAGE_ACCESS_KEY: ${{ secrets.GARAGE_ACCESS_KEY }}
GARAGE_SECRET_KEY: ${{ secrets.GARAGE_SECRET_KEY }} GARAGE_SECRET_KEY: ${{ secrets.GARAGE_SECRET_KEY }}
SEED_ADMIN_EMAIL: ${{ secrets.SEED_ADMIN_EMAIL }} SEED_ADMIN_EMAIL: ${{ secrets.SEED_ADMIN_EMAIL }}
@@ -65,7 +73,7 @@ jobs:
MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }}
MAPBOX_STYLE: ${{ vars.MAPBOX_STYLE }} MAPBOX_STYLE: ${{ vars.MAPBOX_STYLE }}
# Who is who: Rauthy (README.md, "Rauthy"). RAUTHY_HOST and the # Who is who: Rauthy (README.md, "Rauthy"). RAUTHY_HOST and the
# three secrets run it; portal and the chat sign in at OIDC_ISSUER; # three secrets run it; portal signs in at OIDC_ISSUER;
# RAUTHY_API_KEY lets portal make accounts there. # RAUTHY_API_KEY lets portal make accounts there.
RAUTHY_HOST: ${{ vars.RAUTHY_HOST }} RAUTHY_HOST: ${{ vars.RAUTHY_HOST }}
RAUTHY_ENC_KEY: ${{ secrets.RAUTHY_ENC_KEY }} RAUTHY_ENC_KEY: ${{ secrets.RAUTHY_ENC_KEY }}
@@ -80,10 +88,8 @@ jobs:
RAUTHY_API_KEY: ${{ secrets.RAUTHY_API_KEY }} RAUTHY_API_KEY: ${{ secrets.RAUTHY_API_KEY }}
RAUTHY_LANGUAGE: ${{ vars.RAUTHY_LANGUAGE }} RAUTHY_LANGUAGE: ${{ vars.RAUTHY_LANGUAGE }}
# The money service (README.md, "Payments"): Vipps's keys for the # The money service (README.md, "Payments"): Vipps's keys for the
# Medlemskap sales unit, read by kron alone. Unset, kron starts # Medlemskap sales unit, read by kron alone, from its env: with
# without them and asks for them on the treasurer's desk # all four set kron asks the site for nothing. VIPPS_WEBHOOK_SECRET may wait, kron
# ("Tjenester som venter"), sealed to its own identity; set, they
# are kron's from the env. VIPPS_WEBHOOK_SECRET may wait, kron
# then settles by asking Vipps every minute instead. # then settles by asking Vipps every minute instead.
VIPPS_MSN: ${{ vars.VIPPS_MSN }} VIPPS_MSN: ${{ vars.VIPPS_MSN }}
VIPPS_CLIENT_ID: ${{ secrets.VIPPS_CLIENT_ID }} VIPPS_CLIENT_ID: ${{ secrets.VIPPS_CLIENT_ID }}
@@ -101,11 +107,11 @@ jobs:
- name: Write the env files - name: Write the env files
run: | run: |
missing= missing=
for v in PORTAL_HOST CHAT_HOST RAUTHY_HOST OIDC_ISSUER PORTAL_RELEASE GDO_RELEASE CNATS_TAG \ for v in PORTAL_HOST RAUTHY_HOST OIDC_ISSUER PORTAL_RELEASE GDO_RELEASE \
KRON_RELEASE CONTENT_REPO CONTENT_BRANCH SITE_NAME PEOPLE_BACKEND \ KRON_RELEASE CONTENT_REPO CONTENT_BRANCH SITE_NAME PEOPLE_BACKEND \
RESPONSIBLE_GROUP OAUTH2_CLIENT_ID CHAT_OAUTH2_CLIENT_ID \ RESPONSIBLE_GROUP OAUTH2_CLIENT_ID \
GARAGE_S3_ENDPOINT GARAGE_UPLOADS_BUCKET \ GARAGE_S3_ENDPOINT GARAGE_UPLOADS_BUCKET \
NATS_PASSWORD OAUTH2_CLIENT_SECRET CHAT_OAUTH2_CLIENT_SECRET \ DHD_KEYS PORTAL_DHD LOAD_TOKEN OAUTH2_CLIENT_SECRET \
RAUTHY_ENC_KEY RAUTHY_SECRET_RAFT RAUTHY_SECRET_API RAUTHY_API_KEY \ RAUTHY_ENC_KEY RAUTHY_SECRET_RAFT RAUTHY_SECRET_API RAUTHY_API_KEY \
GARAGE_ACCESS_KEY GARAGE_SECRET_KEY SEED_ADMIN_EMAIL; do GARAGE_ACCESS_KEY GARAGE_SECRET_KEY SEED_ADMIN_EMAIL; do
[ -n "${!v}" ] || missing="$missing $v" [ -n "${!v}" ] || missing="$missing $v"
@@ -125,20 +131,21 @@ jobs:
# Interpolated by compose: hosts, versions, profiles. No secret. # Interpolated by compose: hosts, versions, profiles. No secret.
cat > "$STAGE/.env" <<EOF cat > "$STAGE/.env" <<EOF
PORTAL_HOST=$PORTAL_HOST PORTAL_HOST=$PORTAL_HOST
CHAT_HOST=$CHAT_HOST
PORTAL_RELEASE=$PORTAL_RELEASE PORTAL_RELEASE=$PORTAL_RELEASE
GDO_RELEASE=$GDO_RELEASE GDO_RELEASE=$GDO_RELEASE
CNATS_TAG=$CNATS_TAG
KRON_RELEASE=$KRON_RELEASE KRON_RELEASE=$KRON_RELEASE
PORTAL_DHD=$PORTAL_DHD
COMPOSE_PROFILES=$COMPOSE_PROFILES COMPOSE_PROFILES=$COMPOSE_PROFILES
PAY_HOST=$PAY_HOST PAY_HOST=$PAY_HOST
RAUTHY_HOST=$RAUTHY_HOST RAUTHY_HOST=$RAUTHY_HOST
OIDC_ISSUER=$OIDC_ISSUER OIDC_ISSUER=$OIDC_ISSUER
EOF EOF
# The site keeps no token, only its hash.
load_hash=$(printf %s "$LOAD_TOKEN" | sha256sum | cut -d' ' -f1)
cat > "$STAGE/portal.env" <<EOF cat > "$STAGE/portal.env" <<EOF
NATS_URL=nats://portal:$NATS_PASSWORD@nats:4222
PUBLIC_URL=https://$PORTAL_HOST PUBLIC_URL=https://$PORTAL_HOST
CHAT_URL=https://$CHAT_HOST DHD_KEYS=$DHD_KEYS
DHD_TOKENS=$load_hash=load
OAUTH2_CLIENT_ID=$OAUTH2_CLIENT_ID OAUTH2_CLIENT_ID=$OAUTH2_CLIENT_ID
OAUTH2_CLIENT_SECRET=$OAUTH2_CLIENT_SECRET OAUTH2_CLIENT_SECRET=$OAUTH2_CLIENT_SECRET
COOKIE_SECURE=true COOKIE_SECURE=true
@@ -149,7 +156,6 @@ jobs:
RESPONSIBLE_GROUP=$RESPONSIBLE_GROUP RESPONSIBLE_GROUP=$RESPONSIBLE_GROUP
SEED_ADMIN_EMAIL=$SEED_ADMIN_EMAIL SEED_ADMIN_EMAIL=$SEED_ADMIN_EMAIL
SEED_ADMIN_NAME=$SEED_ADMIN_NAME SEED_ADMIN_NAME=$SEED_ADMIN_NAME
NATS_ADOPT_LEGACY=$NATS_ADOPT_LEGACY
GARAGE_S3_ENDPOINT=$GARAGE_S3_ENDPOINT GARAGE_S3_ENDPOINT=$GARAGE_S3_ENDPOINT
GARAGE_ACCESS_KEY=$GARAGE_ACCESS_KEY GARAGE_ACCESS_KEY=$GARAGE_ACCESS_KEY
GARAGE_SECRET_KEY=$GARAGE_SECRET_KEY GARAGE_SECRET_KEY=$GARAGE_SECRET_KEY
@@ -163,24 +169,17 @@ jobs:
EOF EOF
# With the money service in the stack, portal may ask for # With the money service in the stack, portal may ask for
# payments without `by_hand`; the address itself is never # payments without `by_hand`; the address itself is never
# called (the two talk over NATS), the lint only reads that it # called (kron dials the site), the lint only reads that it is
# is set. The content repo's lint sets it the same way. # set. The content repo's lint sets it the same way.
if [ -n "$pay" ]; then if [ -n "$pay" ]; then
echo "PAY_URL=http://kron:3000" >> "$STAGE/portal.env" echo "PAY_URL=http://127.0.0.1:3080" >> "$STAGE/portal.env"
fi fi
# NATS itself (nats.conf reads NATS_PASSWORD), gdo and the chat. if [ -n "$PORTAL_BACKUP_TO" ] && [ -n "$GARAGE_BACKUPS_BUCKET" ]; then
cat > "$STAGE/nats.env" <<EOF printf 'PORTAL_BACKUP_TO=%s\nGARAGE_BACKUPS_BUCKET=%s\n' "$PORTAL_BACKUP_TO" "$GARAGE_BACKUPS_BUCKET" >> "$STAGE/portal.env"
NATS_PASSWORD=$NATS_PASSWORD fi
NATS_URL=nats://portal:$NATS_PASSWORD@nats:4222 # kron: Vipps's keys for the Medlemskap sales unit (kron refuses
EOF # some set and some not). Written even without the profile, so
cat > "$STAGE/chat.env" <<EOF # the file compose names is there.
OAUTH2_CLIENT_ID=$CHAT_OAUTH2_CLIENT_ID
OAUTH2_CLIENT_SECRET=$CHAT_OAUTH2_CLIENT_SECRET
EOF
# kron: Vipps's keys for the Medlemskap sales unit, when the
# deploy holds them; none set, and kron asks for them through
# portal (kron refuses some set and some not). Written even
# without the profile, so the file compose names is there.
{ {
echo "WEBHOOK_SECRET=$VIPPS_WEBHOOK_SECRET" echo "WEBHOOK_SECRET=$VIPPS_WEBHOOK_SECRET"
for name in VIPPS_MSN VIPPS_CLIENT_ID VIPPS_CLIENT_SECRET VIPPS_SUBSCRIPTION_KEY; do for name in VIPPS_MSN VIPPS_CLIENT_ID VIPPS_CLIENT_SECRET VIPPS_SUBSCRIPTION_KEY; do
@@ -208,7 +207,7 @@ jobs:
# "$$" is compose's literal "$". Without this, RAUTHY_API_KEY reached # "$$" is compose's literal "$". Without this, RAUTHY_API_KEY reached
# portal as "portal" alone, Rauthy answered 401, and every invite # portal as "portal" alone, Rauthy answered 401, and every invite
# failed. .env is left alone: it is what compose.yml interpolates. # failed. .env is left alone: it is what compose.yml interpolates.
sed -i 's/\$/$$/g' "$STAGE/portal.env" "$STAGE/nats.env" "$STAGE/chat.env" "$STAGE/rauthy.env" "$STAGE/kron.env" sed -i 's/\$/$$/g' "$STAGE/portal.env" "$STAGE/rauthy.env" "$STAGE/kron.env"
- name: Pull and bring the stack up - name: Pull and bring the stack up
run: sudo /usr/local/bin/deploy-tomtervel run: sudo /usr/local/bin/deploy-tomtervel
+94 -89
View File
@@ -1,10 +1,13 @@
# Tomter Vel's own platform: portal + its own Rauthy and NATS as podman # Tomter Vel's own platform: portal, its own Rauthy, and the programs
# containers. The content (pages, forms, desks) is not here: portal fetches # beside the site (gdo for mail, kron for Vipps) as podman containers.
# it from tomtervel/questions on prosjekt.klingenbergbygg.no and hot-reloads # The content (pages, forms, desks) is not here: portal fetches it from
# it over NATS. This repo owns identity, the bus, and which portal version # tomtervel/questions on prosjekt.klingenbergbygg.no, at start and when
# runs. TLS depends on where it runs: on a standalone host the bundled Caddy # that repo's CI asks it to (POST /dhd/1/load). This repo owns identity,
# (`--profile edge`) terminates it; on kasse the host Caddy already owns # which portal version runs, and where the site keeps what is its own:
# 80/443 and reverse-proxies vel.klingenbergbygg.no -> portal (127.0.0.1:3050). # 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 # Everything it runs with is an Actions variable or secret, written by
# the deploy workflow (README.md); `podman compose up -d --build` is # the deploy workflow (README.md); `podman compose up -d --build` is
@@ -36,30 +39,27 @@ services:
- portal - portal
- rauthy - 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: nats:
profiles: ["nats-0-19"]
image: nats:2.14.6-alpine image: nats:2.14.6-alpine
restart: unless-stopped restart: unless-stopped
command: ["-c", "/etc/nats/nats.conf"] command: ["-c", "/etc/nats/nats.conf"]
# NATS_PASSWORD, which nats.conf reads from the environment. env_file:
env_file: nats.env - path: nats.env
required: false
volumes: volumes:
- ./nats/nats.conf:/etc/nats/nats.conf:ro - ./nats/nats.conf:/etc/nats/nats.conf:ro
- nats_data:/data - 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: ports:
- "127.0.0.1:4223:4222" - "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 # 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 # makes accounts here (RAUTHY_API_KEY). Its database is embedded
# (hiqlite), in rauthy_data. Host-published for kasse's host Caddy # (hiqlite), in rauthy_data. Host-published for kasse's host Caddy
# (RAUTHY_HOST -> here). # (RAUTHY_HOST -> here).
@@ -100,117 +100,120 @@ services:
LEPTOS_HASH_FILES: "true" LEPTOS_HASH_FILES: "true"
LEARN_CACHE: /app/learn-cache LEARN_CACHE: /app/learn-cache
OLLAMA_HOST: http://100.64.0.1:11434 OLLAMA_HOST: http://100.64.0.1:11434
# The namespace of everything this site keeps on NATS from portal 0.9. # What the site calls itself to the programs beside it. Must not
# Must not change: a new name is a new, empty site. # change: kron and the mail name the site by it.
SITE_NAME: tomtervel 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: volumes:
- learn_cache:/app/learn-cache - learn_cache:/app/learn-cache
- portal_data:/data
# gdo and kron run in this container's network (network_mode below):
# they dial the site on loopback, where it listens for them
# (DHD_BIND, 127.0.0.1:4300 unless set). So what they need of the
# network is said here: the way to the host's mail server, and
# kron's port.
extra_hosts:
- "host.containers.internal:host-gateway"
ports: ports:
# Host-published for kasse's host Caddy (vel.klingenbergbygg.no -> here). # Host-published for kasse's host Caddy (tomtervel.no -> here).
# With --profile edge the bundled Caddy proxies portal:3000 internally # With --profile edge the bundled Caddy proxies portal:3000
# instead, but publishing loopback-only is harmless there. # internally instead, but publishing loopback-only is harmless
# there.
- "127.0.0.1:3050:3000" - "127.0.0.1:3050:3000"
# kron (betaling.tomtervel.no -> here).
- "127.0.0.1:3080:3080"
depends_on: depends_on:
nats:
condition: service_healthy
rauthy: rauthy:
condition: service_started condition: service_started
# The mailer. Portal decides what to send - a `mail:` on a state in the # 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 # content, or an invite - and keeps it in its own `mail` outbox; gdo
# actually hands it to a mail server. It is in the vel's own stack rather # dials the site over dhd/1 (PORTAL_DHD), is handed what waits there,
# than shared, so the vel's mail leaves on the vel's own terms, but it # and hands each to a mail server. It has none of its own: it relays
# has no mail server of its own: it relays through the host's, which on # through the host's, which on kasse is Klingenberg Bygg's postfix on
# kasse is Klingenberg Bygg's postfix on port 25. That is the one thing # port 25. That is the one thing here the vel borrows.
# 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: gdo:
build: build:
context: ./gdo context: ./gdo
args: args:
GDO_RELEASE: ${GDO_RELEASE} 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 restart: unless-stopped
# NATS_URL, with the password: made by bootstrap.sh, never committed. # The site's network: gdo dials from loopback to loopback.
env_file: nats.env network_mode: "service:portal"
environment: environment:
# The host, from inside the container. Podman resolves this to the PORTAL_DHD: ${PORTAL_DHD:-}
# gateway; the host's postfix listens on 0.0.0.0:25. # 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 portal); the host's postfix
# listens on 0.0.0.0:25.
SMTP_HOST: host.containers.internal SMTP_HOST: host.containers.internal
SMTP_PORT: "25" SMTP_PORT: "25"
# A strict server refuses a bare container hostname in EHLO. # A strict server refuses a bare container hostname in EHLO.
SMTP_HELO: ${PORTAL_HOST} SMTP_HELO: ${PORTAL_HOST}
extra_hosts: volumes:
- "host.containers.internal:host-gateway" - gdo_data:/var/lib/gdo
depends_on: depends_on:
nats: - portal
condition: service_healthy
# The money service (uhhm/kron): portal asks for a payment on this # The money service (uhhm/kron): a household that owes its fee waits
# NATS as a household owes its fee, kron gives it a link to pay by, # in portal's `payments` outbox; kron dials the site over dhd/1, takes
# talks to Vipps's ePayment API for the Medlemskap sales unit, and # the request, gives it a link to pay by, talks to Vipps's ePayment API
# says `paid` back on the same bus. Vipps's keys are in kron.env and # for the Medlemskap sales unit, and tells the site `paid` as a move on
# nowhere else; portal never calls Vipps. Host-published for kasse's # the payment. Vipps's keys are in kron.env and nowhere else; portal
# host Caddy (betaling.tomtervel.no -> here): the pay links, the page # never calls Vipps. Its ledger is a file of its own in kron_data.
# people come back to from Vipps, and Vipps's webhooks. A profile, since # Reached by kasse's host Caddy on portal's published 3080
# it needs kron.env: COMPOSE_PROFILES gains `pay` once the keys are set. # (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: kron:
profiles: ["pay"] profiles: ["pay"]
image: project.uhhm.no/uhhm/kron:${KRON_RELEASE:-no-tag-set} image: project.uhhm.no/uhhm/kron:${KRON_RELEASE:-no-tag-set}
restart: unless-stopped restart: unless-stopped
network_mode: "service:portal"
env_file: env_file:
- nats.env
- kron.env - kron.env
environment: environment:
PORTAL_DHD: ${PORTAL_DHD:-}
# Must be the portal's own: a request names its site. # Must be the portal's own: a request names its site.
SITE_NAME: tomtervel SITE_NAME: tomtervel
PROVIDER: vipps PROVIDER: vipps
VIPPS_ENV: prod VIPPS_ENV: prod
PUBLIC_URL: https://${PAY_HOST:-no-host-set} PUBLIC_URL: https://${PAY_HOST:-no-host-set}
LISTEN_ADDR: 0.0.0.0:3000 # 3080, not 3000: in this network 3000 is portal's.
# kron's own identity, made on first start: what the Vipps keys LISTEN_ADDR: 0.0.0.0:3080
# given through portal (the treasurer's "Tjenester som venter") # Its key on dhd/1 and, beside it, its ledger (kron.redb).
# are sealed to. On its own volume, never copied anywhere. With KRON_KEY: /var/lib/kron/kron.key
# no VIPPS_* in kron.env, kron waits to be given them. # 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_IDENTITY_FILE: /var/lib/kron/identity
KRON_LANG: nb KRON_LANG: nb
volumes: volumes:
- kron_data:/var/lib/kron - kron_data:/var/lib/kron
ports:
- "127.0.0.1:3080:3000"
depends_on: depends_on:
nats: - portal
condition: service_healthy
# The Gitea Actions runner is a host service on kasse (pacman gitea-runner), # The Gitea Actions runner is a host service on kasse (pacman
# registered against prosjekt.klingenbergbygg.no. It reaches this NATS via the # gitea-runner), registered against prosjekt.klingenbergbygg.no. The
# published 127.0.0.1:4222 port above, so no in-compose runner — and no # content repo's reload reaches the site over HTTPS, so no in-compose
# docker.sock/podman.sock mount — is needed here. # runner - and no docker.sock/podman.sock mount - is needed here.
# The vel's conversations: every group the content names is a room, # The vel's conversations are not in this stack for now: the chat that
# portal speaks in them and decides who gets in. Its history is on the # ran here (cnats) spoke to portal over NATS, and the one that dials a
# vel's own NATS (stream tomtervel_CHAT); there is no Postgres. A # 1.0 site (uhhm/kino) is not published as an image yet.
# 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
# Where uploads go: the pictures and documents a desk attaches, and what # Where uploads go: the pictures and documents a desk attaches, and what
# `portal import` brings in. One node on this host, reachable only inside # `portal import` brings in. One node on this host, reachable only inside
@@ -226,6 +229,8 @@ services:
volumes: volumes:
garage_data: garage_data:
portal_data:
gdo_data:
kron_data: kron_data:
caddy_data: caddy_data:
caddy_config: caddy_config:
+1 -1
View File
@@ -17,7 +17,7 @@ set -euo pipefail
root=/srv/tomtervel/infrastructure root=/srv/tomtervel/infrastructure
stage=/var/lib/gitea-runner/tomtervel-env stage=/var/lib/gitea-runner/tomtervel-env
files=(.env portal.env nats.env chat.env) files=(.env portal.env)
# Written only when the site runs what needs it (Rauthy, the money # Written only when the site runs what needs it (Rauthy, the money
# service under the pay profile). # service under the pay profile).
optional=(rauthy.env kron.env) optional=(rauthy.env kron.env)
+11 -4
View File
@@ -1,4 +1,5 @@
# gdo, the mailer, from the [uhhm] Arch registry - the same package the # gdo, the mailer (0.4 and on: it dials a portal 1.0 site), from the
# [uhhm] Arch registry - the same package the
# bare-metal hosts install. Arch base rather than Debian because that is # bare-metal hosts install. Arch base rather than Debian because that is
# how every uhhm binary is published; portal ships a release tarball and # how every uhhm binary is published; portal ships a release tarball and
# is built from that instead. # is built from that instead.
@@ -28,9 +29,15 @@ RUN pacman-key --init \
&& pacman -Syu --noconfirm --needed ca-certificates gdo \ && pacman -Syu --noconfirm --needed ca-certificates gdo \
&& pacman -Scc --noconfirm \ && pacman -Scc --noconfirm \
&& rm -rf /var/cache/pacman/pkg/* /var/lib/pacman/sync/* && rm -rf /var/cache/pacman/pkg/* /var/lib/pacman/sync/*
# The registry gives its newest gdo. GDO_RELEASE says which one this
# stack means: a build that got another stops here, and a changed
# GDO_RELEASE builds anew.
RUN gdo --version | grep -F "gdo ${GDO_RELEASE#v} "
# A non-root user; gdo writes nothing and holds no state - what it has # A non-root user. gdo keeps its key on dhd/1 in /var/lib/gdo, a volume
# not yet delivered is on the stream, not on disk. # (GDO_KEY in compose.yml); what it has not yet delivered waits with the
RUN useradd --system --no-create-home gdo # site, not here.
RUN useradd --system --no-create-home gdo \
&& mkdir -p /var/lib/gdo && chown gdo /var/lib/gdo && chmod 700 /var/lib/gdo
USER gdo USER gdo
CMD ["/usr/bin/gdo"] CMD ["/usr/bin/gdo"]
+40 -3
View File
@@ -17,6 +17,12 @@
# which counts it and lets it go. A store started on without that step # which counts it and lets it go. A store started on without that step
# mails every sign-up as soon as gdo dials it. # mails every sign-up as soon as gdo dials it.
# #
# The keys: the site and the programs beside it (gdo, kron) know each
# other by key. With GDO_IMAGE and KRON_IMAGE named (move needs both),
# each program is started once on its own volume to say its key, the
# site is started knowing them, and the run ends with the two values the
# deploy wants, DHD_KEYS and PORTAL_DHD. They are public keys.
#
# Nothing is printed that names anyone: counts, and the names of fields. # Nothing is printed that names anyone: counts, and the names of fields.
set -euo pipefail set -euo pipefail
umask 077 umask 077
@@ -36,7 +42,15 @@ stage=tomtervel-move-stage
port=3997; sink_port=3996 port=3997; sink_port=3996
export_sha=e417cbfddb7d3710a36c7b3b0b6a86ff1ed6d08dcffc66417760f9b20fbdfe4f # portal-x86_64-linux v0.19.3 export_sha=e417cbfddb7d3710a36c7b3b0b6a86ff1ed6d08dcffc66417760f9b20fbdfe4f # portal-x86_64-linux v0.19.3
if [ "$mode" = move ]; then volume=tomtervel_portal_data; else volume=tomtervel-move-rehearsal; fi dhd_port=4397 # where the site of this run listens for programs
gdo_image=${GDO_IMAGE:-}; kron_image=${KRON_IMAGE:-}
if [ "$mode" = move ]; then
volume=tomtervel_portal_data; gdo_volume=tomtervel_gdo_data; kron_volume=tomtervel_kron_data
[ -n "$gdo_image" ] && [ -n "$kron_image" ] || { echo "move needs GDO_IMAGE and KRON_IMAGE: the images the 1.0 stack will run" >&2; exit 1; }
else
volume=tomtervel-move-rehearsal; gdo_volume=$volume-gdo; kron_volume=$volume-kron
fi
for i in $gdo_image $kron_image; do podman image exists "$i" || { echo "no image $i" >&2; exit 1; }; done
work=$base/$mode-$(date +%Y%m%d-%H%M%S) work=$base/$mode-$(date +%Y%m%d-%H%M%S)
podman image exists "$image" || { echo "no image $image: build it first (README.md)" >&2; exit 1; } podman image exists "$image" || { echo "no image $image: build it first (README.md)" >&2; exit 1; }
@@ -47,7 +61,7 @@ podman rm -f "$stage" >/dev/null 2>&1 || true
for p in $port $sink_port; do for p in $port $sink_port; do
if (exec 3<>"/dev/tcp/127.0.0.1/$p") 2>/dev/null; then echo "something already answers on 127.0.0.1:$p" >&2; exit 1; fi if (exec 3<>"/dev/tcp/127.0.0.1/$p") 2>/dev/null; then echo "something already answers on 127.0.0.1:$p" >&2; exit 1; fi
done done
[ "$mode" = rehearse ] && podman volume rm -f "$volume" >/dev/null 2>&1 || true [ "$mode" = rehearse ] && podman volume rm -f "$volume" "$gdo_volume" "$kron_volume" >/dev/null 2>&1 || true
install -d -m 0700 "$base" "$work" install -d -m 0700 "$base" "$work"
cd "$work" cd "$work"
@@ -99,6 +113,22 @@ run /app/portal import --path /w/content/questions /w/records-1.0.yaml --dry-run
run /app/portal import --path /w/content/questions /w/records-1.0.yaml | tail -1 run /app/portal import --path /w/content/questions /w/records-1.0.yaml | tail -1
chmod 600 records-1.0.yaml; chmod 700 "$base" chmod 600 records-1.0.yaml; chmod 700 "$base"
dhd_keys=
if [ -n "$gdo_image" ] && [ -n "$kron_image" ]; then
step "the programs' keys"
# Each says its key before it dials, so a site that is not there will
# do. kron's ledger is kept out of it: only its key is made here.
nowhere=$(printf 'a%.0s' $(seq 64))@127.0.0.1:9
said() { sed 's/\x1b\[[0-9;]*m//g' | grep -o 'DHD_KEYS as [0-9a-f]\{64\}=[a-z,:]*' | head -1 | cut -d' ' -f3; }
gdo_key=$(podman run --rm --timeout 20 -v "$gdo_volume:/var/lib/gdo" -e GDO_KEY=/var/lib/gdo/gdo.key \
-e PORTAL_DHD="$nowhere" -e SMTP_HOST=127.0.0.1 -e SMTP_PORT=9 "$gdo_image" 2>&1 | said || true)
kron_key=$(podman run --rm --timeout 20 -v "$kron_volume:/var/lib/kron" -e KRON_KEY=/var/lib/kron/kron.key -e KRON_STATE=/tmp/none.redb \
-e PORTAL_DHD="$nowhere" -e SITE_NAME=tomtervel -e PROVIDER=fake -e PUBLIC_URL=http://127.0.0.1 -e LISTEN_ADDR=127.0.0.1:0 "$kron_image" 2>&1 | said || true)
[ -n "$gdo_key" ] && [ -n "$kron_key" ] || { echo "a program did not say its key (gdo: ${gdo_key:-nothing}, kron: ${kron_key:-nothing})" >&2; exit 1; }
dhd_keys="$gdo_key;$kron_key"
echo "$dhd_keys"
fi
step "a 1.0 site on the store, for this host only, its outboxes posted to the sink" step "a 1.0 site on the store, for this host only, its outboxes posted to the sink"
token=$(head -c 32 /dev/urandom | base64 | tr -dc A-Za-z0-9); printf %s "$token" > token token=$(head -c 32 /dev/urandom | base64 | tr -dc A-Za-z0-9); printf %s "$token" > token
hash=$(printf %s "$token" | sha256sum | cut -d' ' -f1) hash=$(printf %s "$token" | sha256sum | cut -d' ' -f1)
@@ -113,6 +143,7 @@ podman run -d --name "$stage" --user 0 --network host --add-host "garage:$garage
-e CONTENT_DIR=/w -e PORTAL_STORE=/data/site.redb -e SITE_NAME=tomtervel -e PUBLIC_URL="https://$(grep -m1 '^PORTAL_HOST=' "$infra/.env" | cut -d= -f2-)" \ -e CONTENT_DIR=/w -e PORTAL_STORE=/data/site.redb -e SITE_NAME=tomtervel -e PUBLIC_URL="https://$(grep -m1 '^PORTAL_HOST=' "$infra/.env" | cut -d= -f2-)" \
-e LEPTOS_SITE_ADDR=127.0.0.1:$port -e LEPTOS_SITE_ROOT=site -e LEPTOS_HASH_FILES=true -e PAY_URL="$pay" \ -e LEPTOS_SITE_ADDR=127.0.0.1:$port -e LEPTOS_SITE_ROOT=site -e LEPTOS_HASH_FILES=true -e PAY_URL="$pay" \
-e DHD_TOKENS="$hash=submit:pameldinger,read" -e DHD_HOOK_SECRET="$token" \ -e DHD_TOKENS="$hash=submit:pameldinger,read" -e DHD_HOOK_SECRET="$token" \
-e DHD_KEYS="$dhd_keys" -e DHD_BIND="127.0.0.1:$dhd_port" \
-e DHD_HOOKS="mail=http://127.0.0.1:$sink_port/;rooms=http://127.0.0.1:$sink_port/;answers=http://127.0.0.1:$sink_port/" \ -e DHD_HOOKS="mail=http://127.0.0.1:$sink_port/;rooms=http://127.0.0.1:$sink_port/;answers=http://127.0.0.1:$sink_port/" \
"$image" >/dev/null "$image" >/dev/null
code=000 code=000
@@ -143,12 +174,18 @@ if [ "${mails:-0}" != "$sent" ]; then echo "MAIL: $sent sign-ups sent, ${mails:-
podman logs "$stage" 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep -E ' (WARN|ERROR) ' | grep -v '@' > site-warnings.out || true podman logs "$stage" 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep -E ' (WARN|ERROR) ' | grep -v '@' > site-warnings.out || true
echo "warnings and errors in the site's log: $(wc -l < site-warnings.out)" echo "warnings and errors in the site's log: $(wc -l < site-warnings.out)"
cut -d' ' -f2- site-warnings.out | cut -c1-200 | sort | uniq -c | head -15 cut -d' ' -f2- site-warnings.out | cut -c1-200 | sort | uniq -c | head -15
site_key=$(podman logs "$stage" 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep 'programs dial this site here' | grep -o 'key=[0-9a-f]\{64\}' | head -1 | cut -d= -f2 || true)
run chown -R portal /data run chown -R portal /data
podman rm -f "$stage" >/dev/null podman rm -f "$stage" >/dev/null
if [ -n "$dhd_keys" ]; then
step "what the deploy wants (Actions variables of this repo; public keys)"
[ -n "$site_key" ] || { echo "the site did not say its key" >&2; ok=1; }
printf 'DHD_KEYS=%s\nPORTAL_DHD=%s@127.0.0.1:4300\n' "$dhd_keys" "$site_key" | tee keys.env
fi
step "done" step "done"
if [ "$mode" = rehearse ]; then if [ "$mode" = rehearse ]; then
podman volume rm "$volume" >/dev/null podman volume rm -f "$volume" "$gdo_volume" "$kron_volume" >/dev/null
echo "rehearsal volume removed; the export and the logs are in $work (root only)" echo "rehearsal volume removed; the export and the logs are in $work (root only)"
else else
echo "the 1.0 store is in $volume; the export is in $work (root only)" echo "the 1.0 store is in $volume; the export is in $work (root only)"
+4 -2
View File
@@ -22,9 +22,11 @@ WORKDIR /app
RUN curl -sfL "https://project.uhhm.no/uhhm/portal/releases/download/${PORTAL_RELEASE}/portal-${PORTAL_RELEASE}.tar.gz" \ RUN curl -sfL "https://project.uhhm.no/uhhm/portal/releases/download/${PORTAL_RELEASE}/portal-${PORTAL_RELEASE}.tar.gz" \
| tar -xz -C /app \ | tar -xz -C /app \
&& test -x /app/portal && test -x /app/portal
# A non-root user; the image ships nothing writable it needs. # A non-root user. What it writes is in two volumes: the search cache,
# and /data, where the site's store is (PORTAL_STORE in compose.yml); a
# new volume takes this directory's owner.
RUN useradd --system --no-create-home portal RUN useradd --system --no-create-home portal
RUN mkdir -p /app/learn-cache && chown portal /app/learn-cache RUN mkdir -p /app/learn-cache /data && chown portal /app/learn-cache /data
USER portal USER portal
EXPOSE 3000 EXPOSE 3000
CMD ["/app/portal"] CMD ["/app/portal"]