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
59 lines
2.1 KiB
Bash
59 lines
2.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Tomter Vel's stack, brought up from its own repo. This is the whole of
|
|
# what CI may do as root for the vel: pull main, put the env files the
|
|
# deploy workflow wrote in place, and bring the compose project up. It
|
|
# takes no arguments, so there is nothing for a workflow to point
|
|
# somewhere else.
|
|
#
|
|
# The env files come from the repo's and org's Actions variables and
|
|
# secrets: the workflow writes them, as the runner, into $stage (the
|
|
# runner's own, 0700), and this script moves them into the checkout as
|
|
# root's, 0600, and leaves nothing behind in $stage.
|
|
#
|
|
# Install: sudo install -m 0755 -o root -g root \
|
|
# deploy-tomtervel /usr/local/bin/deploy-tomtervel
|
|
# Grant: gitea-runner ALL=(root) NOPASSWD: /usr/local/bin/deploy-tomtervel
|
|
set -euo pipefail
|
|
|
|
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)
|
|
|
|
[ -d "$root/.git" ] || { echo "no checkout at $root - bootstrap it first" >&2; exit 1; }
|
|
for f in "${files[@]}"; do
|
|
[ -s "$stage/$f" ] || { echo "no $stage/$f - the deploy workflow writes it" >&2; exit 1; }
|
|
done
|
|
cd "$root"
|
|
|
|
git fetch --quiet origin main
|
|
git reset --hard --quiet origin/main
|
|
|
|
for f in "${files[@]}"; do
|
|
install -m 0600 -o root -g root "$stage/$f" "$root/$f"
|
|
rm -f "$stage/$f"
|
|
done
|
|
for f in "${optional[@]}"; do
|
|
[ -s "$stage/$f" ] || continue
|
|
install -m 0600 -o root -g root "$stage/$f" "$root/$f"
|
|
rm -f "$stage/$f"
|
|
done
|
|
|
|
# --build so a bumped PORTAL_RELEASE or GDO_RELEASE is actually fetched.
|
|
podman compose up -d --build
|
|
|
|
# The vel's portal, reached the way the host Caddy reaches it. No
|
|
# forwarded header on purpose: a check that sends the one Caddy sends
|
|
# cannot tell you the site is broken for everything that is not Caddy.
|
|
code=000
|
|
for n in $(seq 1 30); do
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3050/ || true)
|
|
[ "$code" = 200 ] && break
|
|
sleep 2
|
|
done
|
|
podman compose ps --format '{{.Names}} {{.State}}' || true
|
|
echo "portal http $code after $((n * 2))s"
|
|
[ "$code" = 200 ]
|