Split Dockerfile: pre-built golangci-lint stage for faster CI #18

Zamknięty
otworzone 2026-03-02 08:50:56 +01:00 przez clawbot · 0 komentarzy
Collaborator

Goal

Split the Dockerfile into a dedicated lint stage using the pre-built golangci/golangci-lint image, so lint and formatting failures surface much faster without downloading golangci-lint on every build.

Pattern

# Stage 1: Lint (pre-built image, fast)
FROM golangci/golangci-lint@sha256:... AS lint
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make fmt-check
RUN make lint

# Stage 2: Test + Build
FROM golang@sha256:... AS builder
# Force BuildKit to run lint stage
COPY --from=lint /src/go.sum /dev/null
...
RUN make test
RUN make build

Key details

  • All images pinned by sha256 per REPO_POLICIES
  • COPY --from=lint creates BuildKit stage dependency (without this, lint stage is silently skipped)
  • Reference implementation: sneak/upaas Dockerfile

Tracked from sdlc-manager#6.

## Goal Split the Dockerfile into a dedicated lint stage using the pre-built `golangci/golangci-lint` image, so lint and formatting failures surface much faster without downloading golangci-lint on every build. ## Pattern ```dockerfile # Stage 1: Lint (pre-built image, fast) FROM golangci/golangci-lint@sha256:... AS lint WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . RUN make fmt-check RUN make lint # Stage 2: Test + Build FROM golang@sha256:... AS builder # Force BuildKit to run lint stage COPY --from=lint /src/go.sum /dev/null ... RUN make test RUN make build ``` ## Key details - All images pinned by sha256 per REPO_POLICIES - `COPY --from=lint` creates BuildKit stage dependency (without this, lint stage is silently skipped) - Reference implementation: [sneak/upaas Dockerfile](https://git.eeqj.de/sneak/upaas/src/branch/main/Dockerfile) Tracked from [sdlc-manager#6](https://git.eeqj.de/clawbot/sdlc-manager/issues/6).
clawbot zamknął(-ęła) to zgłoszenie 2026-03-02 09:29:19 +01:00
clawbot otworzył(-a) ponownie to zgłoszenie 2026-03-02 10:12:57 +01:00
clawbot zamknął(-ęła) to zgłoszenie 2026-03-02 10:13:20 +01:00
clawbot otworzył(-a) ponownie to zgłoszenie 2026-03-02 11:16:25 +01:00
clawbot zamknął(-ęła) to zgłoszenie 2026-03-02 11:16:32 +01:00
clawbot otworzył(-a) ponownie to zgłoszenie 2026-03-02 11:16:54 +01:00
clawbot zamknął(-ęła) to zgłoszenie 2026-03-02 11:24:15 +01:00
Zaloguj się, aby dołączyć do tej rozmowy.
Uczestnicy 1
Powiadomienia
Termin realizacji
Brak ustawionego terminu realizacji.
Zależności

No dependencies set.

Reference: sneak/pixa#18