forked from yylt/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-linkerd
30 lines (26 loc) · 998 Bytes
/
Dockerfile-linkerd
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
# Precompile key slow-to-build dependencies
FROM --platform=$TARGETPLATFORM golang:1.19-alpine as go-deps
WORKDIR /linkerd-build
COPY go.mod go.sum ./
COPY bin/install-deps bin/
RUN go mod download
RUN ./bin/install-deps $TARGETPLATFORM
## compile controller service
FROM go-deps as golang
WORKDIR /linkerd-build
COPY controller/gen controller/gen
COPY pkg pkg
COPY controller controller
COPY charts/patch charts/patch
COPY charts/partials charts/partials
COPY multicluster multicluster
# Generate static templates
# TODO: `go generate` does not honor -mod=readonly
RUN go generate -mod=readonly ./pkg/charts/static
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETPLATFORM go build -o /out/controller -tags prod -mod=readonly -ldflags "-s -w" ./controller/cmd
## package runtime
FROM busybox
COPY --from=golang /out/controller /controller
# for heartbeat (https://versioncheck.linkerd.io/version.json)
COPY --from=golang /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENTRYPOINT ["/controller"]