compose/Dockerfile

53 lines
1.2 KiB
Docker
Raw Normal View History

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