From 494e76dc7064d6d9ac20c203d715be8c193b01eb Mon Sep 17 00:00:00 2001 From: Astra Date: Wed, 9 Sep 2026 15:06:19 +0100 Subject: [PATCH] build: recreate and start the pod containers after building build.sh now, after building the image, recreates owpengram-server and owpengram-admin in the pod (podman create --replace) and starts them. Guards that the pod and .env exist; NO_DEPLOY=1 keeps the old build-only behaviour, POD overrides the pod name. --- build.sh | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 3a065e43..6a176a0c 100755 --- a/build.sh +++ b/build.sh @@ -1,15 +1,17 @@ #!/usr/bin/env bash -# Build the owpengram-server container image, stamping the current git state -# into the binary (shows up in telesrv's startup log as git_commit/git_branch/ -# git_tree_state/build_time). .containerignore excludes .git, so go build's -# automatic VCS stamping can't see the repo - the values are passed in here. +# 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. # # 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) +# NO_DEPLOY=1 ./build.sh build the image only, don't touch containers set -euo pipefail cd "$(dirname "$0")" IMAGE="${IMAGE:-owpengram-server}" +POD="${POD:-owpengram}" podman build \ --build-arg GIT_COMMIT="$(git rev-parse HEAD)" \ @@ -20,3 +22,29 @@ podman build \ -f Containerfile \ "$@" \ . + +if [ "${NO_DEPLOY:-0}" = "1" ]; then + echo "built $IMAGE (NO_DEPLOY=1, containers unchanged)" + exit 0 +fi + +if ! podman pod exists "$POD"; then + echo "error: pod '$POD' does not exist - create it first, e.g.:" >&2 + echo " podman pod create --name $POD -p 127.0.0.1:2401:2401" >&2 + exit 1 +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}}'