forked from kube-vip/kube-vip-cloud-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
24 lines (18 loc) · 788 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
# syntax=docker/dockerfile:1.4
FROM golang:1.19 as builder
COPY . /src/
WORKDIR /src
RUN --mount=type=cache,target=/root/.local/share/golang \
--mount=type=cache,target=/go/pkg/mod \
go mod download
ENV LD_FLAGS="-s -w -extldflags -static"
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.local/share/golang \
CGO_ENABLED=0 GOOS=linux go build -ldflags "$LD_FLAGS" -o kube-vip-cloud-provider
# 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:nonroot
COPY --from=builder /src/kube-vip-cloud-provider /
USER nonroot:nonroot
CMD ["/kube-vip-cloud-provider"]