From 9c9164f8c0a99a12dd18a0bf02bb2c1ce8f61ef8 Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Wed, 25 Nov 2026 07:15:24 +0100 Subject: [PATCH] kino in the stack: the vel's chat beside the 1.0 site The chat left with NATS at the move to 1.0. uhhm/kino 0.1.2 has an image now, so it comes back as a service under the profile `chat`: it shares the site's network namespace like gdo and kron, dials the site over dhd/1, signs people in at Rauthy as the client `chat`, listens on 3070 (the host Caddy's samtaler.tomtervel.no block already points there) and keeps its history in kino_data. The deploy takes CHAT_HOST, KINO_RELEASE and the secret CHAT_OAUTH2_CLIENT_SECRET, refuses the profile without them, and writes kino.env; deploy-tomtervel puts that file in place. README.md, "The chat", has the four steps, the last being kino's key into DHD_KEYS. Nothing changes until COMPOSE_PROFILES has `chat`: the profile keeps the service out, and the new published port (3070) has nothing behind it. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L5fbDjRr9xfrtcDzcdJNr2 --- .gitea/workflows/deploy.yml | 23 +++++++++++++++++++++ README.md | 37 ++++++++++++++++++++++++++++++++-- compose.yml | 40 ++++++++++++++++++++++++++++++++++--- deploy-tomtervel | 4 ++-- 4 files changed, 97 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index aa7f51b..1de2c66 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -39,6 +39,12 @@ jobs: PORTAL_RELEASE: ${{ vars.PORTAL_RELEASE }} GDO_RELEASE: ${{ vars.GDO_RELEASE }} KRON_RELEASE: ${{ vars.KRON_RELEASE }} + # The chat (README.md, "The chat"): where it answers, which kino, + # and the secret of the Rauthy client `chat`. With the profile + # `chat` all three must be set. + CHAT_HOST: ${{ vars.CHAT_HOST }} + KINO_RELEASE: ${{ vars.KINO_RELEASE }} + CHAT_OAUTH2_CLIENT_SECRET: ${{ secrets.CHAT_OAUTH2_CLIENT_SECRET }} COMPOSE_PROFILES: ${{ vars.COMPOSE_PROFILES }} CONTENT_REPO: ${{ vars.CONTENT_REPO }} CONTENT_BRANCH: ${{ vars.CONTENT_BRANCH }} @@ -126,6 +132,15 @@ jobs: [ -z "$missing" ] || { echo "COMPOSE_PROFILES has pay, but not set:$missing"; exit 1; } fi + chat= + case ",$COMPOSE_PROFILES," in *,chat,*) chat=1;; esac + if [ -n "$chat" ]; then + for v in CHAT_HOST KINO_RELEASE CHAT_OAUTH2_CLIENT_SECRET; do + [ -n "${!v}" ] || missing="$missing $v" + done + [ -z "$missing" ] || { echo "COMPOSE_PROFILES has chat, but not set:$missing"; exit 1; } + fi + umask 077 mkdir -p "$STAGE" # Interpolated by compose: hosts, versions, profiles. No secret. @@ -137,6 +152,8 @@ jobs: PORTAL_DHD=$PORTAL_DHD COMPOSE_PROFILES=$COMPOSE_PROFILES PAY_HOST=$PAY_HOST + CHAT_HOST=$CHAT_HOST + KINO_RELEASE=$KINO_RELEASE RAUTHY_HOST=$RAUTHY_HOST OIDC_ISSUER=$OIDC_ISSUER EOF @@ -186,6 +203,12 @@ jobs: if [ -n "${!name}" ]; then echo "$name=${!name}"; fi done } > "$STAGE/kron.env" + # kino: the secret it signs people in with. Only with the + # profile, so a stack without the chat gets no file. + if [ -n "$chat" ]; then + echo "OAUTH2_CLIENT_SECRET=$CHAT_OAUTH2_CLIENT_SECRET" > "$STAGE/kino.env" + sed -i 's/\$/$$/g' "$STAGE/kino.env" + fi # Rauthy's secrets. The first admin is the vel's first person. cat > "$STAGE/rauthy.env" <$`, 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`) | +| `CHAT_HOST`, `KINO_RELEASE` | variable | repo | the chat: where it answers (`samtaler.tomtervel.no`, DNS in `dns/`, a kasse Caddy block) and which kino image (`0.1.2`). Needed once `COMPOSE_PROFILES` has `chat` | +| `CHAT_OAUTH2_CLIENT_SECRET` | secret | repo | the secret of the Rauthy client `chat` ("Rauthy" below), which kino signs people in with | | `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 | @@ -217,6 +220,36 @@ Going live, in order: Nothing here touches the Vippsnummer (500396): people may keep paying there, and the treasurer marks those by hand as before. +## The chat + +The vel's conversations are uhhm/kino at `samtaler.tomtervel.no`: every +group the content names is a room, and the site decides who gets in. +kino signs people in at Rauthy as the client `chat`, dials the site +over dhd/1 beside gdo and kron, and keeps what is said in a file of its +own (`kino_data`). What was said in the old chat did not come along. + +To turn it on: + +1. Set the variables `CHAT_HOST` (`samtaler.tomtervel.no`) and + `KINO_RELEASE` (`0.1.2`), and the secret `CHAT_OAUTH2_CLIENT_SECRET`: + the Rauthy client `chat` exists from the old chat, with the redirect + `https://samtaler.tomtervel.no/auth/callback`; its secret is in + Rauthy's admin, under the client. +2. Install the `deploy-tomtervel` from this repo on kasse (its first + lines say how): the one before this does not put `kino.env` in + place. +3. Add `chat` to `COMPOSE_PROFILES` (`pay,chat`) and run the deploy. + kino starts and says its key in its log (`podman logs + infrastructure_kino_1`). The site does not know that key yet, so + kino has no rooms to show until the next step. +4. Add that key to the variable `DHD_KEYS` as `=rooms,watch,may`, + beside gdo's and kron's, and run the deploy again. Portal starts with + the new key, and kino's next dial is taken. + +`https://samtaler.tomtervel.no/` then asks for a sign-in, and a member +of a group finds its room. The host Caddy's block and the DNS record +are the old chat's, on the same port. + ## Rauthy [Rauthy](https://github.com/sebadob/rauthy) at `RAUTHY_HOST` diff --git a/compose.yml b/compose.yml index a74d5e0..bcac937 100644 --- a/compose.yml +++ b/compose.yml @@ -111,6 +111,8 @@ services: - "127.0.0.1:3050:3000" # kron (betaling.tomtervel.no -> here). - "127.0.0.1:3080:3080" + # kino (samtaler.tomtervel.no -> here). + - "127.0.0.1:3070:3070" portal: build: @@ -228,9 +230,40 @@ services: # 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 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. + # The vel's conversations (uhhm/kino): every group the content names is + # a room, and the site decides who gets in. kino dials the site over + # dhd/1 as gdo and kron do, and keeps its history in a file of its own + # in kino_data; what was said in the old chat (cnats, on NATS) did not + # come along. Reached by kasse's host Caddy on the published 3070 + # (samtaler.tomtervel.no). A profile, since it needs its sign-in + # secret: COMPOSE_PROFILES has `chat` once CHAT_HOST, KINO_RELEASE and + # CHAT_OAUTH2_CLIENT_SECRET are set. + # + # The site must name kino's key in DHD_KEYS as `=rooms,watch,may`; + # kino says its key as it starts (README.md, "The chat"). + kino: + profiles: ["chat"] + image: project.uhhm.no/uhhm/kino:${KINO_RELEASE:-no-tag-set} + restart: unless-stopped + network_mode: "service:net" + env_file: + - path: kino.env + required: false + environment: + PORTAL_DHD: ${PORTAL_DHD:-} + # Must be the portal's own: a room names its site. + SITE_NAME: tomtervel + # Rauthy, and the client it knows the chat as. + OIDC_ISSUER: ${OIDC_ISSUER} + OAUTH2_CLIENT_ID: chat + PUBLIC_URL: https://${CHAT_HOST:-no-host-set} + COOKIE_SECURE: "true" + # 3070, not 3000: in the shared network 3000 is portal's. + LEPTOS_SITE_ADDR: 0.0.0.0:3070 + volumes: + - kino_data:/var/lib/kino + depends_on: + - portal # Where uploads go: the pictures and documents a desk attaches, and what # `portal import` brings in. One node on this host, reachable only inside @@ -249,6 +282,7 @@ volumes: portal_data: gdo_data: kron_data: + kino_data: caddy_data: caddy_config: nats_data: diff --git a/deploy-tomtervel b/deploy-tomtervel index a432486..feedfbe 100644 --- a/deploy-tomtervel +++ b/deploy-tomtervel @@ -19,8 +19,8 @@ root=/srv/tomtervel/infrastructure stage=/var/lib/gitea-runner/tomtervel-env files=(.env portal.env) # Written only when the site runs what needs it (Rauthy, the money -# service under the pay profile). -optional=(rauthy.env kron.env) +# service under the pay profile, the chat under the chat profile). +optional=(rauthy.env kron.env kino.env) [ -d "$root/.git" ] || { echo "no checkout at $root - bootstrap it first" >&2; exit 1; } for f in "${files[@]}"; do