Skip to content

Commit f3ef2ab

Browse files
committed
Fix Architecture metadata in Dockerfiles for distroless base image references
1 parent 275670a commit f3ef2ab

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
1919
ARG builder_image
2020

21+
# Build architecture
22+
ARG ARCH
23+
2124
# Ignore Hadolint rule "Always tag the version of an image explicitly."
2225
# It's an invalid finding since the image is explicitly set in the Makefile.
2326
# https://github.com/hadolint/hadolint/wiki/DL3006
@@ -60,7 +63,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
6063
-o manager ${package}
6164

6265
# Production image
63-
FROM gcr.io/distroless/static:nonroot
66+
FROM --platform=${ARCH} gcr.io/distroless/static:nonroot
6467
WORKDIR /
6568
COPY --from=builder /workspace/manager .
6669
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies

cmd/clusterctl/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
1919
ARG builder_image
2020

21+
# Build architecture
22+
ARG ARCH
23+
2124
# Ignore Hadolint rule "Always tag the version of an image explicitly."
2225
# It's an invalid finding since the image is explicitly set in the Makefile.
2326
# https://github.com/hadolint/hadolint/wiki/DL3006
@@ -60,7 +63,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
6063
-o clusterctl ${package}
6164

6265
# Production image
63-
FROM gcr.io/distroless/static:nonroot
66+
FROM --platform=${ARCH} gcr.io/distroless/static:nonroot
6467
WORKDIR /
6568
COPY --from=builder /workspace/clusterctl .
6669
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies

test/extension/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
1919
ARG builder_image
2020

21+
# Build architecture
22+
ARG ARCH
23+
2124
# Ignore Hadolint rule "Always tag the version of an image explicitly."
2225
# It's an invalid finding since the image is explicitly set in the Makefile.
2326
# https://github.com/hadolint/hadolint/wiki/DL3006
@@ -63,7 +66,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
6366
-o /workspace/extension ${package}
6467

6568
# Production image
66-
FROM gcr.io/distroless/static:nonroot
69+
FROM --platform=${ARCH} gcr.io/distroless/static:nonroot
6770
WORKDIR /
6871
COPY --from=builder /workspace/extension .
6972
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies

test/infrastructure/docker/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
1818
ARG builder_image
1919

20+
# Build architecture
21+
ARG ARCH
22+
2023
# Ignore Hadolint rule "Always tag the version of an image explicitly."
2124
# It's an invalid finding since the image is explicitly set in the Makefile.
2225
# https://github.com/hadolint/hadolint/wiki/DL3006
@@ -57,6 +60,9 @@ COPY . .
5760
# Essentially, change directories into CAPD
5861
WORKDIR /workspace/test/infrastructure/docker
5962

63+
# Build
64+
ARG ARCH
65+
6066
# Build the CAPD manager using the compiler cache folder
6167
RUN --mount=type=cache,target=/root/.cache/go-build \
6268
--mount=type=cache,target=/go/pkg/mod \
@@ -67,7 +73,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
6773
# Ignore Hadolint rule "Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag."
6874
# https://github.com/hadolint/hadolint/wiki/DL3007
6975
# hadolint ignore=DL3007
70-
FROM gcr.io/distroless/static:latest
76+
FROM --platform=${ARCH} gcr.io/distroless/static:latest
7177

7278
WORKDIR /
7379
COPY --from=builder /workspace/manager .

0 commit comments

Comments
 (0)