#!/bin/sh # Build the CI image from ci/images/alkane-ci.Dockerfile, push it to the Gitea # registry, and pin the pushed digest in ci/runner-image.txt and every # workflow (ci/check-runner-image.py enforces the pin). # # Run on the workstation, which holds the registry credential; it is passed to # a throwaway Docker config that is deleted afterwards, never to a runner. # ci/images/build-image.sh TAG e.g. ci/images/build-image.sh windows-2026-11-02 set -eu TAG=${1:?usage: build-image.sh TAG} REPO=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) REGISTRY=gitea.bluefla.re IMAGE=$REGISTRY/blueflare/alkane-ci TOKEN_FILE=${GITEA_TOKEN_FILE:-$HOME/.config/gitea/token} cd "$REPO" DOCKER_CONFIG=$(mktemp -d) export DOCKER_CONFIG trap 'rm -rf "$DOCKER_CONFIG"' 0 user=$(curl -sS --config - "https://$REGISTRY/api/v1/user" </dev/null DOCKER_BUILDKIT=1 docker build -f ci/images/alkane-ci.Dockerfile -t "$IMAGE:$TAG" . docker push "$IMAGE:$TAG" >/dev/null digest=$(docker inspect --format '{{range .RepoDigests}}{{println .}}{{end}}' "$IMAGE:$TAG" \ | grep "^$IMAGE@sha256:" | head -1) [ -n "$digest" ] || { echo "no registry digest for $IMAGE:$TAG" >&2; exit 1; } old=$(cat ci/runner-image.txt) printf '%s\n' "$digest" > ci/runner-image.txt grep -rl "$old" .gitea/workflows | while read -r f; do python3 - "$f" "$old" "$digest" <<'PY' import pathlib, sys p, old, new = pathlib.Path(sys.argv[1]), sys.argv[2], sys.argv[3] p.write_text(p.read_text().replace(old, new)) PY done python3 ci/check-runner-image.py echo "pinned $digest"