FROM golang:alpine as builder ENV CGO_ENABLED 0 RUN go env -w GOCACHE=/go-cache RUN go env -w GOMODCACHE=/gomod-cache COPY . /build WORKDIR /build RUN --mount=type=cache,target=/gomod-cache --mount=type=cache,target=/go-cache go build -o test ./cmd FROM scratch COPY --from=builder /build/test / ENTRYPOINT ["./test"]