Dockerfile 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # syntax = docker/dockerfile:experimental
  2. ARG GO_VERSION=1.14.2
  3. FROM golang:${GO_VERSION} AS fs
  4. ARG TARGET_OS=unknown
  5. ARG TARGET_ARCH=unknown
  6. ARG PWD=$GOPATH/src/github.com/docker/api
  7. RUN apt-get update && apt-get install --no-install-recommends -y \
  8. make \
  9. git \
  10. protobuf-compiler \
  11. libprotobuf-dev
  12. RUN go get github.com/golang/protobuf/protoc-gen-go && \
  13. go get golang.org/x/tools/cmd/goimports && \
  14. go get gotest.tools/gotestsum
  15. WORKDIR ${PWD}
  16. ADD go.* ${PWD}
  17. RUN go mod download
  18. ADD . ${PWD}
  19. FROM fs AS make-protos
  20. RUN make protos
  21. FROM make-protos AS make-bins
  22. RUN --mount=type=cache,target=/root/.cache/go-build \
  23. GOOS=${TARGET_OS} \
  24. GOARCH=${TARGET_ARCH} \
  25. make bins
  26. FROM make-protos as make-test
  27. RUN make test
  28. FROM make-protos AS make-xbins
  29. RUN --mount=type=cache,target=/root/.cache/go-build \
  30. make xbins
  31. FROM scratch AS protos
  32. COPY --from=make-protos /go/src/github.com/docker/api .
  33. FROM scratch AS bins
  34. COPY --from=make-bins /go/src/github.com/docker/api/bin/* .
  35. FROM scratch AS xbins
  36. COPY --from=make-xbins /go/src/github.com/docker/api/bin/* .