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:
8 files changed
+368
-260
No files matched your search
+45
-36
@@ -52,48 +52,52 @@ the board, who takes them off on the event's page.
|
||||
|
||||
Rehearsed on 2026-11-24 against the live site: 91 records and 15 sign-ups
|
||||
(25 guests) across, all 53 files fetched, 15 mails taken by the sink,
|
||||
nothing differing. Steps 1 to 3 are done or can be done any time; 4 on
|
||||
are the switch itself, with the site down from 4 to 6.
|
||||
nothing differing. The 1.0 stack was run the same day beside the live
|
||||
one, with made-up records: mail out, a payment settled, content loaded,
|
||||
and gdo and kron back after portal was restarted and made anew.
|
||||
|
||||
1. **Programs that speak to a 1.0 site.** 1.0 has no NATS; the programs
|
||||
beside the site dial it over `dhd/1`. As of 2026-11-24 none of what
|
||||
the stack runs can:
|
||||
- **gdo** (mail): v0.3.1 is NATS only. The `one-oh` branch dials a
|
||||
site, built against portal v1.0.0-rc.10.
|
||||
- **kron** (Vipps): 0.2.0 is NATS only. `one-oh` likewise.
|
||||
- **cnats** (the chat) is NATS only. Its successor kino 0.1.1 dials a
|
||||
site, but is published as an Arch package, not an image, and takes
|
||||
no history over.
|
||||
The site is down from step 4 until step 7 is done.
|
||||
|
||||
Until gdo has a release, a 1.0 site here sends no mail at all: no
|
||||
invites, no confirmations. That is what the switch waits for.
|
||||
2. **The stack for 1.0** (`compose.yml`, `deploy.yml`, a pull request of
|
||||
its own once step 1 has releases to try it with): a volume for the
|
||||
store, `PORTAL_STORE`, `DHD_KEYS` naming each program's key,
|
||||
`DHD_TOKENS` with the hash of `LOAD_TOKEN` named `load`, the programs
|
||||
in portal's network namespace (they dial loopback), sealed backups
|
||||
(`PORTAL_BACKUP_TO`), and NATS out.
|
||||
3. **`LOAD_TOKEN`** as a secret of the tomtervel org: the content repo's
|
||||
reload posts it to `/dhd/1/load`.
|
||||
4. **`move.sh rehearse`** once more on the day, then **`move.sh move`**.
|
||||
The 0.19 site is down from here.
|
||||
5. **The 1.0 stack up**: `PORTAL_RELEASE=v1.0.2` (the org's variable),
|
||||
questions#48 merged so `main` is the 1.0 content, then the deploy.
|
||||
The reload that merge sets off fails while the site is down; the site
|
||||
reads `main` as it starts.
|
||||
6. **Look**: `/hva-skjer` says 25 of 100 seats, a document opens, a
|
||||
sign-in lands on `/styret` with its lists, and a test invite arrives.
|
||||
7. **Rauthy's groups**: from `komiteer_<id>_medlem` and `_leder` to the
|
||||
1. **Programs that dial a 1.0 site**: kron's image `0.3.0`, and a
|
||||
commit of uhhm/gdo with its NATS mode gone, which the stack builds
|
||||
gdo from. The chat does not come along: cnats speaks NATS only, and
|
||||
kino has no image.
|
||||
2. **Org secret `LOAD_TOKEN`** (`openssl rand -hex 24`, `gt secret set
|
||||
LOAD_TOKEN -o tomtervel`), and this repo's variables `GDO_RELEASE`
|
||||
(that commit), `KRON_RELEASE=0.3.0`, `COMPOSE_PROFILES=pay`.
|
||||
3. **On kasse, the images the stack will run**, so the move can read
|
||||
their keys: from a checkout of this branch, `podman build -t
|
||||
localhost/tomtervel-gdo:<GDO_RELEASE> --build-arg
|
||||
GDO_RELEASE=<GDO_RELEASE> gdo`, and `podman pull
|
||||
project.uhhm.no/uhhm/kron:0.3.0`. And the new `deploy-tomtervel` in
|
||||
`/usr/local/bin` (its first lines say how).
|
||||
4. **`move.sh rehearse`** once more, then **`move.sh move`**, both with
|
||||
`GDO_IMAGE` and `KRON_IMAGE` naming those images. `move` stops the
|
||||
0.19 site, and ends with `DHD_KEYS` and `PORTAL_DHD`.
|
||||
5. **Those two** as variables of this repo, and the org's
|
||||
`PORTAL_RELEASE=v1.0.2`.
|
||||
6. **The content**: questions#48 merged, so `main` is the 1.0 content.
|
||||
Its reload fails, since the site is down; the site reads `main` as it
|
||||
starts.
|
||||
7. **The stack**: this merged, which deploys it. `podman stop
|
||||
tomtervel-cnats-1` afterwards; `tomtervel-nats-1` is left running.
|
||||
8. **Look**: `/hva-skjer` says 25 of 100 seats, a document opens, a
|
||||
sign-in lands on `/styret` with its lists, the log says gdo and kron
|
||||
are beside the site, and a test invite arrives.
|
||||
9. **Rauthy's groups**: from `komiteer_<id>_medlem` and `_leder` to the
|
||||
group named as its page (questions' README has the names).
|
||||
|
||||
### Going back
|
||||
|
||||
- **Before step 5**: `podman start tomtervel-portal-1`, and remove
|
||||
`tomtervel_portal_data`. Nothing else was touched.
|
||||
- **After**: `PORTAL_RELEASE` and the stack back to what they were, and
|
||||
the content's `main` reverted. NATS still holds everything 0.19 had as
|
||||
long as `tomtervel_nats_data` is kept, so keep it for some weeks. What
|
||||
people did on 1.0 in between does not go back with it.
|
||||
- **After**: the stack's merge and the content's reverted, the old
|
||||
`deploy-tomtervel` installed, and the variables back to what they
|
||||
were (`PORTAL_RELEASE=v0.19.2`, `GDO_RELEASE=v0.2.0`,
|
||||
`KRON_RELEASE=0.1.0`, `COMPOSE_PROFILES=chat,pay`), then the deploy.
|
||||
NATS still holds everything 0.19 had as long as `tomtervel_nats_data`
|
||||
is kept, so keep it for some weeks. What people did on 1.0 in between
|
||||
does not go back with it.
|
||||
|
||||
### What does not come across
|
||||
|
||||
@@ -103,5 +107,10 @@ are the switch itself, with the site down from 4 to 6.
|
||||
site's list of them starts empty.
|
||||
- **Each record's history.** A record arrives with one event saying it
|
||||
was imported, and its date.
|
||||
- **The chat's history,** and **payments under way in kron** (none may be
|
||||
open when the switch is made: a fee paid in between would not be seen).
|
||||
- **The chat,** and its history.
|
||||
- **Payments under way in kron.** The new kron starts with none open: a
|
||||
pay link mailed before the move no longer settles. A household that
|
||||
owed its fee is marked paid by the treasurer when the money is seen,
|
||||
or signs up again for a new link.
|
||||
- **The site's backups** are off until `PORTAL_BACKUP_TO` is set
|
||||
(README.md, "Backups").
|
||||
+40
-3
@@ -17,6 +17,12 @@
|
||||
# which counts it and lets it go. A store started on without that step
|
||||
# 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.
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
@@ -36,7 +42,15 @@ stage=tomtervel-move-stage
|
||||
port=3997; sink_port=3996
|
||||
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)
|
||||
|
||||
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
|
||||
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
|
||||
[ "$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"
|
||||
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
|
||||
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"
|
||||
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)
|
||||
@@ -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 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_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/" \
|
||||
"$image" >/dev/null
|
||||
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
|
||||
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
|
||||
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
|
||||
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"
|
||||
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)"
|
||||
else
|
||||
echo "the 1.0 store is in $volume; the export is in $work (root only)"
|
||||
|
||||
Reference in new issue
Block a user