-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
48 lines (37 loc) · 1.46 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
40
41
42
43
44
45
46
47
48
# Build the manager binary
FROM golang:1.16 as builder
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY 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 main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY cmd/webhook/ cmd/webhook/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARM=$(if [ "$TARGETVARIANT" = "v7" ]; then echo "7"; fi) GOARCH=$TARGETARCH GO111MODULE=on go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARM=$(if [ "$TARGETVARIANT" = "v7" ]; then echo "7"; fi) GOARCH=$TARGETARCH GO111MODULE=on go build -o kms-vault-validating-webhook cmd/webhook/main.go
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static-debian10:nonroot-amd64
ARG GIT_COMMIT="unspecified"
LABEL GIT_COMMIT=$GIT_COMMIT
ARG GIT_TAG=""
LABEL GIT_TAG=$GIT_TAG
ARG COMMIT_TIMESTAMP="unspecified"
LABEL COMMIT_TIMESTAMP=$COMMIT_TIMESTAMP
ARG AUTHOR_EMAIL="unspecified"
LABEL AUTHOR_EMAIL=$AUTHOR_EMAIL
ARG SIGNATURE_KEY="undefined"
LABEL SIGNATURE_KEY=$SIGNATURE_KEY
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/kms-vault-validating-webhook .
USER nonroot:nonroot
ENTRYPOINT ["/manager"]