build-images.sh: pass KVITT_VERSION_CODE to the server image build
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
# Usage: infra/build-images.sh [tag] tag defaults to the short git SHA of HEAD; `latest` is always tagged too.
|
||||
#
|
||||
# Images (D-104, D-120): ${KVITT_REGISTRY}/kvitt-server (context: the repository root, D-132; server/Dockerfile
|
||||
# builds the web client too) and kvitt-backup (infra/backup).
|
||||
# builds the web client too, given KVITT_VERSION_CODE = the commit count, as the workflow does) and kvitt-backup (infra/backup).
|
||||
# KVITT_REGISTRY and the optional credentials come from infra/secrets/registry.env (git-ignored):
|
||||
# KVITT_REGISTRY=gitea.lan/jacobh2
|
||||
# KVITT_REGISTRY_USER=<gitea user> optional
|
||||
@@ -26,6 +26,7 @@ fi
|
||||
|
||||
tag="${1:-$(git rev-parse --short HEAD)}"
|
||||
[[ "$tag" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]] || { echo "build-images.sh: not a valid tag: $tag" >&2; exit 2; }
|
||||
version_code="$(git rev-list --count HEAD)" # the web's version code (D-132), as in the Gitea workflow
|
||||
|
||||
reg_file="$repo_root/infra/secrets/registry.env"
|
||||
default_registry="gitea.lan/jacobh2" # SPEC §10.3, D-104
|
||||
@@ -71,8 +72,10 @@ for spec in "${images[@]}"; do
|
||||
IFS='|' read -r name context dockerfile <<< "$spec"
|
||||
ref="$registry/$name"
|
||||
echo "== $ref:$tag"
|
||||
extra_args=()
|
||||
[[ "$name" == kvitt-server ]] && extra_args+=(--build-arg "KVITT_VERSION_CODE=$version_code")
|
||||
if [[ $engine == podman ]]; then
|
||||
podman build --platform linux/arm64 -f "$dockerfile" -t "$ref:$tag" -t "$ref:latest" "$context"
|
||||
podman build --platform linux/arm64 ${extra_args[@]+"${extra_args[@]}"} -f "$dockerfile" -t "$ref:$tag" -t "$ref:latest" "$context"
|
||||
if [[ $push == 1 ]]; then
|
||||
podman push --tls-verify=false "$ref:$tag"
|
||||
podman push --tls-verify=false "$ref:latest"
|
||||
@@ -80,10 +83,10 @@ for spec in "${images[@]}"; do
|
||||
elif [[ $push == 1 ]]; then
|
||||
# --provenance=false: push a plain image manifest, as Podman does, rather than an index with an attestation
|
||||
# entry (same choice as the Gitea workflow).
|
||||
docker buildx build --builder kvitt-http-builder --platform linux/arm64 --provenance=false -f "$dockerfile" \
|
||||
docker buildx build --builder kvitt-http-builder --platform linux/arm64 --provenance=false ${extra_args[@]+"${extra_args[@]}"} -f "$dockerfile" \
|
||||
-t "$ref:$tag" -t "$ref:latest" --push "$context"
|
||||
else
|
||||
docker buildx build --platform linux/arm64 -f "$dockerfile" -t "$ref:$tag" -t "$ref:latest" --load "$context"
|
||||
docker buildx build --platform linux/arm64 ${extra_args[@]+"${extra_args[@]}"} -f "$dockerfile" -t "$ref:$tag" -t "$ref:latest" --load "$context"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user