mirror of https://github.com/linkerd/linkerd2.git
35 lines
1.5 KiB
Plaintext
35 lines
1.5 KiB
Plaintext
## compile binaries
|
|
FROM gcr.io/linkerd-io/go-deps:98181d11 as golang
|
|
WORKDIR /linkerd-build
|
|
COPY cli cli
|
|
COPY charts charts
|
|
|
|
COPY controller/k8s controller/k8s
|
|
COPY controller/api controller/api
|
|
COPY controller/gen controller/gen
|
|
COPY pkg pkg
|
|
RUN mkdir -p /out
|
|
|
|
# Generate static templates
|
|
# TODO: `go generate` does not honor -mod=readonly
|
|
RUN go generate -mod=readonly ./pkg/charts/static
|
|
|
|
# Cache builds without version info
|
|
RUN CGO_ENABLED=0 GOOS=darwin go build -o /out/linkerd-darwin -tags prod -mod=readonly -ldflags "-s -w" ./cli
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/linkerd-linux -tags prod -mod=readonly -ldflags "-s -w" ./cli
|
|
RUN CGO_ENABLED=0 GOOS=windows go build -o /out/linkerd-windows -tags prod -mod=readonly -ldflags "-s -w" ./cli
|
|
|
|
ARG LINKERD_VERSION
|
|
ENV GO_LDFLAGS="-s -w -X github.com/linkerd/linkerd2/pkg/version.Version=${LINKERD_VERSION}"
|
|
RUN CGO_ENABLED=0 GOOS=darwin go build -o /out/linkerd-darwin -tags prod -mod=readonly -ldflags "${GO_LDFLAGS}" ./cli
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/linkerd-linux -tags prod -mod=readonly -ldflags "${GO_LDFLAGS}" ./cli
|
|
RUN CGO_ENABLED=0 GOOS=windows go build -o /out/linkerd-windows -tags prod -mod=readonly -ldflags "${GO_LDFLAGS}" ./cli
|
|
|
|
## export without sources & dependencies
|
|
FROM scratch
|
|
COPY LICENSE /linkerd/LICENSE
|
|
COPY --from=golang /out /out
|
|
# `ENTRYPOINT` prevents `docker build` from otherwise failing with "Error
|
|
# response from daemon: No command specified."
|
|
ENTRYPOINT ["/out/linkerd-linux"]
|