Skip to content
Snippets Groups Projects
Commit d4997b07 authored by kaiyou's avatar kaiyou
Browse files

Rewrite the Dockerfile entirely

parent 7fe53d92
No related branches found
No related tags found
No related merge requests found
Pipeline #33140 passed
FROM golang:1.22 AS golangbuild
ARG TARGETARCH
FROM golang:1.22
WORKDIR /usr/src/app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN make
# This builder stage it's only because we need a command
# to create a symlink and reduce the size of the image
FROM gcr.io/distroless/static-debian11:debug-nonroot AS builder
ARG TARGETARCH
SHELL ["/busybox/sh", "-c"]
COPY --from=golangbuild --chown=nonroot:nonroot --chmod=0755 /usr/src/app/bin/manager bin/
RUN ln -sf bin/manager_${TARGETARCH} manager
FROM gcr.io/distroless/static-debian12:nonroot
ARG VERSION="dev"
ARG TARGETARCH
ENV SUMMARY="CloudNativePG Operator Container Image." \
DESCRIPTION="This Docker image contains CloudNativePG Operator."
LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.display-name="$SUMMARY" \
io.k8s.description="$DESCRIPTION" \
name="CloudNativePG Operator" \
vendor="CloudNativePG Contributors" \
url="https://cloudnative-pg.io/" \
version="$VERSION" \
release="1"
WORKDIR /
# Needs to copy the entire content, otherwise, it will not
# copy the symlink properly.
COPY --from=builder /home/nonroot/ .
USER 65532:65532
RUN make build \
&& mv bin/manager /
ENTRYPOINT ["/manager"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment