From 16d8a388cbc53f89fe9fd00363625f9db0191f71 Mon Sep 17 00:00:00 2001 From: "Quentin McGaw (desktop)" Date: Tue, 15 Jun 2021 12:27:32 +0000 Subject: [PATCH] Maintenance: better layer caching - Install g++ in base image before copying code - Install xcputranslate in base image before copying code - Install golangci-lint in base image before copying code - Install golangci-lint using go get directly --- Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01be9e0e..0766bc77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,11 @@ ARG GO_VERSION=1.16 ARG BUILDPLATFORM=linux/amd64 FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base -RUN apk --update add git +RUN apk --update add git g++ ENV CGO_ENABLED=0 +COPY --from=qmcgaw/xcputranslate:v0.4.0 /xcputranslate /usr/local/bin/xcputranslate +ARG GOLANGCI_LINT_VERSION=v1.40.1 +RUN go get github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} WORKDIR /tmp/gobuild COPY go.mod go.sum ./ RUN go mod download @@ -14,15 +17,11 @@ COPY internal/ ./internal/ FROM --platform=$BUILDPLATFORM base AS test # Note on the go race detector: # - we set CGO_ENABLED=1 to have it enabled -# - we install g++ to support the race detector +# - we installed g++ to support the race detector ENV CGO_ENABLED=1 -RUN apk --update --no-cache add g++ ENTRYPOINT go test -race -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic ./... FROM --platform=$BUILDPLATFORM base AS lint -ARG GOLANGCI_LINT_VERSION=v1.40.1 -RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ - sh -s -- -b /usr/local/bin ${GOLANGCI_LINT_VERSION} COPY .golangci.yml ./ RUN golangci-lint run --timeout=10m @@ -36,7 +35,6 @@ RUN git init && \ git diff --exit-code -- go.mod FROM --platform=$BUILDPLATFORM base AS build -COPY --from=qmcgaw/xcputranslate:v0.4.0 /xcputranslate /usr/local/bin/xcputranslate ARG TARGETPLATFORM ARG VERSION=unknown ARG BUILD_DATE="an unknown date"