# Lint stage: format check + golangci-lint # golangci/golangci-lint:v2.12.2 (Debian-based), 2026-08-07 FROM golangci/golangci-lint:v2.12.2@sha256:5cceeef04e53efe1470638d4b4b4f5ceefd574955ab3941b2d9a68a8c9ad5240 AS lint WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . RUN make fmt-check # Called directly: make lint is itself a docker build of this stage. RUN golangci-lint run --config .golangci.yml ./... # Test stage: run full test suite under the race detector # golang 1.22.12 (Debian-based; -race needs its C toolchain), 2025-02-04 FROM golang@sha256:1cf6c45ba39db9fd6db16922041d074a63c935556a05c5ccb62d181034df7f02 AS test WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . # Called directly: make test is itself a docker build of this stage. RUN go test -timeout 90s -race -cover ./... || \ { echo "--- Rerunning with -v for details ---"; \ go test -timeout 90s -race -v ./...; exit 1; } # Final stage: the copies make a plain docker build run both stages above. # golang 1.22.12 (2025-02-04) FROM golang@sha256:1cf6c45ba39db9fd6db16922041d074a63c935556a05c5ccb62d181034df7f02 COPY --from=lint /src/go.sum /dev/null COPY --from=test /src/go.sum /dev/null