Skip to content

Dist gen generation#541

Open
tjuhaszrh wants to merge 9 commits into
sclorg:masterfrom
tjuhaszrh:dist-git2
Open

Dist gen generation#541
tjuhaszrh wants to merge 9 commits into
sclorg:masterfrom
tjuhaszrh:dist-git2

Conversation

@tjuhaszrh

@tjuhaszrh tjuhaszrh commented May 18, 2026

Copy link
Copy Markdown
Contributor

Cleaning up the draft PR.

Summary by CodeRabbit

  • New Features

    • Added support for Node.js 22 and 24 container image variants.
    • Introduced minimal container image variants for reduced footprint.
    • Enhanced Source-to-Image (S2I) support with improved build and runtime scripts.
    • Added automatic user namespace configuration for containerized applications.
  • Documentation

    • Added comprehensive guides for S2I workflows, environment variables, and development modes.
    • Updated container registry references across multiple platform targets.
  • Chores

    • Updated buildpack stack identifiers for Node.js version alignment.
    • Restructured build configuration for multi-version, multi-distro image generation.

@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

[test]

@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown

Testing Farm results

namecomposearchstatusstarted (UTC)timelogs
Fedora - 24Fedora-latestx86_64✅ passed19.05.2026 12:13:4210min 14stest pipeline
CentOS Stream 10 - 24-minimalCentOS-Stream-10x86_64✅ passed19.05.2026 12:02:4410min 18stest pipeline
CentOS Stream 10 - 22-minimalCentOS-Stream-10x86_64✅ passed19.05.2026 11:15:5811min 44stest pipeline
CentOS Stream 9 - 24CentOS-Stream-9x86_64✅ passed19.05.2026 11:16:4613min 52stest pipeline
CentOS Stream 10 - 22CentOS-Stream-10x86_64✅ passed19.05.2026 11:37:3813min 40stest pipeline
RHEL10 - FIPS Enabled - 24-minimalRHEL-10.2-Nightlyx86_64✅ passed19.05.2026 10:52:3118min 52stest pipeline
RHEL10 - FIPS Enabled - 22-minimalRHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:15:1220min 10stest pipeline
RHEL8 - 22RHEL-8.10.0-Nightlyx86_64✅ passed19.05.2026 12:11:0316min 57stest pipeline
RHEL8 - 22-minimalRHEL-8.10.0-Nightlyx86_64✅ passed19.05.2026 11:57:5618min 13stest pipeline
RHEL10 - 24-minimalRHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:23:5921min 18stest pipeline
RHEL10 - Unsubscribed host - 24RHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:59:0421min 54stest pipeline
Fedora - 24-minimalFedora-latestx86_64✅ passed04.06.2026 10:14:437min 44stest pipeline
RHEL10 - FIPS Enabled - 24RHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:05:4527min 2stest pipeline
RHEL9 - 24RHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:51:5125min 59stest pipeline
RHEL9 - Unsubscribed host - 22RHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:45:2021min 28stest pipeline
RHEL9 - FIPS Enabled - 24-minimalRHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 10:51:4523min 44stest pipeline
RHEL10 - FIPS Enabled - 22RHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:10:0023min 17stest pipeline
RHEL9 - FIPS Enabled - 22-minimalRHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:01:3931min 33stest pipeline
RHEL9 - FIPS Enabled - 24RHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:06:5834min 52stest pipeline
RHEL10 - 22RHEL-10.2-Nightlyx86_64✅ passed19.05.2026 12:15:0628min 5stest pipeline
RHEL9 - Unsubscribed host - 22-minimalRHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:59:1722min 15stest pipeline
RHEL10 - Unsubscribed host - 22-minimalRHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:53:1218min 42stest pipeline
CentOS Stream 9 - 24-minimalCentOS-Stream-9x86_64✅ passed19.05.2026 12:14:2910min 46stest pipeline
RHEL10 - 24RHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:31:2020min 21stest pipeline
RHEL10 - 22-minimalRHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:34:2218min 25stest pipeline
RHEL9 - FIPS Enabled - 22RHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 10:55:4830min 40stest pipeline
RHEL9 - 22-minimalRHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 12:04:5123min 4stest pipeline
RHEL10 - Unsubscribed host - 22RHEL-10.2-Nightlyx86_64✅ passed19.05.2026 12:06:1020min 53stest pipeline
RHEL9 - Unsubscribed host - 24RHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:51:0121min 37stest pipeline
RHEL9 - 22RHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:50:4226min 55stest pipeline
RHEL9 - Unsubscribed host - 24-minimalRHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:42:4122min 31stest pipeline
RHEL9 - 24-minimalRHEL-9.8.0-Nightlyx86_64✅ passed19.05.2026 11:28:3722min 19stest pipeline
CentOS Stream 10 - 24CentOS-Stream-10x86_64✅ passed19.05.2026 11:15:4513min 25stest pipeline
RHEL10 - Unsubscribed host - 24-minimalRHEL-10.2-Nightlyx86_64✅ passed19.05.2026 11:54:4219min 1stest pipeline

