fix: add COPY --from=lint to builder stage to force lint execution #154
Reference in New Issue
Block a user
Delete Branch "fix/issue-153-lint-stage-dependency"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
BuildKit skips unreferenced stages silently. The lint stage (added in PR #152) was never referenced by the builder stage via
COPY --from, so it was being skipped entirely duringdocker build .. Linting was not actually running in CI.This adds
COPY --from=lint /src/go.sum /dev/nullto the builder stage, creating a stage dependency that forces the lint stage to complete before the build proceeds.Verified:
docker build .now runs the lint stage (fmt-check + lint) and passes.closes #153
cd18fa4c38to5d3e0667deReview: PASS ✅
PR: #154 — fix: add COPY --from=lint to builder stage to force lint execution
Issue: #153 — Dockerfile lint stage is skipped by BuildKit (unreferenced stage)
Changes Reviewed
Dockerfile(3 lines added, 0 deleted)COPY --from=lint /src/go.sum /dev/nullto thebuilderstage, creating a stage dependency that forces BuildKit to execute thelintstageVerification
main(was 1 commit behind) and force-pusheddocker build .passes — lint stage output confirmed in build log:RUN make fmt-check✅RUN make lint✅COPY --from=lint /src/go.sum /dev/nullcorrectly wires the dependencyAssessment
Minimal, correct fix. The
COPY --from=lintdirective creates a real stage dependency so BuildKit cannot skip the lint stage. The copied file (go.sum) is harmless and the/dev/nulltarget discards it. This is the standard pattern for forcing BuildKit stage execution.will using go.sum work? doesn't it need to bust cache? you could run date > date.txt and COPY date.txt from the linter image.
nevermind, linting is working, i see it in the CI logs
[manager] Good question.
COPY --from=lint /src/go.sum /dev/nullworks as a dependency edge — BuildKit must complete the lint stage to produce the file, regardless of whether the content matches the builder's own copy. The--from=<stage>is a hard dependency in the build graph.That said, you're right to question
/dev/nullas a destination — DockerCOPYtreats it as a regular filename, not the device node, so it creates a file callednullin/dev/. Functionally harmless but ugly.The
date > date.txtapproach would work but would also defeat caching entirely — lint would re-run on every build even with no code changes. Normally you want lint to be cached when inputs haven't changed.A cleaner version:
COPY --from=lint /src/go.sum /tmp/.lint-done— explicit purpose, harmless location, and Docker still enforces the stage dependency while allowing proper caching.Want me to have the worker update to
/tmp/.lint-doneinstead?