From 8302ecf55f5977a0848b9963eca5c158a59388ed Mon Sep 17 00:00:00 2001 From: Yuvarani Shankar Date: Thu, 25 Jun 2026 18:08:25 -0700 Subject: [PATCH] fix: move BASE_IMAGE_REGISTRY ARG to global scope in Dockerfile templates (#341) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: move BASE_IMAGE_REGISTRY ARG to global scope in Dockerfile templates Buildah treats ARG declarations after a FROM as stage-scoped, so BASE_IMAGE_REGISTRY declared between stages was invisible to the final-stage FROM instruction. This caused the build arg to resolve to an empty string, producing "FROM /ubi9/ubi-minimal" (invalid reference). Move the ARG before the first FROM where it is in true global scope and reachable by all FROM instructions. Fixes srcimg.ionic.coreos (broken) and ubuntu (latent same issue). Co-Authored-By: Claude Opus 4 (1M context) * fix: remove redundant mid-file ARG BASE_IMAGE_REGISTRY in RHEL template Same cleanup as ubuntu template — line 1 already declares the ARG in global scope, so the re-declaration on line 30 between stages is redundant. Ensures all four Dockerfile templates follow the same pattern consistently. Co-Authored-By: Claude Opus 4 (1M context) --------- Co-authored-by: Yuva Shankar <11082310+yuva29@users.noreply.github.com> Co-authored-by: Claude Opus 4 (1M context) (cherry picked from commit 0446b6c12d9ea516a52361ddf1a77ec604981233) --- internal/kmmmodule/dockerfiles/DockerfileTemplate.rhel | 2 -- .../dockerfiles/DockerfileTemplate.srcimg.ionic.coreos | 3 +-- internal/kmmmodule/dockerfiles/DockerfileTemplate.ubuntu | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/kmmmodule/dockerfiles/DockerfileTemplate.rhel b/internal/kmmmodule/dockerfiles/DockerfileTemplate.rhel index 2a64ac32..895890db 100644 --- a/internal/kmmmodule/dockerfiles/DockerfileTemplate.rhel +++ b/internal/kmmmodule/dockerfiles/DockerfileTemplate.rhel @@ -27,8 +27,6 @@ RUN dnf clean all && \ RUN depmod ${KERNEL_VERSION} -ARG BASE_IMAGE_REGISTRY=registry.access.redhat.com - FROM ${BASE_IMAGE_REGISTRY}/redhat/ubi$$MAJOR_VERSION ARG KERNEL_FULL_VERSION diff --git a/internal/kmmmodule/dockerfiles/DockerfileTemplate.srcimg.ionic.coreos b/internal/kmmmodule/dockerfiles/DockerfileTemplate.srcimg.ionic.coreos index 03eb5ce1..24598f3f 100644 --- a/internal/kmmmodule/dockerfiles/DockerfileTemplate.srcimg.ionic.coreos +++ b/internal/kmmmodule/dockerfiles/DockerfileTemplate.srcimg.ionic.coreos @@ -2,6 +2,7 @@ ARG DTK_AUTO ARG RHEL_VERSION ARG SOURCE_IMAGE_REPO=docker.io/library/ionic-srcimg ARG DRIVERS_VERSION +ARG BASE_IMAGE_REGISTRY=registry.access.redhat.com FROM ${SOURCE_IMAGE_REPO}:${DRIVERS_VERSION} as sources FROM ${DTK_AUTO} as builder @@ -33,8 +34,6 @@ RUN mkdir -p /modules_files && \ cp -r /lib/modules/${KERNEL_VERSION}/extra/* /ionic_ko_files/ && \ cp -r /lib/modules/${KERNEL_VERSION}/kernel/* /kernel_files/ || true -ARG BASE_IMAGE_REGISTRY=registry.access.redhat.com - FROM ${BASE_IMAGE_REGISTRY}/ubi9/ubi-minimal ARG KERNEL_VERSION diff --git a/internal/kmmmodule/dockerfiles/DockerfileTemplate.ubuntu b/internal/kmmmodule/dockerfiles/DockerfileTemplate.ubuntu index 197df173..113271aa 100644 --- a/internal/kmmmodule/dockerfiles/DockerfileTemplate.ubuntu +++ b/internal/kmmmodule/dockerfiles/DockerfileTemplate.ubuntu @@ -63,8 +63,6 @@ RUN mods_dir=/lib/modules/${KERNEL_FULL_VERSION}; \ # Regenerate dependency maps only for staged modules depmod -b /staging ${KERNEL_FULL_VERSION} -ARG BASE_IMAGE_REGISTRY=docker.io - FROM ${BASE_IMAGE_REGISTRY}/ubuntu:$$VERSION ARG KERNEL_FULL_VERSION