blob: 155ed766d446937d25d5da6f018158cc3c1a524c [file] [log] [blame]
Giorgi Lekveishvili0048a782023-06-20 18:32:21 +04001# syntax=docker/dockerfile:1.3
2ARG GO_VERSION
3FROM --platform=${TARGETPLATFORM} golang:${GO_VERSION}-alpine AS base
4
5WORKDIR /go/src/cert-manager-webhook-gandi
6COPY go.* .
7
8RUN --mount=type=cache,target=/go/pkg/mod \
9 apk add --no-cache git ca-certificates && \
10 go mod download
11
12FROM base AS build
13ARG TARGETOS
14ARG TARGETARCH
15
16RUN --mount=readonly,target=. --mount=type=cache,target=/go/pkg/mod \
17 GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -a -o /go/bin/webhook -ldflags '-w -extldflags "-static"' .
18
19FROM scratch AS image
20COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
21COPY --from=build /go/bin/webhook /usr/local/bin/webhook
22
23ENTRYPOINT ["/usr/local/bin/webhook"]