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

+40 -3
View File
@@ -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)"