Repository navigation
fix(docker): skip FROM references to earlier build stages - #602
Open
vibgrate-team wants to merge 1 commit into
Open
vibgrate-team wants to merge 1 commit into
vibgrate-team wants to merge 1 commit into
Conversation
A multi-stage Dockerfile's `FROM <stage>` was recorded as a Docker Hub image (for example `library/build`). parseDockerfile now remembers stage names declared with AS, case-insensitively, and skips a FROM whose target is a stage already declared. An image that only matches a stage declared later is still recorded, and row names stay `library/<image>`. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parseDockerfiletreated everyFROMtarget as a registry image. In a multi-stage Dockerfile the later stages usually start from an earlier stage name:buildwas recorded aslibrary/build.vg scanthen looked that name up on Docker Hub and reportedunknowndrift, or drift against an unrelated public image of the same name.While walking the file, the parser now records stage names declared with
AS(the keyword is case-insensitive) and skips aFROMwhose target is a stage already declared. Comparison of the target to those names is case-insensitive, matching Docker. A name is recorded only after thatFROMis classified, so an image that merely shares a name with a stage declared later is still a row. Row naming is unchanged: a Docker Hub image with no namespace stayslibrary/<image>, and the tag stays the version (latestwhen the reference has none).FROM node:20 AS build/FROM build AS testnow yields one row,library/nodeat20.FROM buildfollowed byFROM node:20 AS buildstill yieldslibrary/buildandlibrary/node.Related issues
Closes #588
Checklist
pnpm testpassespnpm lintis cleanpnpm typecheckis cleangraph.json/ report output (content-hashed IDs, stable sorts; no time,randomness, or filesystem-order dependence)
git commit -s, DCO)Notes for reviewers
Table-driven tests cover uppercase
AS, lowercaseas, and an untagged image whose name is reused by a later stage.scratchis still skipped. TheFROMinstruction match itself is unchanged (still uppercase, still anchored at the start of the line), so this does not overlap the lowercase/indentedfromwork in #576 beyond the same regex.No doc edit: the existing DOCS examples are single-stage
FROMlines, and they already describe real images rather than stage names.pnpm lintexits 0; the five warnings it prints are existing and outside this change.