2020-04-22 10:04:11 +02:00
|
|
|
# syntax = docker/dockerfile:experimental
|
|
|
|
ARG GO_VERSION=1.14.2
|
|
|
|
|
|
|
|
FROM golang:${GO_VERSION} AS fs
|
|
|
|
ARG TARGET_OS=unknown
|
|
|
|
ARG TARGET_ARCH=unknown
|
|
|
|
ARG PWD=$GOPATH/src/github.com/docker/api
|
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
|
|
|
make \
|
|
|
|
git \
|
|
|
|
protobuf-compiler \
|
|
|
|
libprotobuf-dev
|
2020-04-27 10:17:10 +02:00
|
|
|
RUN go get github.com/golang/protobuf/protoc-gen-go && \
|
2020-05-02 18:54:03 +02:00
|
|
|
go get golang.org/x/tools/cmd/goimports && \
|
2020-04-27 10:17:10 +02:00
|
|
|
go get gotest.tools/gotestsum
|
2020-04-22 10:04:11 +02:00
|
|
|
WORKDIR ${PWD}
|
|
|
|
ADD go.* ${PWD}
|
|
|
|
RUN go mod download
|
|
|
|
ADD . ${PWD}
|
|
|
|
|
|
|
|
FROM fs AS make-protos
|
2020-05-01 15:27:27 +02:00
|
|
|
RUN make -f builder.Makefile protos
|
2020-04-22 10:04:11 +02:00
|
|
|
|
2020-05-01 15:27:27 +02:00
|
|
|
FROM make-protos AS make-cli
|
2020-04-22 10:04:11 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
GOOS=${TARGET_OS} \
|
|
|
|
GOARCH=${TARGET_ARCH} \
|
2020-05-01 15:27:27 +02:00
|
|
|
make -f builder.Makefile cli
|
2020-04-22 10:04:11 +02:00
|
|
|
|
2020-05-04 10:32:30 +02:00
|
|
|
FROM make-protos AS make-cross
|
2020-04-22 10:04:11 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
2020-05-04 10:32:30 +02:00
|
|
|
make -f builder.Makefile cross
|
2020-04-22 10:04:11 +02:00
|
|
|
|
|
|
|
FROM scratch AS protos
|
2020-05-02 18:54:03 +02:00
|
|
|
COPY --from=make-protos /go/src/github.com/docker/api .
|
2020-04-22 10:04:11 +02:00
|
|
|
|
2020-05-01 15:27:27 +02:00
|
|
|
FROM scratch AS cli
|
|
|
|
COPY --from=make-cli /go/src/github.com/docker/api/bin/* .
|
|
|
|
|
2020-05-04 10:32:30 +02:00
|
|
|
FROM scratch AS cross
|
|
|
|
COPY --from=make-cross /go/src/github.com/docker/api/bin/* .
|
2020-04-22 10:04:11 +02:00
|
|
|
|
2020-05-01 15:27:27 +02:00
|
|
|
FROM make-protos as test
|
|
|
|
RUN make -f builder.Makefile test
|