ci: refuse arm64 images that contain non-arm64 binaries (base-arch guard + ELF verification)
The in-house python:3.12-slim mirror tag was still a flattened amd64-only manifest, so the linux/arm64 build ran on an amd64 base and published x86-64 binaries labelled arm64 (haproxy-manager-base:latest, :2026.11.6-rc). - Dockerfile: fail the build when dpkg arch != TARGETARCH (no-op when correct) - scripts/verify-image-arch.py (+ test): ELF e_machine of haproxy, bash, python, psutil .so per platform digest - build-push.yaml: verify amd64 (fatal) and arm64 before assembling; an arm64 mismatch is excluded from the tags and fails the job Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
3ce1dc8662
commit
56404f4777
4 files changed
+180
-1
No files matched your search
+11
@@ -10,6 +10,17 @@
|
||||
# Future improvement: a scheduled Gitea Action that does the above automatically.
|
||||
FROM repo.anhonesthost.net/cloud-hosting-platform/python:3.12-slim
|
||||
|
||||
# Base-architecture guard. If the mirrored base tag is a single-platform
|
||||
# (flattened amd64) manifest instead of a multi-arch index, buildx silently uses
|
||||
# that amd64 base for a linux/arm64 build, every RUN below executes natively as
|
||||
# x86-64, and the result is x86-64 binaries labelled arm64 (2026-11-19:
|
||||
# haproxy-manager-base:latest). TARGETARCH is set by buildx (empty on the legacy
|
||||
# builder, where the check is skipped). On a correct build this is a no-op.
|
||||
ARG TARGETARCH
|
||||
RUN if [ -n "${TARGETARCH}" ] && [ "$(dpkg --print-architecture)" != "${TARGETARCH}" ]; then \
|
||||
echo "FATAL: base image is $(dpkg --print-architecture) but this build targets ${TARGETARCH}; the in-house python:3.12-slim mirror is not a multi-arch index (re-run mirror-base-image.yaml)" >&2; exit 1; \
|
||||
fi
|
||||
|
||||
# image.source is what ghcr.io uses to link the package to a GitHub repo
|
||||
# sidebar; pointing at the public GitHub mirror enables that linking. The
|
||||
# canonical source-of-truth git remote is still Gitea, but Gitea's registry
|
||||
|
||||
Reference in new issue
Block a user