From 2bdd8f4ba0156e8b40055fa547acdeec78436114 Mon Sep 17 00:00:00 2001 From: hime Date: Wed, 20 Nov 2024 21:46:49 +0000 Subject: [PATCH] Add ARM dependencies to metadata prefetch Dockerfile. --- cmd/metadata_prefetch/Dockerfile | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/cmd/metadata_prefetch/Dockerfile b/cmd/metadata_prefetch/Dockerfile index 74bf24a2..9b11cf37 100644 --- a/cmd/metadata_prefetch/Dockerfile +++ b/cmd/metadata_prefetch/Dockerfile @@ -26,16 +26,31 @@ RUN make metadata-prefetch BINDIR=/bin FROM gke.gcr.io/debian-base:bookworm-v1.0.4-gke.2 AS debian # go/gke-releasing-policies#base-images -FROM gcr.io/distroless/base-debian12 AS output-image +# We use `gcr.io/distroless/base` because it includes glibc. +FROM gcr.io/distroless/base-debian12 AS distroless-base +# The distroless amd64 image has a target triplet of x86_64 +FROM distroless-base AS distroless-amd64 +ENV LIB_DIR_PREFIX=x86_64 +ENV LD_LINUX_FILE=/lib64/ld-linux-x86-64.so.2 +ENV LIB_DIR=/lib64/ + +# The distroless arm64 image has a target triplet of aarch64 +FROM distroless-base AS distroless-arm64 +ENV LIB_DIR_PREFIX aarch64 +ENV LD_LINUX_FILE /lib/ld-linux-aarch64.so.1 +ENV LIB_DIR /lib/ + +# go/gke-releasing-policies#base-images +FROM distroless-$TARGETARCH AS output-image # Copy existing binaries. COPY --from=debian /bin/ls /bin/ls # Copy dependencies. -COPY --from=debian /lib/x86_64-linux-gnu/libselinux.so.1 /lib/x86_64-linux-gnu/libselinux.so.1 -COPY --from=debian /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6 -COPY --from=debian /lib/x86_64-linux-gnu/libpcre2-8.so.0 /lib/x86_64-linux-gnu/libpcre2-8.so.0 -COPY --from=debian /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 +COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libselinux.so.1 /lib/${LIB_DIR_PREFIX}-linux-gnu/libselinux.so.1 +COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libc.so.6 /lib/${LIB_DIR_PREFIX}-linux-gnu/libc.so.6 +COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre2-8.so.0 /lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre2-8.so.0 +COPY --from=debian ${LD_LINUX_FILE} ${LIB_DIR} # Validate dependencies FROM output-image AS validator-image