build.sh: restart via systemd instead of managing containers directly

owpengram-server and owpengram-admin are now systemd-managed units; build.sh
no longer needs to podman create/start them itself, just build the image and
restart the two services so they pick up the new image. The pod itself still
isn't systemd's job, so build.sh keeps ensuring it exists first.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Astra 2026-09-13 22:11:54 +01:00
parent c1c7db325f
commit b565efe9d1

View file

@ -1,12 +1,15 @@
#!/usr/bin/env bash
# Build the owpengram-server container image (stamping the current git state into
# the binary - .containerignore excludes .git, so go build can't see the repo and
# the values are passed in here), then recreate and start the pod containers.
# the values are passed in here), then restart the owpengram-server and
# owpengram-admin systemd services so they pick up the freshly built image.
# Container creation/lifecycle beyond the pod itself is owned by those systemd
# units, not this script.
#
# Usage: ./build.sh [extra podman build args...]
# IMAGE=my/tag ./build.sh override the image tag (default: owpengram-server)
# POD=name ./build.sh override the pod name (default: owpengram)
# NO_DEPLOY=1 ./build.sh build the image only, don't touch containers
# NO_DEPLOY=1 ./build.sh build the image only, don't restart the services
set -euo pipefail
cd "$(dirname "$0")"
@ -24,7 +27,7 @@ podman build \
.
if [ "${NO_DEPLOY:-0}" = "1" ]; then
echo "built $IMAGE (NO_DEPLOY=1, containers unchanged)"
echo "built $IMAGE (NO_DEPLOY=1, services unchanged)"
exit 0
fi
@ -39,18 +42,6 @@ if ! podman pod exists "$POD"; then
-p 12400:12400/udp \
-p 12500-12999:12500-12999/udp
fi
if [ ! -f .env ]; then
echo "error: .env not found (containers are created with --env-file .env)" >&2
exit 1
fi
podman create --replace --pod "$POD" --name owpengram-server --restart unless-stopped \
--pull never --env-file .env -v owpengram_serverdata:/data \
"$IMAGE"
podman create --replace --pod "$POD" --name owpengram-admin --restart unless-stopped \
--pull never --env-file .env --entrypoint /app/telesrv-admin \
"$IMAGE"
podman start owpengram-server owpengram-admin
podman ps --pod --filter "pod=$POD" --format 'table {{.Names}} {{.Status}} {{.Image}}'
systemctl restart owpengram-server.service owpengram-admin.service
systemctl --no-pager status owpengram-server.service owpengram-admin.service