Skip to content

fix: Improve dockerfile_fragments.py to use marker-based substitution instead of regex on FROM lines #3402

@jiridanek

Description

@jiridanek

Problem

scripts/dockerfile_fragments.py uses regex substitution to replace Dockerfile instruction strings (like FROM registry.access.redhat.com/ubi9/go-toolset:...). This introduces ARG-based interpolation into FROM lines, which causes Renovate to skip those dependencies with skipReason: "contains-variable".

Affected image: registry.access.redhat.com/ubi9/go-toolset — skipped in ~12 Dockerfiles across jupyter/, rstudio/, runtimes/, codeserver/ directories.

The current approach also risks matching unintended lines if the regex pattern appears elsewhere in a Dockerfile.

Suggestion: marker-based substitution

Instead of matching on Dockerfile instruction strings, use explicit markers:

### BEGIN go-toolset
FROM registry.access.redhat.com/ubi9/go-toolset:1.25.8-1776370298 AS buildscripts
### END go-toolset

The fragment script would match on ### BEGIN <name> / ### END <name> and replace only the block between markers. This:

  1. Lets Renovate track the FROM line normally (no ARG interpolation needed)
  2. Makes the substitution explicit and auditable
  3. Avoids accidental matches on similar instruction strings elsewhere

Alternative: ARG + custom.regex manager

Add an ARG GO_TOOLSET_VERSION=1.25.8-1776370298 at the top and use FROM registry.access.redhat.com/ubi9/go-toolset:${GO_TOOLSET_VERSION}. Then add a custom.regex manager entry (similar to how BASE_IMAGE is handled via build-args/konflux.*.conf files) so Renovate can track the version through the ARG.

Affected files

From the Renovate debug log, these show contains-variable for go-toolset:

  • Multiple Dockerfiles across jupyter/, rstudio/, runtimes/ directories (~12 instances)
  • scripts/dockerfile_fragments.py itself

Note

The go-toolset image should NOT use :latest — it should be pinned to a specific version tag. The allowedVersions: "/^1\\./" rule in .github/renovate.json5 already restricts go-toolset to Go 1.x tags, which is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions