Something went wrong. Try again.
gotta store my records
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#!/usr/bin/env bash# One-time droplet setup for the ghcr autopush path# (.tangled/workflows/deploy-microvm.yml): installs the timer that polls for a# newly published image and rolls the app container onto it. Idempotent. Run# from the repo root:## deploy/setup-autopull.sh## If ghcr.io/nmokkenstorm/crate is a private package, log in on the droplet# first, or every pull fails with a 403:# ssh root@<droplet> 'docker login ghcr.io -u <user>'set -euo pipefail
droplet="${CRATE_DROPLET:-root@206.189.15.37}"
echo "installing the pull timer on $droplet"# Every file sync-config.sh keeps in step has to be here too, or the droplet# starts from a copy the next pull then overwrites.tar cf - -C deploy crate-pull.service crate-pull.timer Caddyfile docker-compose.yml sync-config.sh \ | ssh -o ConnectTimeout=20 "$droplet" " set -e tar xf - -C /etc/systemd/system install -d /opt/crate/deploy install -m 644 /etc/systemd/system/Caddyfile /tmp/crate.Caddyfile docker run --rm -v /tmp/crate.Caddyfile:/etc/caddy/Caddyfile:ro caddy:2 caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile install -m 644 /tmp/crate.Caddyfile /opt/crate/Caddyfile install -m 644 /etc/systemd/system/docker-compose.yml /opt/crate/docker-compose.yml install -m 755 /etc/systemd/system/sync-config.sh /opt/crate/deploy/sync-config.sh rm /etc/systemd/system/Caddyfile /etc/systemd/system/docker-compose.yml /etc/systemd/system/sync-config.sh cd /opt/crate && docker compose config -q chown root:root /etc/systemd/system/crate-pull.{service,timer} chmod 644 /etc/systemd/system/crate-pull.{service,timer} systemctl daemon-reload systemctl enable --now crate-pull.timer cd /opt/crate && docker compose up -d --force-recreate caddy"
# The timer re-resolves whatever tag the container runs; a pinned sha would# never move. Setting it back to a sha is how a rollback freezes.echo "pointing the app at the moving tag"ssh -o ConnectTimeout=20 "$droplet" " set -e cd /opt/crate sed -i 's/^CRATE_TAG=.*/CRATE_TAG=latest/' .env grep -q '^CRATE_TAG=latest\$' .env || { echo 'no CRATE_TAG line in .env' >&2; exit 1; } docker compose up -d app systemctl list-timers crate-pull.timer --no-pager"