Changes for init/tidy
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -2,12 +2,17 @@
|
||||
|
||||
FROM --platform=${BUILDPLATFORM} golang:1.16.5-alpine AS base
|
||||
WORKDIR /src
|
||||
ENV CGO_ENABLED=0
|
||||
ENV CGO_ENABLED=1
|
||||
RUN apk update
|
||||
RUN apk add gcc g++
|
||||
RUN mkdir /out
|
||||
|
||||
FROM base AS buildbase
|
||||
COPY go.* .
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
go mod download
|
||||
|
||||
FROM base AS build
|
||||
FROM buildbase AS build
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
RUN --mount=target=. \
|
||||
@@ -31,6 +36,24 @@ RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/golangci-lint \
|
||||
golangci-lint run --timeout 10m0s ./...
|
||||
|
||||
FROM base as mod-init-base
|
||||
WORKDIR /out
|
||||
COPY . .
|
||||
ENV MODNAME example
|
||||
RUN rm -f go.sum go.mod ; go mod init "${MODNAME}" && go mod tidy
|
||||
|
||||
FROM base AS mod-tidy
|
||||
WORKDIR /out
|
||||
COPY . .
|
||||
RUN go mod tidy
|
||||
|
||||
FROM scratch AS mod-init
|
||||
COPY --from=mod-init-base /out/go.mod /go.mod
|
||||
COPY --from=mod-init-base /out/go.sum /go.sum
|
||||
|
||||
FROM scratch AS tidy
|
||||
COPY --from=mod-tidy /out/go.sum /go.sum
|
||||
|
||||
FROM scratch AS unit-test-coverage
|
||||
COPY --from=unit-test /out/cover.out /cover.out
|
||||
|
||||
|
||||
Reference in New Issue
Block a user