-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile-cert
21 lines (17 loc) · 1.22 KB
/
Dockerfile-cert
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
FROM docker.io/library/golang:1.20 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY . .
# Build
RUN commit=$(git rev-parse HEAD) ; \
version=$(git describe --tags --match='v*' --abbrev=14); \
mkdir -p _bin && \
CGO_ENABLED=0 go build -o _bin/webhook -trimpath -ldflags '-w -s -X github.com/cert-manager/cert-manager/pkg/util.AppVersion=${version} -X github.com/cert-manager/cert-manager/pkg/util.AppGitCommit=${commit}' cmd/webhook/main.go && \
CGO_ENABLED=0 go build -o _bin/cainjector -trimpath -ldflags '-w -s -X github.com/cert-manager/cert-manager/pkg/util.AppVersion=${version} -X github.com/cert-manager/cert-manager/pkg/util.AppGitCommit=${commit}' cmd/cainjector/main.go && \
CGO_ENABLED=0 go build -o _bin/controller -trimpath -ldflags '-w -s -X github.com/cert-manager/cert-manager/pkg/util.AppVersion=${version} -X github.com/cert-manager/cert-manager/pkg/util.AppGitCommit=${commit}' cmd/controller/main.go
# Use distroless as minimal base image to package the manager binary
FROM busybox
WORKDIR /
COPY --from=builder /workspace/_bin/webhook /usr/bin/webhook
COPY --from=builder /workspace/_bin/cainjector /usr/bin/cainjector
COPY --from=builder /workspace/_bin/controller /usr/bin/controller