compose-cli/Dockerfile

56 строки
1.2 KiB
Docker
Исходник Обычный вид История

# syntax = docker/dockerfile:experimental
ARG GO_VERSION=1.14.2
FROM golang:${GO_VERSION} AS base
ARG TARGET_OS=unknown
ARG TARGET_ARCH=unknown
ARG PWD=/api
ENV GO111MODULE=on
WORKDIR ${PWD}
ADD go.* ${PWD}
2020-05-14 13:17:06 +03:00
RUN go mod download
ADD . ${PWD}
FROM golang:${GO_VERSION} AS protos-base
ARG TARGET_OS=unknown
ARG TARGET_ARCH=unknown
2020-05-05 00:49:40 +03:00
ARG PWD=/api
ENV GO111MODULE=on
RUN apt-get update && apt-get install --no-install-recommends -y \
protobuf-compiler \
libprotobuf-dev
2020-05-05 00:49:40 +03:00
RUN go get github.com/golang/protobuf/protoc-gen-go@v1.4.1 && \
go get golang.org/x/tools/cmd/goimports
2020-05-05 00:49:40 +03:00
WORKDIR ${PWD}
ADD go.* ${PWD}
ADD . ${PWD}
FROM protos-base AS make-protos
RUN make -f builder.Makefile protos
FROM base AS make-cli
RUN --mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGET_OS} \
GOARCH=${TARGET_ARCH} \
make -f builder.Makefile cli
FROM base AS make-cross
RUN --mount=type=cache,target=/root/.cache/go-build \
2020-05-04 11:32:30 +03:00
make -f builder.Makefile cross
FROM scratch AS protos
2020-05-05 00:50:00 +03:00
COPY --from=make-protos /api .
FROM scratch AS cli
2020-05-05 00:50:00 +03:00
COPY --from=make-cli /api/bin/* .
2020-05-04 11:32:30 +03:00
FROM scratch AS cross
2020-05-05 00:50:00 +03:00
COPY --from=make-cross /api/bin/* .
FROM base as test
RUN make -f builder.Makefile test