fix: set default base image in Dockerfiles and improve syntax handling#1242
fix: set default base image in Dockerfiles and improve syntax handling#1242sireeshajonnalagadda wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR refactors devcontainer features Dockerfile generation/templates to be more resilient when base image build args are not provided, and cleans up formatting/whitespace in a few spots.
Changes:
- Updates generated Dockerfile content to use
${_DEV_CONTAINERS_BASE_IMAGE:-scratch}and adds placeholder ARG defaults. - Adds missing
ARG _DEV_CONTAINERS_BASE_IMAGEin the base Dockerfile template and aligns indentation. - Minor formatting fixes (brace style, indentation, trailing whitespace, JSON newline).
Show a summary per file
| File | Description |
|---|---|
| src/spec-node/containerFeatures.ts | Adjusts generated Dockerfile content/prefix and applies formatting cleanups. |
| src/spec-configuration/containerFeaturesConfiguration.ts | Updates base Dockerfile template to declare _DEV_CONTAINERS_BASE_IMAGE and uses a fallback in FROM. |
| scripts/updateUID.Dockerfile | Adds a default value to BASE_IMAGE ARG. |
| .devcontainer/devcontainer-lock.json | Formatting-only newline/EOF adjustment. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (3)
src/spec-node/containerFeatures.ts:1
- Dockerfile variable substitution does not reliably support shell-style defaulting (
${VAR:-scratch}) across Docker/BuildKit versions, and it may be treated as a literal/invalid image reference. Prefer setting the default on theARGitself (e.g.,ARG _DEV_CONTAINERS_BASE_IMAGE=scratch) and then usingFROM $_DEV_CONTAINERS_BASE_IMAGE ..., or ensure the build arg is always provided and fail early with a clear error if missing.
/*---------------------------------------------------------------------------------------------
src/spec-configuration/containerFeaturesConfiguration.ts:1
- Falling back to
scratchin these stages can produce confusing build failures if_DEV_CONTAINERS_BASE_IMAGEisn’t set, because this Dockerfile later executesRUNinstructions (which will fail onscratchdue to the absence of/bin/sh). Consider either: (1) making theARGdefault a real minimal base image that supportsRUN(if acceptable), or (2) keeping the base image required and adding an explicit, early failure explaining that_DEV_CONTAINERS_BASE_IMAGEmust be provided, rather than silently defaulting toscratch.
/*---------------------------------------------------------------------------------------------
src/spec-configuration/containerFeaturesConfiguration.ts:1
- Falling back to
scratchin these stages can produce confusing build failures if_DEV_CONTAINERS_BASE_IMAGEisn’t set, because this Dockerfile later executesRUNinstructions (which will fail onscratchdue to the absence of/bin/sh). Consider either: (1) making theARGdefault a real minimal base image that supportsRUN(if acceptable), or (2) keeping the base image required and adding an explicit, early failure explaining that_DEV_CONTAINERS_BASE_IMAGEmust be provided, rather than silently defaulting toscratch.
/*---------------------------------------------------------------------------------------------
- Files reviewed: 3/4 changed files
- Comments generated: 3
| ARG BASE_IMAGE=placeholder | ||
| FROM $BASE_IMAGE |
sireeshajonnalagadda
left a comment
There was a problem hiding this comment.
Defaulting BASE_IMAGE to placeholder will cause builds to fail with an invalid image reference if the build arg is omitted. If the intent is to provide a safe default, use a valid default value (e.g., scratch or a known minimal base)
What issue is about
The warning InvalidDefaultArgInFrom is not from the user’s project Dockerfile.
It comes from internal CLI Dockerfile flows where FROM uses an ARG that can look empty at parse time.
The reported hang after Starting container is likely a separate startup/event path, not this warning itself.
What has been done for you
Root cause was confirmed by tracing internal paths and issue context.
Warning fix was applied in updateUID.Dockerfile:3
ARG BASE_IMAGE changed to ARG BASE_IMAGE=placeholder.
Related hardening changes were also applied in generated feature Dockerfile templates:
containerFeaturesConfiguration.ts
containerFeatures.ts
Validation done
Local CLI build and run path was verified:
npm run compile
node devcontainer.js up --workspace-folder ./src/test/configs/example/ --build-no-cache --remove-existing-container
This succeeded with local source and removed the original BASE_IMAGE warning path in the tested flow.
Current changed files relevant to this issue
updateUID.Dockerfile
containerFeaturesConfiguration.ts
containerFeatures.ts