latest
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
2022-12-05 14:40:57 +04:00
parent bd4b135e17
commit a9f23c79d2
7 changed files with 80 additions and 39 deletions

View File

@@ -1,29 +1,47 @@
## lint image
FROM golangci/golangci-lint:v1.50.1
FROM golang:1.19.3-bullseye AS cacher
ENV GOPATH /go
ENV DEBIAN_FRONTEND noninteractive
RUN --mount=type=cache,target=/var/cache/apt \
apt update && apt install -y make zstd curl unzip
RUN mkdir -p /build
WORKDIR /build
COPY ./ ./
RUN golangci-lint run
## build image:
FROM sneak/mfer-build AS builder
# 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
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
COPY go.mod .
COPY go.sum .
COPY ./ ./
# don't lint again during build because there's no golangci-lint in this
# image and we already did it in a previous stage
#RUN make lint
RUN make mfer.cmd
#RUN go mod vendor
RUN tar -c . | bzip2 > /src.tbz2
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
COPY --from=cacher /build /build
WORKDIR /build
RUN golangci-lint run
FROM scratch
COPY --from=builder /src.tbz2 /src.tbz2
COPY --from=builder /src.tzst /src.tzst
COPY --from=builder /build/mfer.cmd /mfer
ENTRYPOINT ["/mfer"]