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 4ca35d2000
commit 1f6f25074a

View file

@ -1,12 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Build the owpengram-server container image (stamping the current git state into # 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 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...] # Usage: ./build.sh [extra podman build args...]
# IMAGE=my/tag ./build.sh override the image tag (default: owpengram-server) # IMAGE=my/tag ./build.sh override the image tag (default: owpengram-server)
# POD=name ./build.sh override the pod name (default: owpengram) # 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 set -euo pipefail
cd "$(dirname "$0")" cd "$(dirname "$0")"
@ -24,7 +27,7 @@ podman build \
. .
if [ "${NO_DEPLOY:-0}" = "1" ]; then if [ "${NO_DEPLOY:-0}" = "1" ]; then
echo "built $IMAGE (NO_DEPLOY=1, containers unchanged)" echo "built $IMAGE (NO_DEPLOY=1, services unchanged)"
exit 0 exit 0
fi fi
@ -39,18 +42,6 @@ if ! podman pod exists "$POD"; then
-p 12400:12400/udp \ -p 12400:12400/udp \
-p 12500-12999:12500-12999/udp -p 12500-12999:12500-12999/udp
fi 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 \ systemctl restart owpengram-server.service owpengram-admin.service
--pull never --env-file .env -v owpengram_serverdata:/data \ systemctl --no-pager status owpengram-server.service owpengram-admin.service
"$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}}'