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>
47 lines
1.7 KiB
Bash
Executable file
47 lines
1.7 KiB
Bash
Executable file
#!/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 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 restart the services
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
IMAGE="${IMAGE:-owpengram-server}"
|
|
POD="${POD:-owpengram}"
|
|
|
|
podman build \
|
|
--build-arg GIT_COMMIT="$(git rev-parse HEAD)" \
|
|
--build-arg GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" \
|
|
--build-arg GIT_TREE_STATE="$(git diff --quiet && echo clean || echo dirty)" \
|
|
--build-arg BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
|
-t "$IMAGE" \
|
|
-f Containerfile \
|
|
"$@" \
|
|
.
|
|
|
|
if [ "${NO_DEPLOY:-0}" = "1" ]; then
|
|
echo "built $IMAGE (NO_DEPLOY=1, services unchanged)"
|
|
exit 0
|
|
fi
|
|
|
|
if ! podman pod exists "$POD"; then
|
|
echo "pod '$POD' does not exist - creating it"
|
|
podman pod create --name "$POD" \
|
|
-p 2398:2398 \
|
|
-p 127.0.0.1:2600:2600 \
|
|
-p 2400:2400 \
|
|
-p 2500:2500 \
|
|
-p 12399:12399/udp \
|
|
-p 12400:12400/udp \
|
|
-p 12500-12999:12500-12999/udp
|
|
fi
|
|
|
|
systemctl restart owpengram-server.service owpengram-admin.service
|
|
systemctl --no-pager status owpengram-server.service owpengram-admin.service
|