Skip to content

Commit

Permalink
Fix Dockerfile warnings (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
so-sahu authored Aug 13, 2024
1 parent 7d704a4 commit 1c79b7b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.23rc2-bookworm as builder
FROM golang:1.23rc2-bookworm AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -20,14 +20,14 @@ COPY hack/ hack/
ARG TARGETOS
ARG TARGETARCH

FROM builder as ceph-bucket-provider-builder
FROM builder AS ceph-bucket-provider-builder
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/ceph-bucket-provider ./cmd/bucketprovider/main.go


# Start from Kubernetes Debian base.
FROM builder as ceph-volume-provider-builder
FROM builder AS ceph-volume-provider-builder
# Install necessary dependencies

RUN apt update && apt install -y libcephfs-dev librbd-dev librados-dev libc-bin
Expand All @@ -40,7 +40,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot as manager
FROM gcr.io/distroless/static:nonroot AS manager
WORKDIR /
COPY --from=controller /workspace/bin/manager .
USER 65532:65532
Expand All @@ -50,21 +50,21 @@ ENTRYPOINT ["/manager"]


# Since we're leveraging apt to pull in dependencies, we use `gcr.io/distroless/base` because it includes glibc.
FROM gcr.io/distroless/base-debian11 as distroless-base
FROM gcr.io/distroless/base-debian11 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 LIB_DIR_PREFIX_MINUS x86-64
ENV LIB_DIR_PREFIX=x86_64
ENV LIB_DIR_PREFIX_MINUS=x86-64

# The distroless arm64 image has a target triplet of aarch64
FROM distroless-base AS distroless-arm64
ENV LIB_DIR_PREFIX aarch64
ENV LIB_DIR_PREFIX_MINUS aarch64
ENV LIB_DIR_PREFIX=aarch64
ENV LIB_DIR_PREFIX_MINUS=aarch64


FROM busybox:1.36.1-uclibc as busybox
FROM distroless-$TARGETARCH as ceph-volume-provider-image
FROM busybox:1.36.1-uclibc AS busybox
FROM distroless-$TARGETARCH AS ceph-volume-provider-image
WORKDIR /
COPY --from=busybox /bin/sh /bin/sh
COPY --from=busybox /bin/mkdir /bin/mkdir
Expand Down Expand Up @@ -97,7 +97,7 @@ COPY --from=ceph-volume-provider-builder /lib/${LIB_DIR_PREFIX}-linux-gnu/librad
/lib/${LIB_DIR_PREFIX}-linux-gnu/libnl-3.so.200 \
/lib/${LIB_DIR_PREFIX}-linux-gnu/libselinux.so.1 \
/lib/${LIB_DIR_PREFIX}-linux-gnu/libpthread.so.0 \
/lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre2-8.so.0 /lib/${LIB_DIR_PREFIX}-linux-gnu
/lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre2-8.so.0 /lib/${LIB_DIR_PREFIX}-linux-gnu/
RUN mkdir -p /lib64
COPY --from=ceph-volume-provider-builder /lib64/ld-linux-${LIB_DIR_PREFIX_MINUS}.so.2 /lib64/
RUN mkdir -p /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/ceph/
Expand All @@ -107,7 +107,7 @@ COPY --from=ceph-volume-provider-builder /workspace/bin/ceph-volume-provider /ce

# Build stage used for validation of the output-image
# See validate-container-linux-* targets in Makefile
FROM ceph-volume-provider-image as validation-image
FROM ceph-volume-provider-image AS validation-image

COPY --from=busybox /usr/bin/ldd /usr/bin/find /usr/bin/xargs /usr/bin/
COPY --from=builder /workspace/hack/print-missing-deps.sh /print-missing-deps.sh
Expand All @@ -116,14 +116,14 @@ RUN /print-missing-deps.sh


# Final build stage, create the real Docker image with ENTRYPOINT
FROM ceph-volume-provider-image as ceph-volume-provider
FROM ceph-volume-provider-image AS ceph-volume-provider
USER 65532:65532

ENTRYPOINT ["/ceph-volume-provider"]



FROM distroless-base as ceph-bucket-provider
FROM distroless-base AS ceph-bucket-provider
COPY --from=ceph-bucket-provider-builder /workspace/bin/ceph-bucket-provider /ceph-bucket-provider
USER 65532:65532
ENTRYPOINT ["/ceph-bucket-provider"]

0 comments on commit 1c79b7b

Please sign in to comment.