2020-04-22 11:04:11 +03: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 11:17:10 +03:00
|
|
|
RUN go get github.com/golang/protobuf/protoc-gen-go && \
|
|
|
|
go get gotest.tools/gotestsum
|
2020-04-22 11:04:11 +03:00
|
|
|
WORKDIR ${PWD}
|
|
|
|
ADD go.* ${PWD}
|
|
|
|
RUN go mod download
|
|
|
|
ADD . ${PWD}
|
|
|
|
|
|
|
|
FROM fs AS make-protos
|
|
|
|
RUN make protos
|
|
|
|
|
|
|
|
FROM make-protos AS make-bins
|
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
GOOS=${TARGET_OS} \
|
|
|
|
GOARCH=${TARGET_ARCH} \
|
|
|
|
make bins
|
|
|
|
|
2020-04-27 11:17:10 +03:00
|
|
|
FROM make-protos as make-test
|
|
|
|
RUN make test
|
|
|
|
|
2020-04-22 11:04:11 +03:00
|
|
|
FROM make-protos AS make-xbins
|
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
make xbins
|
|
|
|
|
|
|
|
FROM scratch AS protos
|
2020-04-30 13:42:11 +03:00
|
|
|
COPY --from=make-protos /go/src/github.com/docker/api/backend/v1/*.pb.go ./backend/v1/
|
|
|
|
COPY --from=make-protos /go/src/github.com/docker/api/compose/v1/*.pb.go ./compose/v1/
|
2020-05-01 11:49:35 +03:00
|
|
|
COPY --from=make-protos /go/src/github.com/docker/api/containers/v1/*.pb.go ./containers/v1/
|
2020-04-30 13:42:11 +03:00
|
|
|
COPY --from=make-protos /go/src/github.com/docker/api/cli/v1/*.pb.go ./cli/v1/
|
2020-04-22 11:04:11 +03:00
|
|
|
|
|
|
|
FROM scratch AS bins
|
|
|
|
COPY --from=make-bins /go/src/github.com/docker/api/bin/* .
|
|
|
|
|
|
|
|
FROM scratch AS xbins
|
|
|
|
COPY --from=make-xbins /go/src/github.com/docker/api/bin/* .
|