@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

Tests seem to mostly pass, the failures look like infra issues.
I have also separated the changes into more commits for better structuring.

@tjuhaszrh tjuhaszrh force-pushed the dist-git2 branch 4 times, most recently from a5b6c0f to 6852710 Compare May 19, 2026 10:38
@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

[test]

@tjuhaszrh tjuhaszrh changed the title [Draft] Dist gen generation Dist gen generation May 19, 2026
@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

@phracek Could you do a review please?

@phracek phracek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few comments. C8S is not supported at all.

Comment thread specs/multispec.yml Outdated
Comment thread specs/multispec.yml Outdated
Comment thread manifest-minimal.yml Outdated
Comment thread manifest.yml Outdated
@phracek

phracek commented Jun 4, 2026

Copy link
Copy Markdown
Member

@tjuhaszrh Please update .github/workflows/container-tests.yml and .github/workflows/container-upstream-tests.yml so it checks distgen. See here: https://github.com/sclorg/postgresql-container/blob/master/.github/workflows/container-tests.yml#L7. This has to be done as separate pull request. @pkhartsk Am I right, or it could be part of this pull request?

@tjuhaszrh tjuhaszrh self-assigned this Jun 4, 2026
@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

[test]

@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

I don't think the README check targets changes from this PR.
I don't even understand why it was runned, I probably accidentally started it manually.

@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

Just a few comments. C8S is not supported at all.

Removed all mentions of c8s and regenerated files, so c8s dockerfiles should be gone.

@tjuhaszrh tjuhaszrh requested a review from phracek June 4, 2026 10:30
@phracek

phracek commented Jun 4, 2026

Copy link
Copy Markdown
Member

@tjuhaszrh Please by make version-table regenerated the version table and add README.md to the pull request as well.

@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

[test]

@phracek phracek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@phracek

phracek commented Jun 8, 2026

Copy link
Copy Markdown
Member

[test]

@phracek

phracek commented Jun 9, 2026

Copy link
Copy Markdown
Member

[test-pytest]

@tjuhaszrh

Copy link
Copy Markdown
Contributor Author

[test]

@phracek phracek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@phracek phracek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my comments. Let's make the src/Dockerfile more readable. Let's remove a lot of duplicty.

But thanks for your good work.

Comment thread src/Dockerfile Outdated
help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \
usage="s2i build <SOURCE-REPOSITORY> {% if spec.prod in ["c8s", "c9s", "c10s"] %}quay.io/{% endif %}{{ spec.img_name }}{% if spec.prod != "rhel10" %}:latest{% endif %} <APP-NAME>"

