################################################################################ #2345678911234567892123456789312345678941234567895123456789612345678971234567898 ################################################################################ FROM golang:1.19.3-bullseye AS builder ENV GOPATH /go ENV DEBIAN_FRONTEND noninteractive RUN --mount=type=cache,target=/var/cache/apt \ apt update && \ apt install -y make zstd unzip && \ mkdir /build WORKDIR /tmp # install newer protoc COPY ./builddeps/* ./ RUN unzip protoc-*-linux-$(uname -m).zip -d /usr/local && \ protoc --version && \ mkdir -p /go/pkg/mod && \ cd /go/pkg/mod && \ tar xvf /tmp/modcache.tar && \ cd / && \ go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 && \ go install -v mvdan.cc/gofumpt@latest && \ go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 && \ rm -rf /tmp/* WORKDIR /build COPY ./go.mod ./go.sum . RUN \ go mod download -x ################################################################################ #### caching phase done ################################################################################ WORKDIR /build COPY ./Makefile ./.golangci.yml ./go.mod ./go.sum . COPY ./internal ./internal COPY ./bin/gitrev.sh ./bin/gitrev.sh COPY ./mfer ./mfer COPY ./cmd ./cmd RUN find /build ARG GITREV unknown RUN \ cd mfer && go generate . && cd .. && \ GOPACKAGESDEBUG=true golangci-lint run ./... && \ make mfer.cmd RUN go mod vendor && tar -c . | zstdmt -19 > /src.tzst ################################################################################ #2345678911234567892123456789312345678941234567895123456789612345678971234567898 ################################################################################ ## final image ################################################################################ FROM scratch # we put all the source into the final image for posterity, it's small COPY --from=builder /src.tzst /src.tzst COPY --from=builder /build/mfer.cmd /mfer ENTRYPOINT ["/mfer"]