-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile.gatekeeper-operator
35 lines (30 loc) · 1.3 KB
/
Containerfile.gatekeeper-operator
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
31
32
33
34
35
# Based on ./gatekeeper-operator/Dockerfile
# Build the manager binary
FROM registry.access.redhat.com/ubi9/go-toolset:1.21.11-7 as builder
USER 0
ENV LDFLAGS="-X ${VERSION_PKG}.gitVersion=v3.15.1-7 \
-X ${VERSION_PKG}.gitCommit=59587323ce32580b4dffba0a09b1ca22109925db \
-X ${VERSION_PKG}.gitTreeState=clean \
-X ${VERSION_PKG}.buildDate="
WORKDIR /workspace
# Copy the Go Modules manifests
COPY gatekeeper-operator/go.mod go.mod
COPY gatekeeper-operator/go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY gatekeeper-operator/main.go main.go
COPY gatekeeper-operator/api/ api/
COPY gatekeeper-operator/controllers/ controllers/
COPY gatekeeper-operator/pkg/ pkg/
# Build
RUN CGO_ENABLED=1 go build -a -ldflags "${LDFLAGS}$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -o manager main.go
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
WORKDIR /
COPY --from=builder /workspace/manager .
RUN microdnf -y update && microdnf -y clean all
USER 65532:65532
ENTRYPOINT ["/manager"]