nixos: app stacks on Podman, unchanged

The apps keep deploying themselves: their CI copies a compose file and
a .env and runs docker compose as user deploy. `docker` is now the real
Docker CLI against rootful Podman's socket, so compose, inspect and
logs behave as before and every user sees the same containers.

Their compose files still expect the storage stack's network and the
hosts postgres and garage. On ops every container resolves those two
names to the host, where the native services run, and an empty storage
network exists, so nothing in the app repositories has to change for
the move itself.

Tried on the rehearsal pair with the real asxpio and datacenterbingo
images on the restored database and Garage (mail and IndexNow
disabled): both serve through Traefik, and a local compose build works.

One thing does need the app repositories: Podman ignores the
HEALTHCHECK of OCI-format images, which is what the CI builds, so the
deploy's wait for "healthy" would time out. Declaring the healthcheck
in each compose file fixes it, also under Docker; see MIGRATION.md.

ops-data.sh now also moves the monitoring history, Traefik's
certificates and the app directories, and pulls the images again.

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-17 05:11:17 +04:00
commit fa46d26f89
Signed by: asxpi
GPG key ID: 4F8851660FA4121B

View file

@ -46,6 +46,32 @@ if [ -f "$src/opt/traefik/letsencrypt/acme.json" ]; then
install -o traefik -g traefik -m 600 "$src/opt/traefik/letsencrypt/acme.json" /var/lib/traefik/acme.json
fi
echo "== Monitoring history (Docker volumes; not in the restic backup)"
mvvol() { # mvvol <volume> <dest> <owner>
if [ -d "$vols/$1/_data" ]; then
rm -rf "$2"; mkdir -p "$(dirname "$2")"
mv "$vols/$1/_data" "$2"; chown -R "$3" "$2"
else
echo " $1: not there (a restore, not a conversion); starting empty"
fi
}
vols=$src/var/lib/docker/volumes
mvvol monitoring_prometheus-data /var/lib/prometheus2/data prometheus:prometheus
mvvol monitoring_loki-data /var/lib/loki loki:loki
if [ -f "$vols/monitoring_grafana-data/_data/grafana.db" ]; then
install -d -o grafana -g grafana /var/lib/grafana/data
mv "$vols/monitoring_grafana-data/_data/grafana.db" /var/lib/grafana/data/grafana.db
chown grafana:grafana /var/lib/grafana/data/grafana.db
fi
echo "== App stacks (compose file and .env each; CI deploys them later)"
for app in asxpio datacenterbingo blog czsk vhpbot-prod vhpbot-dev; do
[ -d "$src/opt/$app" ] || continue
rm -rf "/opt/$app"; mv "$src/opt/$app" "/opt/$app"
chown -R deploy:deploy "/opt/$app"
done
[ ! -d "$src/root/backups" ] || { rm -rf /root/backups; mv "$src/root/backups" /root/backups; }
echo "== Starting"
touch /var/lib/.data-in-place
systemctl start postgresql.service
@ -63,4 +89,16 @@ echo "== Forgejo: hooks and SSH keys for the new paths"
forgejo-admin regenerate hooks
forgejo-admin regenerate keys
echo "== Done. Check: systemctl --failed; garage status; a git clone over SSH and HTTPS"
echo "== App stacks: images again (Docker's image store does not carry over)"
for app in asxpio datacenterbingo blog czsk vhpbot-prod vhpbot-dev; do
[ -f "/opt/$app/docker-compose.yml" ] || continue
echo " $app"
if grep -q "^ *build:" "/opt/$app/docker-compose.yml" && ! grep -q "image: *git" "/opt/$app/docker-compose.yml"; then
runuser -l deploy -c "cd /opt/$app && docker compose up -d --build" || echo " $app FAILED"
else
runuser -l deploy -c "cd /opt/$app && docker compose pull -q && docker compose up -d" || echo " $app FAILED"
fi
done
echo "== Done. Check: systemctl --failed; garage status; a git clone over SSH and HTTPS;"
echo " docker ps (as deploy): every app healthy; Grafana on gf.asxp.io"