Skip to content

fix(docker): prepend ARG BASE to overlay Dockerfiles#182

Merged
thejoeejoee merged 2 commits into
mainfrom
fix/allow-broken-overlays
May 23, 2026
Merged

fix(docker): prepend ARG BASE to overlay Dockerfiles#182
thejoeejoee merged 2 commits into
mainfrom
fix/allow-broken-overlays

Conversation

@thejoeejoee

Copy link
Copy Markdown
Collaborator

Overlay Dockerfiles that use FROM ${BASE} without declaring ARG BASE in global scope fail with:

base name (${BASE}) should not be blank

Docker requires the ARG declared before the first FROM for substitution to work. This prepends ARG BASE\n to every loaded overlay Dockerfile — harmless when already declared (duplicate bare ARGs are no-ops), and --build-arg always overrides any default.

Docker requires ARG declared in global scope (before first FROM) for
build-arg substitution to work in FROM instructions. User Dockerfiles
that omit ARG BASE fail with 'base name should not be blank'.

Prepending ARG BASE is a no-op when already declared — duplicate bare
ARGs are harmless and --build-arg always overrides any default.
Copilot AI review requested due to automatic review settings May 22, 2026 21:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Docker overlay builds failing when an overlay Dockerfile uses FROM ${BASE} without declaring ARG BASE before the first FROM, by automatically injecting a global ARG BASE into the loaded overlay Dockerfile content.

Changes:

  • Prepend ARG BASE to overlay Dockerfile content in BuildOverlayImage to enable ${BASE} substitution in FROM.
  • Add an integration test covering overlay builds where the Dockerfile omits an explicit ARG BASE.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/docker/docker.go Prepends ARG BASE to loaded overlay Dockerfiles prior to building.
internal/docker/docker_integration_test.go Adds an integration test ensuring overlays without ARG BASE don’t fail with “base name (${BASE}) should not be blank”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/docker/docker.go Outdated
Prepending ARG BASE at byte 0 breaks Dockerfiles starting with parser
directives (# syntax=..., # escape=..., # check=...) which must appear
before any instruction. Now scans past leading directives and blank
lines before injecting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread internal/docker/docker.go
@thejoeejoee thejoeejoee merged commit 62f443b into main May 23, 2026
6 checks passed
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.

2 participants