Dockerfile 990 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. WORKDIR ${PWD}
  14. ADD go.* ${PWD}
  15. RUN go mod download
  16. ADD . ${PWD}
  17. FROM fs AS make-protos
  18. RUN make protos
  19. FROM make-protos AS make-bins
  20. RUN --mount=type=cache,target=/root/.cache/go-build \
  21. GOOS=${TARGET_OS} \
  22. GOARCH=${TARGET_ARCH} \
  23. make bins
  24. FROM make-protos AS make-xbins
  25. RUN --mount=type=cache,target=/root/.cache/go-build \
  26. make xbins
  27. FROM scratch AS protos
  28. COPY --from=make-protos /go/src/github.com/docker/api/backend/v1/*.pb.go .
  29. FROM scratch AS bins
  30. COPY --from=make-bins /go/src/github.com/docker/api/bin/* .
  31. FROM scratch AS xbins
  32. COPY --from=make-xbins /go/src/github.com/docker/api/bin/* .