-
Notifications
You must be signed in to change notification settings - Fork 30
/
Containerfile.gatekeeper-operator
42 lines (36 loc) · 1.55 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
36
37
38
39
40
41
42
# Based on ./gatekeeper-operator/Dockerfile
# Build the manager binary
FROM registry.access.redhat.com/ubi9/go-toolset:1.21.11-9 as builder
USER 0
COPY drift-detection/detector.sh /detector.sh
# Check to see if we need to react to any uptream changes
COPY drift-cache /drift-cache
WORKDIR /tmp
COPY gatekeeper-operator/Dockerfile .
RUN /detector.sh ./Dockerfile /drift-cache/gatekeeper-operator/Dockerfile
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"]