Skip to content

fix(docker): substitute ARG defaults in FROM image refs - #603

Open
vibgrate-team wants to merge 1 commit into
mainfrom
cursor/dockerfile-arg-defaults-30de
Open

vibgrate-team wants to merge 1 commit into
mainfrom
cursor/dockerfile-arg-defaults-30de

Conversation

@vibgrate-team

Copy link
Copy Markdown
Contributor

Summary

Dockerfiles that parameterise a base image with ARG defaults were recorded as a literal image name such as library/${BASE} with unknown drift. FROM now substitutes $NAME and ${NAME} from ARG name=default values that appear earlier in the file, including a default that itself references an earlier argument.

ARG NODE_VERSION=20
ARG BASE=node:${NODE_VERSION}-alpine
FROM ${BASE}

That file yields one library/node row at 20-alpine. FROM $UNSET with no default yields no row. Unresolved ${...} text is never written into an image name or tag.

Related issues

Fixes #577

Checklist

  • pnpm test passes
  • pnpm lint is clean
  • pnpm typecheck is clean
  • Docs updated (README / DOCS / ARCHITECTURE) where behavior changed
  • Determinism preserved — identical input still produces identical graph.json / report output (content-hashed IDs, stable sorts; no time, randomness, or filesystem-order dependence)
  • No proprietary or internal references — public, Apache-2.0 content only
  • Commits use Conventional Commits and are signed off (git commit -s, DCO)

Notes for reviewers

No public docs describe Dockerfile FROM parsing, so none were changed. A variable with no default drops that FROM rather than inventing an image. Defaults are expanded when the ARG is seen, so a later ARG does not rewrite an earlier default that already used it.

Open in Web Open in Cursor 

Dockerfile ARG defaults are expanded before an image row is recorded, so
FROM ${BASE} with a nested default such as node:${NODE_VERSION}-alpine
becomes library/node at 20-alpine. A FROM that still names a variable with
no default is skipped instead of emitting a literal ${...} image.

Fixes #577

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: FROM ${BASE_IMAGE} in a Dockerfile becomes a bogus image row instead of using the ARG default

2 participants