2022-12-05 10:40:57 +00:00
|
|
|
FROM golang:1.19.3-bullseye AS cacher
|
2022-02-02 05:36:20 +00:00
|
|
|
|
2022-12-05 10:40:57 +00:00
|
|
|
ENV GOPATH /go
|
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
|
|
RUN --mount=type=cache,target=/var/cache/apt \
|
|
|
|
apt update && apt install -y make zstd curl unzip
|
2022-02-02 05:36:20 +00:00
|
|
|
RUN mkdir -p /build
|
|
|
|
WORKDIR /build
|
|
|
|
|
2022-12-05 10:40:57 +00:00
|
|
|
# install newer protoc
|
|
|
|
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v21.10/protoc-21.10-linux-aarch_64.zip && \
|
|
|
|
unzip *.zip -d /usr/local && rm -v *.zip && protoc --version
|
|
|
|
|
|
|
|
RUN go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
|
|
|
|
|
|
|
|
COPY ./go.mod .
|
|
|
|
COPY ./go.sum .
|
|
|
|
|
|
|
|
RUN --mount=type=cache,target=/go/pkg go mod download -x
|
|
|
|
RUN go env
|
|
|
|
## build image
|
|
|
|
FROM golang:1.19.3-bullseye AS builder
|
2022-02-02 05:36:20 +00:00
|
|
|
|
2022-12-05 10:40:57 +00:00
|
|
|
COPY --from=cacher /usr/local /usr/local
|
|
|
|
COPY --from=cacher /usr/bin /usr/bin
|
|
|
|
COPY --from=cacher /go/bin /go/bin
|
|
|
|
COPY --from=cacher /build /build
|
|
|
|
|
|
|
|
WORKDIR /build
|
2022-02-02 05:36:20 +00:00
|
|
|
|
|
|
|
COPY ./ ./
|
2022-12-05 10:40:57 +00:00
|
|
|
RUN --mount=type=cache,target=/go/pkg go mod download -x && go mod tidy && cd mfer && go generate .
|
|
|
|
RUN --mount=type=cache,target=/go/pkg make mfer.cmd && go mod vendor
|
|
|
|
RUN tar -c . | zstdmt -19 > /src.tzst
|
|
|
|
|
|
|
|
## lint image
|
|
|
|
FROM golangci/golangci-lint:v1.50.1 AS linter
|
2022-02-02 05:47:30 +00:00
|
|
|
|
2022-12-05 10:40:57 +00:00
|
|
|
COPY --from=cacher /build /build
|
|
|
|
WORKDIR /build
|
|
|
|
RUN golangci-lint run
|
2022-02-02 05:47:30 +00:00
|
|
|
|
2022-02-02 06:17:13 +00:00
|
|
|
FROM scratch
|
2022-12-05 10:40:57 +00:00
|
|
|
COPY --from=builder /src.tzst /src.tzst
|
2022-12-04 09:19:21 +00:00
|
|
|
COPY --from=builder /build/mfer.cmd /mfer
|
2022-02-02 06:17:13 +00:00
|
|
|
ENTRYPOINT ["/mfer"]
|
|
|
|
|