Fix ARG scoping in Dockerfile.distroless

ARG declarations before FROM are only available within the FROM
instruction and go out of scope afterward. Re-declare ARCH and OS
after FROM so they're available for the COPY instructions.

This fixes the build failure where ${OS}-${ARCH} resolved to empty
strings, causing "not found" errors for .build/-/prometheus.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This commit is contained in:
Julien Pivotto 2026-01-20 12:21:01 +01:00
parent 629bd3c5d5
commit 3733a14b87

View file

@ -1,11 +1,12 @@
ARG ARCH="amd64"
ARG OS="linux"
ARG DISTROLESS_ARCH="amd64" ARG DISTROLESS_ARCH="amd64"
# Use DISTROLESS_ARCH for base image selection (handles armv7->arm mapping). # Use DISTROLESS_ARCH for base image selection (handles armv7->arm mapping).
FROM gcr.io/distroless/static-debian13:nonroot-${DISTROLESS_ARCH} FROM gcr.io/distroless/static-debian13:nonroot-${DISTROLESS_ARCH}
# Base image sets USER to 65532:65532 (nonroot user). # Base image sets USER to 65532:65532 (nonroot user).
ARG ARCH="amd64"
ARG OS="linux"
LABEL org.opencontainers.image.authors="The Prometheus Authors" LABEL org.opencontainers.image.authors="The Prometheus Authors"
LABEL org.opencontainers.image.vendor="Prometheus" LABEL org.opencontainers.image.vendor="Prometheus"
LABEL org.opencontainers.image.title="Prometheus" LABEL org.opencontainers.image.title="Prometheus"