Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix Architecture metadata in Dockerfiles for distroless base image references #7070

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
ARG builder_image

# Build architecture
ARG ARCH

# Ignore Hadolint rule "Always tag the version of an image explicitly."
# It's an invalid finding since the image is explicitly set in the Makefile.
# https://github.com/hadolint/hadolint/wiki/DL3006
Expand Down Expand Up @@ -60,7 +63,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-o manager ${package}

# Production image
FROM gcr.io/distroless/static:nonroot
FROM --platform=${ARCH} gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
Expand Down
5 changes: 4 additions & 1 deletion cmd/clusterctl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
ARG builder_image

# Build architecture
ARG ARCH

# Ignore Hadolint rule "Always tag the version of an image explicitly."
# It's an invalid finding since the image is explicitly set in the Makefile.
# https://github.com/hadolint/hadolint/wiki/DL3006
Expand Down Expand Up @@ -60,7 +63,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-o clusterctl ${package}

# Production image
FROM gcr.io/distroless/static:nonroot
FROM --platform=${ARCH} gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/clusterctl .
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
Expand Down
5 changes: 4 additions & 1 deletion test/extension/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
ARG builder_image

# Build architecture
ARG ARCH

# Ignore Hadolint rule "Always tag the version of an image explicitly."
# It's an invalid finding since the image is explicitly set in the Makefile.
# https://github.com/hadolint/hadolint/wiki/DL3006
Expand Down Expand Up @@ -63,7 +66,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-o /workspace/extension ${package}

# Production image
FROM gcr.io/distroless/static:nonroot
FROM --platform=${ARCH} gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/extension .
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
Expand Down
8 changes: 7 additions & 1 deletion test/infrastructure/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
ARG builder_image

# Build architecture
ARG ARCH

# Ignore Hadolint rule "Always tag the version of an image explicitly."
# It's an invalid finding since the image is explicitly set in the Makefile.
# https://github.com/hadolint/hadolint/wiki/DL3006
Expand Down Expand Up @@ -57,6 +60,9 @@ COPY . .
# Essentially, change directories into CAPD
WORKDIR /workspace/test/infrastructure/docker

# Build
ARG ARCH

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

WORKDIR /
COPY --from=builder /workspace/manager .
Expand Down