From 3b42620749f094b9357b00501971d3c5a04ff1a8 Mon Sep 17 00:00:00 2001 From: clawbot Date: Mon, 2 Mar 2026 00:03:04 -0800 Subject: [PATCH] feat: split Dockerfile into dedicated lint stage Use pre-built golangci/golangci-lint:v2.1.6 image for fast lint feedback instead of installing golangci-lint from source on every build. - Lint stage: runs fmt-check and lint using pre-built image - Build stage: runs tests and compiles binaries - COPY --from=lint forces BuildKit to execute the lint stage - All images pinned by sha256 digest - Runtime stage unchanged --- Dockerfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 60b0bf9..a1668d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,28 @@ +# Lint stage — fast feedback on formatting and lint issues +# golangci/golangci-lint:v2.1.6 +FROM golangci/golangci-lint@sha256:568ee1c1c53493575fa9494e280e579ac9ca865787bafe4df3023ae59ecf299b AS lint +WORKDIR /src +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN make fmt-check +RUN make lint + +# Build stage — tests and compilation # golang:1.24-alpine, 2026-02-26 FROM golang@sha256:8bee1901f1e530bfb4a7850aa7a479d17ae3a18beb6e09064ed54cfd245b7191 AS builder WORKDIR /src RUN apk add --no-cache git build-base make -# golangci-lint v2.1.6 (eabc2638a66d), 2026-02-26 -RUN CGO_ENABLED=0 go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@eabc2638a66daf5bb6c6fb052a32fa3ef7b6600d +# Force BuildKit to run the lint stage by creating a stage dependency +COPY --from=lint /src/go.sum /dev/null COPY go.mod go.sum ./ RUN go mod download COPY . . -# Run all checks — build fails if branch is not green -RUN make check +RUN make test # Build static binaries (no cgo needed at runtime — modernc.org/sqlite is pure Go) ARG VERSION=dev -- 2.49.1