{% if spec.prod in ["c9s", "rhel10", "c10s"] %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Empty comment?

Comment thread src/Dockerfile Outdated
{% if spec.prod in ["c9s", "rhel10", "c10s"] %}
# Package libatomic_ops was removed
{% endif %}{% if spec.prod in ["rhel10", "c10s"] and spec.version == "22" %}
RUN INSTALL_PKGS="make gcc gcc-c++ git openssl-devel nodejs nodejs-nodemon nodejs-npm nss_wrapper-libs which" && \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what about to add none npm package to mamultispec.yml file and add only nodejs version or unversioned packages here.

Comment thread src/Dockerfile Outdated
dnf -y clean all --enablerepo='*'
{% elif spec.environment_setup %}
{% if spec.prod == "rhel8" and spec.version == "20" -%}
RUN yum -y module enable nodejs:$NODEJS_VERSION && \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is repeating. It would be nice to collect them together. See e.g. sclorg/mariadb-container#331

Comment thread src/Dockerfile Outdated
INSTALL_PKGS="$MODULE_DEPS {{ spec.pkgs }}" && \
ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && \
ln -s /usr/libexec/platform-python /usr/bin/python3 && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code is duplicated several times.

Add scripts which will be copied to version specific fodlers upon generation.

Scripts are distro-agnostic as to be usable for all resulted versions.
Readme files also have to be genereted from as agnostic baseline as possible.
Manifest files dictate source baseline dockerfile and resulting path of genereted files, also sets access rights.
Add multispec.yaml file which defines values later used in conditions of DockerFiles in src and to fill in the version specific data.
Move scripts to version agnostic pathway which allows copying during generation.
Remove c8s files and configurations from the project.
Regenerate README.md with updated version table.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Introduces a src/ directory containing Jinja-based Dockerfile and S2I script templates (assemble, run, run-minimal, init-wrapper, save-artifacts, usage), runtime helpers (fix-permissions, generate_container_user, scl_enable), and full documentation templates. Adds specs/multispec.yml (distro/version matrix) and manifest.yml/manifest-minimal.yml (distgen generation rules). Corrects CNB_STACK_ID and io.buildpacks.stack.id values in existing Node.js 22 and 24 RHEL Dockerfiles, removes stale c8s Dockerfiles, and normalises whitespace, symlinks, and registry entries across version directories.

Changes

Source template and manifest infrastructure

Layer / File(s) Summary
Multi-version/distro spec matrix
specs/multispec.yml
Defines distroinfo for fedora, UBI 8/9/10, c9s, and c10s; specs.version entries for Node.js 20/22/24 and -minimal variants; and the matrix.include build/test combinations.
manifest.yml and manifest-minimal.yml generation rules
manifest.yml, manifest-minimal.yml
Specifies DISTGEN_MULTI_RULES for per-distro Dockerfile generation, DISTGEN_RULES for README generation, COPY_RULES for S2I bin scripts at mode 0755, and SYMLINK_RULES wiring test fixtures.
src/Dockerfile Jinja template
src/Dockerfile
Parameterised Dockerfile covering base image, environment/label blocks, conditional package installation per spec.prod/spec.version, SCL module enabling, S2I script copying, root filesystem overlay, permission fixing, optional RHEL8 GCC toolset activation, and default CMD.
Runtime helper scripts and root files
src/root/usr/bin/fix-permissions, src/root/opt/app-root/etc/generate_container_user, src/root/opt/app-root/etc/scl_enable, src/root/opt/app-root/etc/npm_global_module_list
Adds fix-permissions (group ownership/permission normalisation), generate_container_user (NSS-wrapper setup for arbitrary UIDs), scl_enable (SCL collection activation), and the global npm module list.
S2I bin scripts
src/s2i/bin/assemble, src/s2i/bin/run, src/s2i/bin/run-minimal, src/s2i/bin/init-wrapper, src/s2i/bin/save-artifacts, src/s2i/bin/usage
assemble restores artifacts, configures npm proxy/auth/registry, runs install/build/prune with environment-specific logic; run and run-minimal implement the startup decision tree (nodemon → init-wrapper → NODE_CMD → package.json derivation → npm run fallback); init-wrapper provides PID-1 signal forwarding; save-artifacts tars node_modules; usage prints help.
Documentation templates
src/README.md, src/README.minimal.md
Full documentation for S2I/Dockerfile workflows, environment variable reference, dev mode/debug/hot-deploy, init-wrapper usage, and distribution-specific Dockerfile naming for both the full and minimal image variants.

Corrections to existing version-specific artifacts

Layer / File(s) Summary
CNB_STACK_ID and buildpack label corrections
22/Dockerfile.rhel8, 22/Dockerfile.rhel9, 24/Dockerfile.rhel8, 24/Dockerfile.rhel9
Updates CNB_STACK_ID ENV and io.buildpacks.stack.id label from the Node.js 20 stack identifiers to the correct Node.js 22 and 24 identifiers.
c8s Dockerfile removal, symlink and whitespace normalization
22/Dockerfile.c8s, 22-minimal/Dockerfile.c8s, 24/Dockerfile.c8s, 24-minimal/Dockerfile.c8s, 22/s2i/bin/run, 22-minimal/s2i/bin/run, 24/s2i/bin/run, 24-minimal/s2i/bin/run, 22/test, 24/test, README.md
Removes four stale c8s Dockerfiles, removes trailing whitespace from run_node function braces across version directories, corrects test symlink targets from ../test/ to ../test, and fills missing container registry addresses in the root README versions table.

Sequence Diagram(s)

sequenceDiagram
    participant S2I as S2I Build System
    participant assemble as assemble script
    participant run as run / run-minimal
    participant init_wrapper as init-wrapper
    participant node as Node.js Process

    S2I->>assemble: invoke (source in /tmp/src)
    assemble->>assemble: restore node_modules from /tmp/artifacts
    assemble->>assemble: configure npm proxy / registry / auth token
    assemble->>assemble: npm install (dev or prod path)
    assemble->>assemble: npm run build + prune (prod only)
    assemble->>assemble: fix-permissions

    S2I->>run: container entrypoint
    run->>run: source generate_container_user (if present)
    run->>run: resolve DEV_MODE / NODE_ENV defaults

    alt DEV_MODE=true
        run->>node: nodemon --inspect
    else INIT_WRAPPER=true and NODE_CMD set
        run->>init_wrapper: exec NODE_CMD in background
        init_wrapper-->>node: start process, trap SIGTERM/SIGINT
        init_wrapper-->>run: exit with child status
    else NODE_CMD set
        run->>node: exec NODE_CMD directly
    else package.json / server.js derived
        run->>node: exec derived start command
    else
        run->>node: npm run -d $NPM_RUN
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 Hopping through Dockerfiles, one by one,
Templates and specs — the new era's begun!
Stack IDs corrected, c8s swept away,
Symlinks trimmed neatly, no slash left astray.
init-wrapper reaps PIDs with care,
A rabbit-built image beyond compare! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Dist gen generation' is vague and uses generic/redundant terminology that lacks specificity about the actual changes. Consider using a more descriptive title such as 'Implement dist-gen infrastructure for s2i-nodejs-container' to clearly convey the main objective of the PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/README.md (1)

5-5: ⚡ Quick win

Fix spelling and grammar errors in both README templates.

Multiple spelling errors and hyphenation issues reduce clarity and professional appearance. Consistent errors across both files:

  • src/README.md#L206, src/README.minimal.md#L278: "souce" → "source"
  • src/README.md#L264, src/README.minimal.md#L336: "avalable" → "available"
  • src/README.md#L149, src/README.minimal.md#L222: "environemnt variale" → "environment variable"
  • src/README.md#L301, src/README.minimal.md#L372: "another versions" → "other versions"
  • src/README.md#L5,L7, src/README.minimal.md#L7: "Fedora based" → "Fedora-based"
  • src/README.md#L166, src/README.minimal.md#L238: "key value pairs" → "key-value pairs"
🔧 Proposed fixes for spelling and grammar in src/README.md
-Users can choose between RHEL, CentOS and Fedora based images.
+Users can choose between RHEL, CentOS and Fedora-based images.

-and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora).
+and the Fedora-based images are available in [Quay.io](https://quay.io/organization/fedora).

-In case of `NODE_CMD` environemnt variale is specified, then `init-wrapper` script will use the value of `NODE_CMD` to start your application.
+In case of `NODE_CMD` environment variable is specified, then `init-wrapper` script will use the value of `NODE_CMD` to start your application.

-One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file.
+One way to define a set of environment variables is to include them as key-value pairs in your repo's `.s2i/environment` file.

-As part of development mode, this image supports hot deploy. If development mode is enabled, any souce code that is changed in the running container will be immediately reflected in the running nodejs application.
+As part of development mode, this image supports hot deploy. If development mode is enabled, any source code that is changed in the running container will be immediately reflected in the running nodejs application.

-A detailed explanation on how the init-wrapper script works is avalable in
+A detailed explanation on how the init-wrapper script works is available in

-In that repository you also can find another versions of Node.js environment Dockerfiles.
+In that repository you also can find other versions of Node.js environment Dockerfiles.
🔧 Proposed fixes for spelling and grammar in src/README.minimal.md
-Users can choose between RHEL, CentOS and Fedora based images.
+Users can choose between RHEL, CentOS and Fedora-based images.

-In case of `NODE_CMD` environemnt variale is specified, then `init-wrapper` script will use the value of `NODE_CMD` to start your application.
+In case of `NODE_CMD` environment variable is specified, then `init-wrapper` script will use the value of `NODE_CMD` to start your application.

-One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file.
+One way to define a set of environment variables is to include them as key-value pairs in your repo's `.s2i/environment` file.

-As part of development mode, this image supports hot deploy. If development mode is enabled, any souce code that is changed in the running container will be immediately reflected in the running nodejs application.
+As part of development mode, this image supports hot deploy. If development mode is enabled, any source code that is changed in the running container will be immediately reflected in the running nodejs application.

-A detailed explanation on how the init-wrapper script works is avalable in
+A detailed explanation on how the init-wrapper script works is available in

-In that repository you also can find another versions of Node.js environment Dockerfiles.
+In that repository you also can find other versions of Node.js environment Dockerfiles.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/README.md` at line 5, Fix all spelling and grammar errors across
src/README.md and src/README.minimal.md. In src/README.md at lines 5-7, change
"Fedora based" to "Fedora-based". Additionally, in src/README.md, correct
"souce" to "source" at line 206, "avalable" to "available" at line 264,
"environemnt variale" to "environment variable" at line 149, "another versions"
to "other versions" at line 301, and "key value pairs" to "key-value pairs" at
line 166. In src/README.minimal.md, apply the same corrections at the
corresponding locations: line 7 for "Fedora-based", line 278 for "source", line
336 for "available", line 222 for "environment variable", line 372 for "other
versions", and line 238 for "key-value pairs".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Dockerfile`:
- Around line 71-73: The conditional guard on line 71 checks for
`config.post_install` but the RUN directive on line 73 renders
`spec.post_install`, causing a namespace mismatch. Since the post_install field
is defined in the spec namespace in specs/multispec.yml, the condition will
always evaluate to false and skip the post-install hook. Change the conditional
on line 71 from `{% if config.post_install %}` to `{% if spec.post_install %}`
to match the namespace being used in the RUN statement.

In `@src/s2i/bin/run`:
- Around line 31-37: The startup command detection has two issues: First, on
line 36, the condition `[ -n $package_json_main ]` uses an unquoted variable,
which when empty expands to `[ -n ]` and evaluates to true incorrectly—add
quotes around the variable to properly check if it is non-empty. Second, lines
31-32 execute sed commands on package.json without verifying the file exists
first, which will cause the script to exit under set -e if the file is
missing—add a file existence check before the sed commands that read the
package.json file to ensure the script handles missing package.json gracefully.

---

Nitpick comments:
In `@src/README.md`:
- Line 5: Fix all spelling and grammar errors across src/README.md and
src/README.minimal.md. In src/README.md at lines 5-7, change "Fedora based" to
"Fedora-based". Additionally, in src/README.md, correct "souce" to "source" at
line 206, "avalable" to "available" at line 264, "environemnt variale" to
"environment variable" at line 149, "another versions" to "other versions" at
line 301, and "key value pairs" to "key-value pairs" at line 166. In
src/README.minimal.md, apply the same corrections at the corresponding
locations: line 7 for "Fedora-based", line 278 for "source", line 336 for
"available", line 222 for "environment variable", line 372 for "other versions",
and line 238 for "key-value pairs".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 48becdda-8e9b-440a-9d42-410371d84779

📥 Commits

Reviewing files that changed from the base of the PR and between 07647bd and dc26e09.

📒 Files selected for processing (45)
  • 22-minimal/.exclude-c8s
  • 22-minimal/.exclude-c9s
  • 22-minimal/.exclude-fedora
  • 22-minimal/Dockerfile.c8s
  • 22-minimal/s2i/bin/init-wrapper
  • 22-minimal/s2i/bin/run
  • 22/.exclude-c8s
  • 22/.exclude-c9s
  • 22/.exclude-fedora
  • 22/Dockerfile.c8s
  • 22/Dockerfile.rhel8
  • 22/Dockerfile.rhel9
  • 22/s2i/bin/init-wrapper
  • 22/s2i/bin/run
  • 22/test
  • 24-minimal/.exclude-c8s
  • 24-minimal/.exclude-rhel8
  • 24-minimal/Dockerfile.c8s
  • 24-minimal/s2i/bin/init-wrapper
  • 24-minimal/s2i/bin/run
  • 24/.exclude-c8s
  • 24/.exclude-rhel8
  • 24/Dockerfile.c8s
  • 24/Dockerfile.rhel8
  • 24/Dockerfile.rhel9
  • 24/s2i/bin/init-wrapper
  • 24/s2i/bin/run
  • 24/test
  • README.md
  • manifest-minimal.yml
  • manifest.yml
  • specs/multispec.yml
  • src/Dockerfile
  • src/README.md
  • src/README.minimal.md
  • src/root/opt/app-root/etc/generate_container_user
  • src/root/opt/app-root/etc/npm_global_module_list
  • src/root/opt/app-root/etc/scl_enable
  • src/root/usr/bin/fix-permissions
  • src/s2i/bin/assemble
  • src/s2i/bin/init-wrapper
  • src/s2i/bin/run
  • src/s2i/bin/run-minimal
  • src/s2i/bin/save-artifacts
  • src/s2i/bin/usage
💤 Files with no reviewable changes (4)
  • 24-minimal/Dockerfile.c8s
  • 24/Dockerfile.c8s
  • 22-minimal/Dockerfile.c8s
  • 22/Dockerfile.c8s

Comment thread src/Dockerfile
Comment on lines +71 to +73
{% if spec.prod == "c8s" or (spec.prod == "rhel8" and spec.version == "20") or (spec.prod == "c9s" and spec.version == "20") or (spec.prod == "rhel9" and spec.version == "20") %}yum{% else %}dnf{% endif %} -y clean all --enablerepo='*'{% if config.post_install %}

RUN {{ spec.post_install }}{% endif %}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm post_install field source and template namespace usage.
rg -n -C2 'post_install|config\.post_install|spec\.post_install' src/Dockerfile specs/multispec.yml manifest.yml manifest-minimal.yml

Repository: sclorg/s2i-nodejs-container

Length of output: 1325


🏁 Script executed:

rg -n 'config\.' src/Dockerfile

Repository: sclorg/s2i-nodejs-container

Length of output: 342


🏁 Script executed:

rg -n 'spec\.' src/Dockerfile | head -30

Repository: sclorg/s2i-nodejs-container

Length of output: 2958


Change post-install guard condition to use correct variable namespace.

Line 71 checks {% if config.post_install %} but line 73 renders {{ spec.post_install }}. The post_install field is defined in specs/multispec.yml under the spec namespace, so the guard condition will always be false and skip the post-install hook. Change the condition on line 71 to {% if spec.post_install %}.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Dockerfile` around lines 71 - 73, The conditional guard on line 71 checks
for `config.post_install` but the RUN directive on line 73 renders
`spec.post_install`, causing a namespace mismatch. Since the post_install field
is defined in the spec namespace in specs/multispec.yml, the condition will
always evaluate to false and skip the post-install hook. Change the conditional
on line 71 from `{% if config.post_install %}` to `{% if spec.post_install %}`
to match the namespace being used in the RUN statement.

Comment thread src/s2i/bin/run
Comment on lines +31 to +37
package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json)
package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json)

if [ -n "$package_json_start" ]; then
start_command=$package_json_start
elif [ -n $package_json_main ]; then
start_command="node ."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

unset package_json_main
if [ -n $package_json_main ]; then
  echo "unquoted check => true (bug)"
else
  echo "unquoted check => false"
fi

if [ -n "$package_json_main" ]; then
  echo "quoted check => true"
else
  echo "quoted check => false (expected)"
fi

bash -c 'set -e; sed -n "s/.*/x/p" package.json; echo "still running"' 2>/dev/null || \
  echo "missing package.json causes non-zero path under set -e"

Repository: sclorg/s2i-nodejs-container

Length of output: 126


🏁 Script executed:

cat -n src/s2i/bin/run | head -50

Repository: sclorg/s2i-nodejs-container

Length of output: 2147


🏁 Script executed:

#!/bin/bash
set -e

echo "=== Testing unquoted [ -n \$var ] without set -u ==="
unset package_json_main
if [ -n $package_json_main ]; then
  echo "unquoted empty var => true"
else
  echo "unquoted empty var => false (correct)"
fi

echo ""
echo "=== Testing sed on missing file under set -e ==="
bash -c 'set -e; sed -n "s/.*/x/p" nonexistent.json; echo "still running"' 2>&1 || \
  echo "FAILED: script exited due to sed failure (as expected)"

echo ""
echo "=== Verifying lines 34-37 logic ==="
# Simulate the scenario
package_json_start=""
package_json_main=""

echo "package_json_start='$package_json_start'"
echo "package_json_main='$package_json_main'"

if [ -n "$package_json_start" ]; then
  echo "Result: uses package_json_start"
elif [ -n $package_json_main ]; then
  echo "Result: uses package_json_main (node .)"
else
  echo "Result: falls through to other checks"
fi

Repository: sclorg/s2i-nodejs-container

Length of output: 435


Startup command detection fails when package_json_main is empty, and script exits if package.json is missing.

Line 36 uses [ -n $package_json_main ] unquoted. When the variable is empty, this expands to [ -n ], which evaluates to true because it tests whether the string "-n" itself is non-empty—incorrectly forcing start_command="node .". Additionally, lines 31–32 execute sed on package.json without checking file existence first, so a missing file will cause the script to exit under set -e.

Proposed fix
-    package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json)
-    package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json)
+    package_json_start=""
+    package_json_main=""
+    if [ -f "package.json" ]; then
+      package_json_start=$(sed -n 's/[[:space:]]*"start"[[:space:]]*:[[:space:]]*"\(.*\)".*/\1/p' package.json)
+      package_json_main=$(sed -n 's/[[:space:]]*"main"[[:space:]]*:[[:space:]]*"\(.*\)".*/\1/p' package.json)
+    fi
@@
-    elif [ -n $package_json_main ]; then
+    elif [ -n "$package_json_main" ]; then
       start_command="node ."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
package_json_start=$(sed -n 's/\s*"start"\s*:\s*"\(.*\)".*/\1/p' package.json)
package_json_main=$(sed -n 's/\s*"main"\s*:\s*"\(.*\)".*/\1/p' package.json)
if [ -n "$package_json_start" ]; then
start_command=$package_json_start
elif [ -n $package_json_main ]; then
start_command="node ."
package_json_start=""
package_json_main=""
if [ -f "package.json" ]; then
package_json_start=$(sed -n 's/[[:space:]]*"start"[[:space:]]*:[[:space:]]*"\(.*\)".*/\1/p' package.json)
package_json_main=$(sed -n 's/[[:space:]]*"main"[[:space:]]*:[[:space:]]*"\(.*\)".*/\1/p' package.json)
fi
if [ -n "$package_json_start" ]; then
start_command=$package_json_start
elif [ -n "$package_json_main" ]; then
start_command="node ."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/s2i/bin/run` around lines 31 - 37, The startup command detection has two
issues: First, on line 36, the condition `[ -n $package_json_main ]` uses an
unquoted variable, which when empty expands to `[ -n ]` and evaluates to true
incorrectly—add quotes around the variable to properly check if it is non-empty.
Second, lines 31-32 execute sed commands on package.json without verifying the
file exists first, which will cause the script to exit under set -e if the file
is missing—add a file existence check before the sed commands that read the
package.json file to ensure the script handles missing package.json gracefully.

@phracek phracek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Last round. Now it looks really awesome.

Comment thread src/Dockerfile
com.redhat.dev-mode.port="DEBUG_PORT:5858" \
com.redhat.component="{{ spec.redhat_component }}" \
name="{{ spec.img_name }}" \
{% if spec.prod != "rhel10" %} version="1" \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be removed at all. We do not needed.

Comment thread src/Dockerfile
{% endif %} com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \
usage="s2i build <SOURCE-REPOSITORY> {% if spec.prod in ["c8s", "c9s", "c10s"] %}quay.io/{% endif %}{{ spec.img_name }}{% if spec.prod != "rhel10" %}:latest{% endif %} <APP-NAME>"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe directly specified for each manifest version and then use something like {{ spec.full_image_name }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants