forked from prometheus-operator/prometheus-operator
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile
30 lines (21 loc) · 989 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
ARG ARCH=amd64
ARG OS=linux
ARG GOLANG_BUILDER=1.23
FROM quay.io/prometheus/golang-builder:${GOLANG_BUILDER}-base AS builder
WORKDIR /workspace
COPY . .
# Download Go dependencies to reuse the Go cache in subsequent builds.
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download -x && go mod verify
# Build
ARG GOARCH
ENV GOARCH=${GOARCH}
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build make operator
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest
COPY --from=builder workspace/operator /bin/operator
# On busybox 'nobody' has uid `65534'
USER 65534
LABEL org.opencontainers.image.source="https://github.com/prometheus-operator/prometheus-operator" \
org.opencontainers.image.url="https://prometheus-operator.dev/" \
org.opencontainers.image.documentation="https://prometheus-operator.dev/" \
org.opencontainers.image.licenses="Apache-2.0"
ENTRYPOINT ["/bin/operator"]