-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
26 lines (19 loc) · 796 Bytes
/
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
# syntax=docker/dockerfile:1.3
ARG GO_VERSION
FROM --platform=${TARGETPLATFORM} golang:${GO_VERSION}-alpine AS base
WORKDIR /go/src/cert-manager-webhook-dnsmadeasy
COPY go.* .
# ENV GO111MODULE=on
RUN --mount=type=cache,target=/go/pkg/mod \
apk add --no-cache git ca-certificates && \
go mod download
FROM base AS build
ARG TARGETOS
ARG TARGETARCH
RUN --mount=readonly,target=. --mount=type=cache,target=/go/pkg/mod \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -a -o /go/bin/webhook -ldflags '-w -extldflags "-static"' .
# ------------------------------
FROM scratch AS image
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /go/bin/webhook /usr/local/bin/webhook
ENTRYPOINT ["/usr/local/bin/webhook"]