feat(builder): declare multi-arch builds with ARCHES

Project architecture lists belong in makefile.builder, not .env.builder.
deb/push-deb fan out when ARCH is omitted; Docker platforms derive from
ARCHES. Legacy makefiles without ARCHES keep the old single-arch behavior.
This commit is contained in:
2026-09-08 16:31:53 +08:00
parent c248c3f0e3
commit aa7a265e76
9 changed files with 433 additions and 36 deletions
+26 -2
View File
@@ -17,7 +17,8 @@ usage() {
# DOCKER_REGISTRY Required (or --registry)
# DOCKER_REPOSITORY Optional, default: git repository name (or --repository)
# IMAGE_TAG Optional, default: version.sh --docker (or --tag)
# PLATFORMS Optional, default: linux/amd64 (or --platform)
# PLATFORMS Optional. Else makefile.builder ARCHES mapped to
# linux/<arch>,… ; else linux/amd64 (or --platform)
# DOCKER_DOCKERFILE Optional, default: Dockerfile (--file)
# DOCKER_CONTEXT Optional, default: . (--context)
# DOCKER_BUILDER Optional buildx builder name (--builder)
@@ -53,7 +54,7 @@ fi
registry=${DOCKER_REGISTRY:-}
repository=${DOCKER_REPOSITORY:-$git_repo_name}
tag=${IMAGE_TAG:-}
platform=${PLATFORMS:-linux/amd64}
platform=${PLATFORMS:-}
dockerfile=${DOCKER_DOCKERFILE:-Dockerfile}
build_context=${DOCKER_CONTEXT:-.}
builder=${DOCKER_BUILDER:-}
@@ -126,6 +127,29 @@ if [[ "$tag" == latest && ${ALLOW_LATEST:-0} != 1 && "$mode" == push ]]; then
echo "Set ALLOW_LATEST=1 only when the user explicitly asked for 'latest'." >&2
exit 3
fi
if [[ -z "$platform" ]]; then
if [[ -n "$project_root" && -f "$project_root/makefile.builder" ]]; then
arches=$(make -C "$project_root" -f makefile.builder -s --no-print-directory arches 2>/dev/null || true)
mapped=
for arch in $arches; do
case "$arch" in
amd64|arm64)
if [[ -n "$mapped" ]]; then
mapped="$mapped,linux/$arch"
else
mapped="linux/$arch"
fi
;;
*)
echo "Error: unsupported ARCHES entry from makefile.builder: $arch" >&2
exit 2
;;
esac
done
platform=$mapped
fi
platform=${platform:-linux/amd64}
fi
if [[ "$mode" == load && "$platform" == *,* ]]; then
echo "Error: --load cannot be combined with multiple platforms: $platform" >&2
exit 2