owpengram-server/build.sh
Astra 1c477fe32a build: stamp git metadata into the container image
.containerignore excludes .git, so go build's automatic VCS stamping produced
nothing and telesrv logged git_commit/git_branch/git_tree_state/build_time as
"unknown" on startup.

- Containerfile: accept GIT_COMMIT/GIT_BRANCH/GIT_TREE_STATE/BUILD_TIME build
  args and pass them to the gramsrv build via -ldflags -X.
- build.sh: wrapper that fills those args from the current checkout and runs
  podman build.
2026-09-09 14:26:58 +01:00

22 lines
870 B
Bash
Executable file

#!/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.
#
# Usage: ./build.sh [extra podman build args...]
# IMAGE=my/tag ./build.sh # override the image tag (default: owpengram-server)
set -euo pipefail
cd "$(dirname "$0")"
IMAGE="${IMAGE:-owpengram-server}"
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 \
"$@" \
.