forked from open-policy-agent/gatekeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (28 loc) · 1.02 KB
/
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
31
32
33
34
35
36
37
38
39
ARG BUILDPLATFORM="linux/amd64"
ARG BUILDERIMAGE="golang:1.15-alpine"
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
ARG BASEIMAGE="gcr.io/distroless/static:nonroot-amd64"
FROM --platform=$BUILDPLATFORM $BUILDERIMAGE as builder
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG LDFLAGS
ENV GO111MODULE=on\
CGO_ENABLED=0
WORKDIR /go/src/github.com/open-policy-agent/gatekeeper
COPY pkg/ pkg/
COPY third_party/ third_party/
COPY vendor/ vendor/
COPY main.go main.go
COPY apis/ apis/
COPY go.mod .
RUN export GOOS=$TARGETOS && \
export GOARCH=$TARGETARCH && \
GOARM=$(echo ${TARGETPLATFORM} | cut -d / -f3); export GOARM=${GOARM:1} && \
go build -mod vendor -a -ldflags "${LDFLAGS:--X github.com/open-policy-agent/gatekeeper/pkg/version.Version=latest}" -o manager main.go
FROM $BASEIMAGE
WORKDIR /
COPY --from=builder /go/src/github.com/open-policy-agent/gatekeeper/manager .
USER nonroot:nonroot
ENTRYPOINT ["/manager"]