From 744599000c42c7709149211a6ceed86401937bc8 Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Wed, 16 Jul 2025 09:33:42 +0200 Subject: [PATCH 1/6] Add Node.js 24 (1/3 - move latest dir) --- {22-minimal => 24-minimal}/.exclude-c8s | 0 {22-minimal => 24-minimal}/.exclude-c9s | 0 {22-minimal => 24-minimal}/Dockerfile.c10s | 0 {22-minimal => 24-minimal}/Dockerfile.c8s | 0 {22-minimal => 24-minimal}/Dockerfile.c9s | 0 {22-minimal => 24-minimal}/Dockerfile.fedora | 0 {22-minimal => 24-minimal}/Dockerfile.rhel10 | 0 {22-minimal => 24-minimal}/Dockerfile.rhel8 | 0 {22-minimal => 24-minimal}/Dockerfile.rhel9 | 0 {22-minimal => 24-minimal}/README.md | 0 {22-minimal => 24-minimal}/root/usr/bin/fix-permissions | 0 {22-minimal => 24-minimal}/s2i/bin/assemble | 0 {22-minimal => 24-minimal}/s2i/bin/init-wrapper | 0 {22-minimal => 24-minimal}/s2i/bin/run | 0 {22-minimal => 24-minimal}/s2i/bin/save-artifacts | 0 {22-minimal => 24-minimal}/s2i/bin/usage | 0 {22-minimal => 24-minimal}/test/check_imagestreams.py | 0 {22-minimal => 24-minimal}/test/examples | 0 {22-minimal => 24-minimal}/test/imagestreams | 0 {22-minimal => 24-minimal}/test/run | 0 {22-minimal => 24-minimal}/test/run-openshift-remote-cluster | 0 {22-minimal => 24-minimal}/test/test-app | 0 {22-minimal => 24-minimal}/test/test-binary | 0 {22-minimal => 24-minimal}/test/test-express-webapp | 0 {22-minimal => 24-minimal}/test/test-hw | 0 {22-minimal => 24-minimal}/test/test-incremental | 0 {22-minimal => 24-minimal}/test/test-lib-nodejs.sh | 0 {22-minimal => 24-minimal}/test/test-lib-openshift.sh | 0 {22-minimal => 24-minimal}/test/test-lib-remote-openshift.sh | 0 {22-minimal => 24-minimal}/test/test-lib.sh | 0 {22-minimal => 24-minimal}/test/test-openshift.yaml | 0 {22 => 24}/.exclude-c8s | 0 {22 => 24}/.exclude-c9s | 0 {22 => 24}/Dockerfile.c10s | 0 {22 => 24}/Dockerfile.c8s | 0 {22 => 24}/Dockerfile.c9s | 0 {22 => 24}/Dockerfile.fedora | 0 {22 => 24}/Dockerfile.rhel10 | 0 {22 => 24}/Dockerfile.rhel8 | 0 {22 => 24}/Dockerfile.rhel9 | 0 {22 => 24}/README.md | 0 {22 => 24}/root/opt/app-root/etc/generate_container_user | 0 {22 => 24}/root/opt/app-root/etc/npm_global_module_list | 0 {22 => 24}/root/opt/app-root/etc/scl_enable | 0 {22 => 24}/s2i/bin/assemble | 0 {22 => 24}/s2i/bin/init-wrapper | 0 {22 => 24}/s2i/bin/run | 0 {22 => 24}/s2i/bin/save-artifacts | 0 {22 => 24}/s2i/bin/usage | 0 {22 => 24}/test | 0 50 files changed, 0 insertions(+), 0 deletions(-) rename {22-minimal => 24-minimal}/.exclude-c8s (100%) rename {22-minimal => 24-minimal}/.exclude-c9s (100%) rename {22-minimal => 24-minimal}/Dockerfile.c10s (100%) rename {22-minimal => 24-minimal}/Dockerfile.c8s (100%) rename {22-minimal => 24-minimal}/Dockerfile.c9s (100%) rename {22-minimal => 24-minimal}/Dockerfile.fedora (100%) rename {22-minimal => 24-minimal}/Dockerfile.rhel10 (100%) rename {22-minimal => 24-minimal}/Dockerfile.rhel8 (100%) rename {22-minimal => 24-minimal}/Dockerfile.rhel9 (100%) rename {22-minimal => 24-minimal}/README.md (100%) rename {22-minimal => 24-minimal}/root/usr/bin/fix-permissions (100%) rename {22-minimal => 24-minimal}/s2i/bin/assemble (100%) rename {22-minimal => 24-minimal}/s2i/bin/init-wrapper (100%) rename {22-minimal => 24-minimal}/s2i/bin/run (100%) rename {22-minimal => 24-minimal}/s2i/bin/save-artifacts (100%) rename {22-minimal => 24-minimal}/s2i/bin/usage (100%) rename {22-minimal => 24-minimal}/test/check_imagestreams.py (100%) rename {22-minimal => 24-minimal}/test/examples (100%) rename {22-minimal => 24-minimal}/test/imagestreams (100%) rename {22-minimal => 24-minimal}/test/run (100%) rename {22-minimal => 24-minimal}/test/run-openshift-remote-cluster (100%) rename {22-minimal => 24-minimal}/test/test-app (100%) rename {22-minimal => 24-minimal}/test/test-binary (100%) rename {22-minimal => 24-minimal}/test/test-express-webapp (100%) rename {22-minimal => 24-minimal}/test/test-hw (100%) rename {22-minimal => 24-minimal}/test/test-incremental (100%) rename {22-minimal => 24-minimal}/test/test-lib-nodejs.sh (100%) rename {22-minimal => 24-minimal}/test/test-lib-openshift.sh (100%) rename {22-minimal => 24-minimal}/test/test-lib-remote-openshift.sh (100%) rename {22-minimal => 24-minimal}/test/test-lib.sh (100%) rename {22-minimal => 24-minimal}/test/test-openshift.yaml (100%) rename {22 => 24}/.exclude-c8s (100%) rename {22 => 24}/.exclude-c9s (100%) rename {22 => 24}/Dockerfile.c10s (100%) rename {22 => 24}/Dockerfile.c8s (100%) rename {22 => 24}/Dockerfile.c9s (100%) rename {22 => 24}/Dockerfile.fedora (100%) rename {22 => 24}/Dockerfile.rhel10 (100%) rename {22 => 24}/Dockerfile.rhel8 (100%) rename {22 => 24}/Dockerfile.rhel9 (100%) rename {22 => 24}/README.md (100%) rename {22 => 24}/root/opt/app-root/etc/generate_container_user (100%) rename {22 => 24}/root/opt/app-root/etc/npm_global_module_list (100%) rename {22 => 24}/root/opt/app-root/etc/scl_enable (100%) rename {22 => 24}/s2i/bin/assemble (100%) rename {22 => 24}/s2i/bin/init-wrapper (100%) rename {22 => 24}/s2i/bin/run (100%) rename {22 => 24}/s2i/bin/save-artifacts (100%) rename {22 => 24}/s2i/bin/usage (100%) rename {22 => 24}/test (100%) diff --git a/22-minimal/.exclude-c8s b/24-minimal/.exclude-c8s similarity index 100% rename from 22-minimal/.exclude-c8s rename to 24-minimal/.exclude-c8s diff --git a/22-minimal/.exclude-c9s b/24-minimal/.exclude-c9s similarity index 100% rename from 22-minimal/.exclude-c9s rename to 24-minimal/.exclude-c9s diff --git a/22-minimal/Dockerfile.c10s b/24-minimal/Dockerfile.c10s similarity index 100% rename from 22-minimal/Dockerfile.c10s rename to 24-minimal/Dockerfile.c10s diff --git a/22-minimal/Dockerfile.c8s b/24-minimal/Dockerfile.c8s similarity index 100% rename from 22-minimal/Dockerfile.c8s rename to 24-minimal/Dockerfile.c8s diff --git a/22-minimal/Dockerfile.c9s b/24-minimal/Dockerfile.c9s similarity index 100% rename from 22-minimal/Dockerfile.c9s rename to 24-minimal/Dockerfile.c9s diff --git a/22-minimal/Dockerfile.fedora b/24-minimal/Dockerfile.fedora similarity index 100% rename from 22-minimal/Dockerfile.fedora rename to 24-minimal/Dockerfile.fedora diff --git a/22-minimal/Dockerfile.rhel10 b/24-minimal/Dockerfile.rhel10 similarity index 100% rename from 22-minimal/Dockerfile.rhel10 rename to 24-minimal/Dockerfile.rhel10 diff --git a/22-minimal/Dockerfile.rhel8 b/24-minimal/Dockerfile.rhel8 similarity index 100% rename from 22-minimal/Dockerfile.rhel8 rename to 24-minimal/Dockerfile.rhel8 diff --git a/22-minimal/Dockerfile.rhel9 b/24-minimal/Dockerfile.rhel9 similarity index 100% rename from 22-minimal/Dockerfile.rhel9 rename to 24-minimal/Dockerfile.rhel9 diff --git a/22-minimal/README.md b/24-minimal/README.md similarity index 100% rename from 22-minimal/README.md rename to 24-minimal/README.md diff --git a/22-minimal/root/usr/bin/fix-permissions b/24-minimal/root/usr/bin/fix-permissions similarity index 100% rename from 22-minimal/root/usr/bin/fix-permissions rename to 24-minimal/root/usr/bin/fix-permissions diff --git a/22-minimal/s2i/bin/assemble b/24-minimal/s2i/bin/assemble similarity index 100% rename from 22-minimal/s2i/bin/assemble rename to 24-minimal/s2i/bin/assemble diff --git a/22-minimal/s2i/bin/init-wrapper b/24-minimal/s2i/bin/init-wrapper similarity index 100% rename from 22-minimal/s2i/bin/init-wrapper rename to 24-minimal/s2i/bin/init-wrapper diff --git a/22-minimal/s2i/bin/run b/24-minimal/s2i/bin/run similarity index 100% rename from 22-minimal/s2i/bin/run rename to 24-minimal/s2i/bin/run diff --git a/22-minimal/s2i/bin/save-artifacts b/24-minimal/s2i/bin/save-artifacts similarity index 100% rename from 22-minimal/s2i/bin/save-artifacts rename to 24-minimal/s2i/bin/save-artifacts diff --git a/22-minimal/s2i/bin/usage b/24-minimal/s2i/bin/usage similarity index 100% rename from 22-minimal/s2i/bin/usage rename to 24-minimal/s2i/bin/usage diff --git a/22-minimal/test/check_imagestreams.py b/24-minimal/test/check_imagestreams.py similarity index 100% rename from 22-minimal/test/check_imagestreams.py rename to 24-minimal/test/check_imagestreams.py diff --git a/22-minimal/test/examples b/24-minimal/test/examples similarity index 100% rename from 22-minimal/test/examples rename to 24-minimal/test/examples diff --git a/22-minimal/test/imagestreams b/24-minimal/test/imagestreams similarity index 100% rename from 22-minimal/test/imagestreams rename to 24-minimal/test/imagestreams diff --git a/22-minimal/test/run b/24-minimal/test/run similarity index 100% rename from 22-minimal/test/run rename to 24-minimal/test/run diff --git a/22-minimal/test/run-openshift-remote-cluster b/24-minimal/test/run-openshift-remote-cluster similarity index 100% rename from 22-minimal/test/run-openshift-remote-cluster rename to 24-minimal/test/run-openshift-remote-cluster diff --git a/22-minimal/test/test-app b/24-minimal/test/test-app similarity index 100% rename from 22-minimal/test/test-app rename to 24-minimal/test/test-app diff --git a/22-minimal/test/test-binary b/24-minimal/test/test-binary similarity index 100% rename from 22-minimal/test/test-binary rename to 24-minimal/test/test-binary diff --git a/22-minimal/test/test-express-webapp b/24-minimal/test/test-express-webapp similarity index 100% rename from 22-minimal/test/test-express-webapp rename to 24-minimal/test/test-express-webapp diff --git a/22-minimal/test/test-hw b/24-minimal/test/test-hw similarity index 100% rename from 22-minimal/test/test-hw rename to 24-minimal/test/test-hw diff --git a/22-minimal/test/test-incremental b/24-minimal/test/test-incremental similarity index 100% rename from 22-minimal/test/test-incremental rename to 24-minimal/test/test-incremental diff --git a/22-minimal/test/test-lib-nodejs.sh b/24-minimal/test/test-lib-nodejs.sh similarity index 100% rename from 22-minimal/test/test-lib-nodejs.sh rename to 24-minimal/test/test-lib-nodejs.sh diff --git a/22-minimal/test/test-lib-openshift.sh b/24-minimal/test/test-lib-openshift.sh similarity index 100% rename from 22-minimal/test/test-lib-openshift.sh rename to 24-minimal/test/test-lib-openshift.sh diff --git a/22-minimal/test/test-lib-remote-openshift.sh b/24-minimal/test/test-lib-remote-openshift.sh similarity index 100% rename from 22-minimal/test/test-lib-remote-openshift.sh rename to 24-minimal/test/test-lib-remote-openshift.sh diff --git a/22-minimal/test/test-lib.sh b/24-minimal/test/test-lib.sh similarity index 100% rename from 22-minimal/test/test-lib.sh rename to 24-minimal/test/test-lib.sh diff --git a/22-minimal/test/test-openshift.yaml b/24-minimal/test/test-openshift.yaml similarity index 100% rename from 22-minimal/test/test-openshift.yaml rename to 24-minimal/test/test-openshift.yaml diff --git a/22/.exclude-c8s b/24/.exclude-c8s similarity index 100% rename from 22/.exclude-c8s rename to 24/.exclude-c8s diff --git a/22/.exclude-c9s b/24/.exclude-c9s similarity index 100% rename from 22/.exclude-c9s rename to 24/.exclude-c9s diff --git a/22/Dockerfile.c10s b/24/Dockerfile.c10s similarity index 100% rename from 22/Dockerfile.c10s rename to 24/Dockerfile.c10s diff --git a/22/Dockerfile.c8s b/24/Dockerfile.c8s similarity index 100% rename from 22/Dockerfile.c8s rename to 24/Dockerfile.c8s diff --git a/22/Dockerfile.c9s b/24/Dockerfile.c9s similarity index 100% rename from 22/Dockerfile.c9s rename to 24/Dockerfile.c9s diff --git a/22/Dockerfile.fedora b/24/Dockerfile.fedora similarity index 100% rename from 22/Dockerfile.fedora rename to 24/Dockerfile.fedora diff --git a/22/Dockerfile.rhel10 b/24/Dockerfile.rhel10 similarity index 100% rename from 22/Dockerfile.rhel10 rename to 24/Dockerfile.rhel10 diff --git a/22/Dockerfile.rhel8 b/24/Dockerfile.rhel8 similarity index 100% rename from 22/Dockerfile.rhel8 rename to 24/Dockerfile.rhel8 diff --git a/22/Dockerfile.rhel9 b/24/Dockerfile.rhel9 similarity index 100% rename from 22/Dockerfile.rhel9 rename to 24/Dockerfile.rhel9 diff --git a/22/README.md b/24/README.md similarity index 100% rename from 22/README.md rename to 24/README.md diff --git a/22/root/opt/app-root/etc/generate_container_user b/24/root/opt/app-root/etc/generate_container_user similarity index 100% rename from 22/root/opt/app-root/etc/generate_container_user rename to 24/root/opt/app-root/etc/generate_container_user diff --git a/22/root/opt/app-root/etc/npm_global_module_list b/24/root/opt/app-root/etc/npm_global_module_list similarity index 100% rename from 22/root/opt/app-root/etc/npm_global_module_list rename to 24/root/opt/app-root/etc/npm_global_module_list diff --git a/22/root/opt/app-root/etc/scl_enable b/24/root/opt/app-root/etc/scl_enable similarity index 100% rename from 22/root/opt/app-root/etc/scl_enable rename to 24/root/opt/app-root/etc/scl_enable diff --git a/22/s2i/bin/assemble b/24/s2i/bin/assemble similarity index 100% rename from 22/s2i/bin/assemble rename to 24/s2i/bin/assemble diff --git a/22/s2i/bin/init-wrapper b/24/s2i/bin/init-wrapper similarity index 100% rename from 22/s2i/bin/init-wrapper rename to 24/s2i/bin/init-wrapper diff --git a/22/s2i/bin/run b/24/s2i/bin/run similarity index 100% rename from 22/s2i/bin/run rename to 24/s2i/bin/run diff --git a/22/s2i/bin/save-artifacts b/24/s2i/bin/save-artifacts similarity index 100% rename from 22/s2i/bin/save-artifacts rename to 24/s2i/bin/save-artifacts diff --git a/22/s2i/bin/usage b/24/s2i/bin/usage similarity index 100% rename from 22/s2i/bin/usage rename to 24/s2i/bin/usage diff --git a/22/test b/24/test similarity index 100% rename from 22/test rename to 24/test From 3ff11e68ad5dd63dc243ad04b2dded9c18e2f921 Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Wed, 16 Jul 2025 09:34:22 +0200 Subject: [PATCH 2/6] Add Node.js 24 (2/3 - copy 24->22) --- 22-minimal/.exclude-c8s | 0 22-minimal/.exclude-c9s | 0 22-minimal/Dockerfile.c10s | 67 ++++ 22-minimal/Dockerfile.c8s | 69 ++++ 22-minimal/Dockerfile.c9s | 69 ++++ 22-minimal/Dockerfile.fedora | 71 ++++ 22-minimal/Dockerfile.rhel10 | 68 ++++ 22-minimal/Dockerfile.rhel8 | 70 ++++ 22-minimal/Dockerfile.rhel9 | 70 ++++ 22-minimal/README.md | 373 ++++++++++++++++++ 22-minimal/root/usr/bin/fix-permissions | 27 ++ 22-minimal/s2i/bin/assemble | 116 ++++++ 22-minimal/s2i/bin/init-wrapper | 18 + 22-minimal/s2i/bin/run | 79 ++++ 22-minimal/s2i/bin/save-artifacts | 5 + 22-minimal/s2i/bin/usage | 15 + 22-minimal/test/check_imagestreams.py | 1 + 22-minimal/test/examples | 1 + 22-minimal/test/imagestreams | 1 + 22-minimal/test/run | 1 + 22-minimal/test/run-openshift-remote-cluster | 1 + 22-minimal/test/test-app | 1 + 22-minimal/test/test-binary | 1 + 22-minimal/test/test-express-webapp | 1 + 22-minimal/test/test-hw | 1 + 22-minimal/test/test-incremental | 1 + 22-minimal/test/test-lib-nodejs.sh | 1 + 22-minimal/test/test-lib-openshift.sh | 1 + 22-minimal/test/test-lib-remote-openshift.sh | 1 + 22-minimal/test/test-lib.sh | 1 + 22-minimal/test/test-openshift.yaml | 1 + 22/.exclude-c8s | 0 22/.exclude-c9s | 0 22/Dockerfile.c10s | 80 ++++ 22/Dockerfile.c8s | 80 ++++ 22/Dockerfile.c9s | 80 ++++ 22/Dockerfile.fedora | 74 ++++ 22/Dockerfile.rhel10 | 80 ++++ 22/Dockerfile.rhel8 | 85 ++++ 22/Dockerfile.rhel9 | 79 ++++ 22/README.md | 302 ++++++++++++++ .../opt/app-root/etc/generate_container_user | 17 + .../opt/app-root/etc/npm_global_module_list | 5 + 22/root/opt/app-root/etc/scl_enable | 3 + 22/s2i/bin/assemble | 116 ++++++ 22/s2i/bin/init-wrapper | 18 + 22/s2i/bin/run | 83 ++++ 22/s2i/bin/save-artifacts | 5 + 22/s2i/bin/usage | 15 + 22/test | 1 + 50 files changed, 2255 insertions(+) create mode 100644 22-minimal/.exclude-c8s create mode 100644 22-minimal/.exclude-c9s create mode 100644 22-minimal/Dockerfile.c10s create mode 100644 22-minimal/Dockerfile.c8s create mode 100644 22-minimal/Dockerfile.c9s create mode 100644 22-minimal/Dockerfile.fedora create mode 100644 22-minimal/Dockerfile.rhel10 create mode 100644 22-minimal/Dockerfile.rhel8 create mode 100644 22-minimal/Dockerfile.rhel9 create mode 100644 22-minimal/README.md create mode 100755 22-minimal/root/usr/bin/fix-permissions create mode 100755 22-minimal/s2i/bin/assemble create mode 100644 22-minimal/s2i/bin/init-wrapper create mode 100755 22-minimal/s2i/bin/run create mode 100755 22-minimal/s2i/bin/save-artifacts create mode 100755 22-minimal/s2i/bin/usage create mode 120000 22-minimal/test/check_imagestreams.py create mode 120000 22-minimal/test/examples create mode 120000 22-minimal/test/imagestreams create mode 120000 22-minimal/test/run create mode 120000 22-minimal/test/run-openshift-remote-cluster create mode 120000 22-minimal/test/test-app create mode 120000 22-minimal/test/test-binary create mode 120000 22-minimal/test/test-express-webapp create mode 120000 22-minimal/test/test-hw create mode 120000 22-minimal/test/test-incremental create mode 120000 22-minimal/test/test-lib-nodejs.sh create mode 120000 22-minimal/test/test-lib-openshift.sh create mode 120000 22-minimal/test/test-lib-remote-openshift.sh create mode 120000 22-minimal/test/test-lib.sh create mode 120000 22-minimal/test/test-openshift.yaml create mode 100644 22/.exclude-c8s create mode 100644 22/.exclude-c9s create mode 100644 22/Dockerfile.c10s create mode 100644 22/Dockerfile.c8s create mode 100644 22/Dockerfile.c9s create mode 100644 22/Dockerfile.fedora create mode 100644 22/Dockerfile.rhel10 create mode 100644 22/Dockerfile.rhel8 create mode 100644 22/Dockerfile.rhel9 create mode 100644 22/README.md create mode 100644 22/root/opt/app-root/etc/generate_container_user create mode 100644 22/root/opt/app-root/etc/npm_global_module_list create mode 100644 22/root/opt/app-root/etc/scl_enable create mode 100755 22/s2i/bin/assemble create mode 100644 22/s2i/bin/init-wrapper create mode 100755 22/s2i/bin/run create mode 100755 22/s2i/bin/save-artifacts create mode 100755 22/s2i/bin/usage create mode 120000 22/test diff --git a/22-minimal/.exclude-c8s b/22-minimal/.exclude-c8s new file mode 100644 index 00000000..e69de29b diff --git a/22-minimal/.exclude-c9s b/22-minimal/.exclude-c9s new file mode 100644 index 00000000..e69de29b diff --git a/22-minimal/Dockerfile.c10s b/22-minimal/Dockerfile.c10s new file mode 100644 index 00000000..b558a0ba --- /dev/null +++ b/22-minimal/Dockerfile.c10s @@ -0,0 +1,67 @@ +FROM quay.io/sclorg/s2i-core-c10s + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application +ENV APP_ROOT=/opt/app-root \ + # The $HOME is not set by default, but some applications need this variable + HOME=/opt/app-root/src \ + NPM_RUN=start \ + PLATFORM="el10" \ + NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs + +ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ + name="sclorg/$NAME-$NODEJS_VERSION-minimal-c10s" \ + version="1" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" + +# nodejs-full-i18n is included for error strings +RUN INSTALL_PKGS="nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-full-i18n npm findutils tar which" && \ + dnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ + node-22 -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + dnf clean all && \ + rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* + +COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" +WORKDIR "$HOME" +USER 1001 diff --git a/22-minimal/Dockerfile.c8s b/22-minimal/Dockerfile.c8s new file mode 100644 index 00000000..d7829589 --- /dev/null +++ b/22-minimal/Dockerfile.c8s @@ -0,0 +1,69 @@ +FROM quay.io/sclorg/s2i-core-c8s + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application +ENV APP_ROOT=/opt/app-root \ + # The $HOME is not set by default, but some applications need this variable + HOME=/opt/app-root/src \ + NPM_RUN=start \ + PLATFORM="el8" \ + NODEJS_VERSION=20 \ + NPM_RUN=start \ + NAME=nodejs + +ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION Minimal" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ + name="sclorg/$NAME-$NODEJS_VERSION-minimal-c8s" \ + version="1" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" + +# nodejs-full-i18n is included for error strings +RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ + yum -y module disable nodejs && \ + yum -y module enable nodejs:$NODEJS_VERSION && \ + yum -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + yum clean all && \ + rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* + +COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" +WORKDIR "$HOME" +USER 1001 diff --git a/22-minimal/Dockerfile.c9s b/22-minimal/Dockerfile.c9s new file mode 100644 index 00000000..92275fbe --- /dev/null +++ b/22-minimal/Dockerfile.c9s @@ -0,0 +1,69 @@ +FROM quay.io/sclorg/s2i-core-c9s + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application +ENV APP_ROOT=/opt/app-root \ + # The $HOME is not set by default, but some applications need this variable + HOME=/opt/app-root/src \ + NPM_RUN=start \ + PLATFORM="el9" \ + NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs + +ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ + name="sclorg/$NAME-$NODEJS_VERSION-minimal-c9s" \ + version="1" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" + +# nodejs-full-i18n is included for error strings +RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ + yum -y module disable nodejs && \ + yum -y module enable nodejs:$NODEJS_VERSION && \ + yum -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + yum clean all && \ + rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* + +COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" +WORKDIR "$HOME" +USER 1001 diff --git a/22-minimal/Dockerfile.fedora b/22-minimal/Dockerfile.fedora new file mode 100644 index 00000000..149c4955 --- /dev/null +++ b/22-minimal/Dockerfile.fedora @@ -0,0 +1,71 @@ +FROM quay.io/fedora/fedora-minimal:40 + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application +ENV APP_ROOT=/opt/app-root \ + # The $HOME is not set by default, but some applications need this variable + HOME=/opt/app-root/src \ + NPM_RUN=start \ + PLATFORM="fedora" \ + NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs + +ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ + name="fedora/$NAME-$NODEJS_VERSION-minimal" \ + version="1" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" + +# nodejs-full-i18n is included for error strings +RUN INSTALL_PKGS="nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-full-i18n nodejs$NODEJS_VERSION-npm findutils tar which nss_wrapper-libs" && \ + microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ + microdnf clean all && \ + ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \ + ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \ + ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* + +# +COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" +WORKDIR "$HOME" +USER 1001 diff --git a/22-minimal/Dockerfile.rhel10 b/22-minimal/Dockerfile.rhel10 new file mode 100644 index 00000000..1ded9dd1 --- /dev/null +++ b/22-minimal/Dockerfile.rhel10 @@ -0,0 +1,68 @@ +FROM ubi10-minimal:latest + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application +ENV APP_ROOT=/opt/app-root \ + # The $HOME is not set by default, but some applications need this variable + HOME=/opt/app-root/src \ + NPM_RUN=start \ + PLATFORM="el10" \ + NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs + +ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ + name="ubi9/$NAME-$NODEJS_VERSION-minimal" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" + +# nodejs-full-i18n is included for error strings +RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ + microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + microdnf clean all && \ + rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* + +COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" +WORKDIR "$HOME" +USER 1001 diff --git a/22-minimal/Dockerfile.rhel8 b/22-minimal/Dockerfile.rhel8 new file mode 100644 index 00000000..5f6d0bc3 --- /dev/null +++ b/22-minimal/Dockerfile.rhel8 @@ -0,0 +1,70 @@ +FROM ubi8/ubi-minimal:latest + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application +ENV APP_ROOT=/opt/app-root \ + # The $HOME is not set by default, but some applications need this variable + HOME=/opt/app-root/src \ + NPM_RUN=start \ + PLATFORM="el8" \ + NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs + +ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION Minimal" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ + name="ubi8/$NAME-$NODEJS_VERSION-minimal" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" + +# nodejs-full-i18n is included for error strings +RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ + microdnf -y module disable nodejs && \ + microdnf -y module enable nodejs:$NODEJS_VERSION && \ + microdnf --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + microdnf clean all && \ + rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* + +COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" +WORKDIR "$HOME" +USER 1001 diff --git a/22-minimal/Dockerfile.rhel9 b/22-minimal/Dockerfile.rhel9 new file mode 100644 index 00000000..9a18e3ec --- /dev/null +++ b/22-minimal/Dockerfile.rhel9 @@ -0,0 +1,70 @@ +FROM ubi9/ubi-minimal + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application +ENV APP_ROOT=/opt/app-root \ + # The $HOME is not set by default, but some applications need this variable + HOME=/opt/app-root/src \ + NPM_RUN=start \ + PLATFORM="el9" \ + NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs + +ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \ + name="ubi9/$NAME-$NODEJS_VERSION-minimal" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" + +# nodejs-full-i18n is included for error strings +RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \ + microdnf -y module disable nodejs && \ + microdnf -y module enable nodejs:$NODEJS_VERSION && \ + microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + microdnf clean all && \ + rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* + +COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT" +WORKDIR "$HOME" +USER 1001 diff --git a/22-minimal/README.md b/22-minimal/README.md new file mode 100644 index 00000000..e9e5170a --- /dev/null +++ b/22-minimal/README.md @@ -0,0 +1,373 @@ +NodeJS 22 minimal container image +========================= + +This container image includes Node.JS 22 on top of a minimal base image for your Node.JS 22 applications. This image is designed to be used +with the full-sized s2i-enabled Node.JS 22 image to build the application. The image can be used as a standalone s2i-enabled image as well, +but compared to the full-sized Node.JS 22 image it will be missing many build-time dependencies. +Users can choose between RHEL, CentOS and Fedora based images. +The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), +the CentOS Stream images are available in the [Quay.io](https://quay.io/organization/sclorg), +and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora). +The resulting image can be run using [podman](https://github.com/containers/libpod). + +Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments + +Description +----------- + +Node.js 22 available as a minimal container is a base platform for +running various Node.js 22 applications and frameworks. +Node.js is a platform built on Chrome's JavaScript runtime for easily building +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model +that makes it lightweight and efficient, perfect for data-intensive real-time applications +that run across distributed devices. + +Usage in OpenShift +------------------ +In this example, we will assume that you are using the `ubi8/nodejs-22` image, available via `nodejs:22-ubi8` imagestream tag in Openshift +to build the application, as well as the `ubi8/nodejs-22-minimal` image, available via `nodejs:22-ubi8-minimal` image stream +for running the resulting application. + +With these two images we can create a [chained build](https://docs.openshift.com/container-platform/4.7/cicd/builds/advanced-build-operations.html#builds-chaining-builds_advanced-build-operations) in Openshift using two BuildConfigs: + +The first BuildConfig defines and builds the builder image, using the source-to-image strategy, and pushes the result into +the `nodejs-builder-image` imagestream. + +``` +apiVersion: build.openshift.io/v1 +kind: BuildConfig +metadata: + name: nodejs-builder-image +spec: + output: + to: + kind: ImageStreamTag + name: nodejs-builder-image:latest + source: + git: + uri: https://github.com/sclorg/nodejs-ex.git + strategy: + sourceStrategy: + from: + kind: ImageStreamTag + name: nodejs:22-ubi8 + namespace: openshift +``` + +The second BuildConfig takes the resulting image from the `nodejs-builder-image` imagestream, copies the application source (including build artifacts) +from the image and creates a new runtime image on top of the nodejs minimal image, with the application copied in and prepared to run. +The resulting runtime image is then pushed into the `nodejs-runtime-image` imagestream. + +``` +apiVersion: build.openshift.io/v1 +kind: BuildConfig +metadata: + name: nodejs-runtime-image +spec: + output: + to: + kind: ImageStreamTag + name: nodejs-runtime-image:latest + source: + dockerfile: |- + FROM nodejs:22-ubi8-minimal + COPY src $HOME + CMD /usr/libexec/s2i/run + images: + - from: + kind: ImageStreamTag + name: nodejs-builder-image:latest + paths: + - sourcePath: /opt/app-root/src + destinationDir: "." + strategy: + dockerStrategy: + from: + kind: ImageStreamTag + name: nodejs:22-ubi8-minimal + triggers: + - imageChange: {} + type: ImageChange +``` + +Source-to-Image framework and scripts +------------------------------------- +This image supports the [Source-to-Image](https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html#images-create-s2i_create-images) +(S2I) strategy in OpenShift. The Source-to-Image is an OpenShift framework +which makes it easy to write images that take application source code as +an input, use a builder image like this Node.js container image, and produce +a new image that runs the assembled application as an output. + +To support the Source-to-Image framework, only the `run` script is included in this image. + +* The `/usr/libexec/s2i/run` script is set as the default command in the resulting container image (the new image with the application artifacts). It runs `npm run` for production, or `nodemon` if `DEV_MODE` is set to `true` (see the **Environment variables** section below). + +Building an application using a Dockerfile +------------------------------------------ +Compared to the Source-to-Image strategy, using a Dockerfile is a more +flexible way to build a Node.js container image with an application. +Use a Dockerfile when Source-to-Image is not sufficiently flexible for you or +when you build the image outside of the OpenShift environment. + +To use the Node.js image in a Dockerfile, follow these steps: + +#### 1. Pull the base builder and minimal runtime images + +``` +podman pull ubi8/nodejs-22 +podman pull ubi8/nodejs-22-minimal +``` + +The UBI images `ubi8/nodejs-22` and `ubi8/nodejs-22-minimal` that are used in this example are both usable and freely redistributable under the terms of the UBI End User License Agreement (EULA). See more about UBI at [UBI FAQ](https://developers.redhat.com/articles/ubi-faq). + +#### 2. Pull an application code + +An example application available at https://github.com/sclorg/nodejs-ex.git is used here. Feel free to clone the repository for further experiments. + +``` +git clone https://github.com/sclorg/nodejs-ex.git app-src +``` + +#### 3. Prepare an application inside a container + +This step usually consists of at least these parts: + +* putting the application source into the container +* installing the dependencies +* setting the default command in the resulting image + +For all these three parts, users can either setup all manually and use commands `nodejs` and `npm` explicitly in the Dockerfile ([3.1.](#31-to-use-your-own-setup-create-a-dockerfile-with-this-content)), or users can use the Source-to-Image scripts inside the image ([3.2.](#32-to-use-the-source-to-image-scripts-and-build-an-image-using-a-dockerfile-create-a-dockerfile-with-this-content); see more about these scripts in the section "Source-to-Image framework and scripts" above), that already know how to set-up and run some common Node.js applications. + +##### 3.1. To use your own setup, create a Dockerfile with this content: +``` +# First stage builds the application +FROM ubi8/nodejs-22 as builder + +# Add application sources +ADD app-src $HOME + +# Install the dependencies +RUN npm install + +# Second stage copies the application to the minimal image +FROM ubi8/nodejs-22-minimal + +# Copy the application source and build artifacts from the builder image to this one +COPY --from=builder $HOME $HOME + +# Run script uses standard ways to run the application +CMD npm run -d start +``` + +##### 3.2. To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: +``` +# First stage builds the application +FROM ubi8/nodejs-22 as builder + +# Add application sources to a directory that the assemble script expects them +# and set permissions so that the container runs without root access +USER 0 +ADD app-src /tmp/src +RUN chown -R 1001:0 /tmp/src +USER 1001 + +# Install the dependencies +RUN /usr/libexec/s2i/assemble + +# Second stage copies the application to the minimal image +FROM ubi8/nodejs-22-minimal + +# Copy the application source and build artifacts from the builder image to this one +COPY --from=builder $HOME $HOME + +# Set the default command for the resulting image +CMD /usr/libexec/s2i/run +``` + +#### 4. Build a new image from a Dockerfile prepared in the previous step + +``` +podman build -t node-app . +``` + +#### 5. Run the resulting image with the final application + +``` +podman run -d node-app +``` + +Environment variables for Source-to-Image +--------------------- + +Application developers can use the following environment variables to configure the runtime behavior of this image in OpenShift: + +#### Used in the minimal image + +**`NODE_ENV`** + NodeJS runtime mode (default: "production") + +**`DEV_MODE`** + When set to "true", `nodemon` will be used to automatically reload the server while you work (default: "false"). Setting `DEV_MODE` to "true" will change the `NODE_ENV` default to "development" (if not explicitly set). + +**`NPM_BUILD`** + Select an alternate / custom build command, defined in your `package.json` file's [`scripts`](https://docs.npmjs.com/misc/scripts) section (default: npm run "build"). These user-defined run-scripts are unavailable while `DEV_MODE` is in use. + +**`NPM_RUN`** + Select an alternate / custom runtime mode, defined in your `package.json` file's [`scripts`](https://docs.npmjs.com/misc/scripts) section (default: npm run "start"). These user-defined run-scripts are unavailable while `DEV_MODE` is in use. + +**`NODE_CMD`** + When specified (e.g.Specify `NODE_CMD="node server.js"`) the value of `NODE_CMD` is used to start the application instead of `npm start`. + +**`INIT_WRAPPER`** + When set to "true", the application is started via the `init-wrapper` script instead of using `npm start`, by looking for the presence of the files `server.js`, `index.js` or `main.js` in the order in which they are listed. In case of `NODE_CMD` environemnt variale is specified, then `init-wrapper` script will use the value of `NODE_CMD` to start your application. + +#### Additional variables used in the full-sized image + +**`HTTP_PROXY`** + Use an npm proxy during assembly + +**`HTTPS_PROXY`** + Use an npm proxy during assembly + +**`NPM_MIRROR`** + Use a custom NPM registry mirror to download packages during the build process + +One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file. + +Example: DATABASE_USER=sampleUser + +#### NOTE: Define your own "`DEV_MODE`": + +The following `package.json` example includes a `scripts.dev` entry. You can define your own custom [`NPM_RUN`](https://docs.npmjs.com/cli/run-script) scripts in your application's `package.json` file. + +#### Note: Setting logging output verbosity +To alter the level of logs output during an `npm install` the npm_config_loglevel environment variable can be set. See [npm-config](https://docs.npmjs.com/misc/config). + +Development Mode +---------------- +This image supports development mode. This mode can be switched on and off with the environment variable `DEV_MODE`. `DEV_MODE` can either be set to `true` or `false`. +Development mode supports two features: +* Hot Deploy +* Debugging + +The debug port can be specified with the environment variable `DEBUG_PORT`. `DEBUG_PORT` is only valid if `DEV_MODE=true`. + +A simple example command for running the container in development mode is: +``` +podman run --env DEV_MODE=true my-image-id +``` + +To run the container in development mode with a debug port of 5454, run: +``` +$ podman run --env DEV_MODE=true DEBUG_PORT=5454 my-image-id +``` + +To run the container in production mode, run: +``` +$ podman run --env DEV_MODE=false my-image-id +``` + +By default, `DEV_MODE` is set to `false`, and `DEBUG_PORT` is set to `5858`, however the `DEBUG_PORT` is only relevant if `DEV_MODE=true`. + +Hot deploy +---------- + +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. + +### Using Podman's exec + +To change your source code in a running container, use Podman's [exec](https://github.com/containers/libpod) command: +``` +$ podman exec -it /bin/bash +``` + +After you [Podman exec](https://github.com/containers/libpod) into the running container, your current directory is set to `/opt/app-root/src`, where the source code for your application is located. + +### Using OpenShift's rsync + +If you have deployed the container to OpenShift, you can use [oc rsync](https://docs.openshift.org/latest/dev_guide/copy_files_to_container.html) to copy local files to a remote container running in an OpenShift pod. + +#### Warning: + +The default behaviour of the s2i-nodejs container image is to run the Node.js application using the command `npm start`. This runs the _start_ script in the _package.json_ file. In developer mode, the application is run using the command `nodemon`. The default behaviour of nodemon is to look for the _main_ attribute in the _package.json_ file, and execute that script. If the _main_ attribute doesn't appear in the _package.json_ file, it executes the _start_ script. So, in order to achieve some sort of uniform functionality between production and development modes, the user should remove the _main_ attribute. + +Below is an example _package.json_ file with the _main_ attribute and _start_ script marked appropriately: + +```json +{ + "name": "node-echo", + "version": "0.0.1", + "description": "node-echo", + "main": "example.js", <--- main attribute + "dependencies": { + }, + "devDependencies": { + "nodemon": "*" + }, + "engine": { + "node": "*", + "npm": "*" + }, + "scripts": { + "dev": "nodemon --ignore node_modules/ server.js", + "start": "node server.js" <-- start script + }, + "keywords": [ + "Echo" + ], + "license": "", +} +``` + +#### Note: +`oc rsync` is only available in versions 3.1+ of OpenShift. + +## init-wrapper + +init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used to handle: + +- Proper signal handling and propagation, as Node.js was not designed to run as PID 1. +- Reaping zombie child processes +Avoiding use of npm, there is more information on why you want to avoid that in the [Node.js reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application). When the INIT_WRAPPER is set to true the application is started via the init script instead of using npm start. + +A detailed explanation on how the init-wrapper script works is avalable in +[this url](http://veithen.io/2014/11/16/sigterm-propagation.html). + +Example of using init-wrapper: + +**During image build** +``` +s2i -e INIT_WRAPPER=true build . buildImage node-app +docker run node-app +``` +**During container start** +``` +s2i build . buildImage node-app +docker run -e INIT_WRAPPER=true node-app +``` + +`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`. + +``` +docker run -e INIT_WRAPPER=false node-app +``` +`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap. + +For example: + +**during container build** +``` +s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app +``` +**during container start** +``` +docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app +``` +See also +-------- +Dockerfile and other sources are available on https://github.com/sclorg/s2i-nodejs-container. +In that repository you also can find another versions of Node.js environment Dockerfiles. +Dockerfile for CentOS Stream 9 is called `Dockerfile.c9s`, +Dockerfile for CentOS Stream 10 is called `Dockerfile.c10s`, +for RHEL8 it's `Dockerfile.rhel8`, for RHEL9 it's `Dockerfile.rhel9`, +for RHEL10 it's `Dockerfile.rhel10` and the Fedora Dockerfile is called Dockerfile.fedora. diff --git a/22-minimal/root/usr/bin/fix-permissions b/22-minimal/root/usr/bin/fix-permissions new file mode 100755 index 00000000..ddd33ace --- /dev/null +++ b/22-minimal/root/usr/bin/fix-permissions @@ -0,0 +1,27 @@ +#!/bin/sh + +# Allow this script to fail without failing a build +set +e + +SYMLINK_OPT=${2:--L} + +# Fix permissions on the given directory or file to allow group read/write of +# regular files and execute of directories. + +[ $(id -u) -ne 0 ] && CHECK_OWNER=" -uid $(id -u)" + +# If argument does not exist, script will still exit with 0, +# but at least we'll see something went wrong in the log +if ! [ -e "$1" ] ; then + echo "ERROR: File or directory $1 does not exist." >&2 + # We still want to end successfully + exit 0 +fi + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + + +# Always end successfully +exit 0 diff --git a/22-minimal/s2i/bin/assemble b/22-minimal/s2i/bin/assemble new file mode 100755 index 00000000..f644a811 --- /dev/null +++ b/22-minimal/s2i/bin/assemble @@ -0,0 +1,116 @@ +#!/bin/bash + +# Prevent running assemble in builders different than official STI image. +# The official nodejs:8-onbuild already run npm install and use different +# application folder. +[ -d "/usr/src/app" ] && exit 0 + +set -e + +# FIXME: Linking of global modules is disabled for now as it causes npm failures +# under RHEL7 +# Global modules good to have +# npmgl=$(grep "^\s*[^#\s]" ../etc/npm_global_module_list | sort -u) +# Available global modules; only match top-level npm packages +#global_modules=$(npm ls -g 2> /dev/null | perl -ne 'print "$1\n" if /^\S+\s(\S+)\@[\d\.-]+/' | sort -u) +# List all modules in common +#module_list=$(/usr/bin/comm -12 <(echo "${global_modules}") | tr '\n' ' ') +# Link the modules +#npm link $module_list + +safeLogging () { + if [[ $1 =~ http[s]?://.*@.*$ ]]; then + echo $1 | sed 's/^.*@/redacted@/' + else + echo $1 + fi +} + +shopt -s dotglob +if [ -d /tmp/artifacts ] && [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then + echo "---> Restoring previous build artifacts ..." + mv -T --verbose /tmp/artifacts/node_modules "${HOME}/node_modules" +fi + +echo "---> Installing application source ..." +mv /tmp/src/* ./ + +# Fix source directory permissions +fix-permissions ./ + +if [ ! -z $HTTP_PROXY ]; then + echo "---> Setting npm http proxy to" $(safeLogging $HTTP_PROXY) + npm config set proxy $HTTP_PROXY +fi + +if [ ! -z $http_proxy ]; then + echo "---> Setting npm http proxy to" $(safeLogging $http_proxy) + npm config set proxy $http_proxy +fi + +if [ ! -z $HTTPS_PROXY ]; then + echo "---> Setting npm https proxy to" $(safeLogging $HTTPS_PROXY) + npm config set https-proxy $HTTPS_PROXY +fi + +if [ ! -z $https_proxy ]; then + echo "---> Setting npm https proxy to" $(safeLogging $https_proxy) + npm config set https-proxy $https_proxy +fi + +# Change the npm registry mirror if provided +if [ -n "$NPM_MIRROR" ]; then + npm config set registry $NPM_MIRROR +fi + +# Set the DEV_MODE to false by default. +if [ -z "$DEV_MODE" ]; then + export DEV_MODE=false +fi + +# If NODE_ENV is not set by the user, then NODE_ENV is determined by whether +# the container is run in development mode. +if [ -z "$NODE_ENV" ]; then + if [ "$DEV_MODE" == true ]; then + export NODE_ENV=development + else + export NODE_ENV=production + fi +fi + +if [ "$NODE_ENV" != "production" ]; then + + echo "---> Building your Node application from source" + npm install + +else + + echo "---> Installing all dependencies" + NODE_ENV=development npm install + + #do not fail when there is no build script + echo "---> Building in production mode" + npm run ${NPM_BUILD:-build} --if-present + + echo "---> Pruning the development dependencies" + npm prune + + NPM_TMP=$(npm config get tmp) + if ! mountpoint $NPM_TMP; then + echo "---> Cleaning the $NPM_TMP/npm-*" + rm -rf $NPM_TMP/npm-* + fi + + # Clear the npm's cache and tmp directories only if they are not a docker volumes + NPM_CACHE=$(npm config get cache) + if ! mountpoint $NPM_CACHE; then + echo "---> Cleaning the npm cache $NPM_CACHE" + #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory + # instead of $NPM_CACHE* use $NPM_CACHE/*. + # We do not want to delete .npmrc file. + rm -rf "${NPM_CACHE:?}/" + fi +fi + +# Fix source directory permissions +fix-permissions ./ diff --git a/22-minimal/s2i/bin/init-wrapper b/22-minimal/s2i/bin/init-wrapper new file mode 100644 index 00000000..24e0d078 --- /dev/null +++ b/22-minimal/s2i/bin/init-wrapper @@ -0,0 +1,18 @@ +#!/bin/bash + +# Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html +# Set a trap to kill the main app process when this +# init script receives SIGTERM or SIGINT +trap 'kill -s TERM $PID' TERM INT +# Execute the main application in the background +"$@" & +PID=$! +# wait command always terminates when trap is caught, even if the process hasn't finished yet +wait $PID +# Remove the trap and wait till the app process finishes completely +trap - TERM INT +# We wait again, since the first wait terminates when trap is caught +wait $PID +# Exit with the exit code of the app process +STATUS=$? +exit $STATUS \ No newline at end of file diff --git a/22-minimal/s2i/bin/run b/22-minimal/s2i/bin/run new file mode 100755 index 00000000..10150f34 --- /dev/null +++ b/22-minimal/s2i/bin/run @@ -0,0 +1,79 @@ +#!/bin/bash + +# S2I run script for the 'nodejs' image. +# The run script executes the server that runs your application. +# +# For more information see the documentation: +# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md +# + +set -e + +# Runs the nodejs application server. If the container is run in development mode, +# hot deploy and debugging are enabled. +run_node() { + echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" + if [ "$DEV_MODE" == true ]; then + echo "Launching via nodemon..." + exec nodemon --inspect="$DEBUG_PORT" + elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then + echo "launching via init wrapper..." + exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD + elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then + echo "Launching via ${NODE_CMD}" + exec $NODE_CMD + elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then + + 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 ." + elif [ -f "server.js" ]; then + start_command="node server.js" + else + echo "Failed to find file for starting the Node.js application" + exit 1 + fi + echo "launching via init wrapper..." + exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command + else + echo "Launching via npm..." + exec npm run -d $NPM_RUN + fi +} + +#Set the debug port to 5858 by default. +if [ -z "$DEBUG_PORT" ]; then + export DEBUG_PORT=5858 +fi + +# Set the environment to development by default. +if [ -z "$DEV_MODE" ]; then + export DEV_MODE=false +fi + +# If NODE_ENV is not set by the user, then NODE_ENV is determined by whether +# the container is run in development mode. +if [ -z "$NODE_ENV" ]; then + if [ "$DEV_MODE" == true ]; then + export NODE_ENV=development + else + export NODE_ENV=production + fi +fi + +# If the official dockerhub node image is used, skip the SCL setup below +# and just run the nodejs server +if [ -d "/usr/src/app" ]; then + run_node +fi + +# Allow users to inspect/debug the builder image itself, by using: +# $ docker run -i -t openshift/centos-nodejs-builder --debug +# +[ "$1" == "--debug" ] && exec /bin/bash + +run_node diff --git a/22-minimal/s2i/bin/save-artifacts b/22-minimal/s2i/bin/save-artifacts new file mode 100755 index 00000000..16be05e7 --- /dev/null +++ b/22-minimal/s2i/bin/save-artifacts @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then + tar -C "${HOME}" -cf - node_modules +fi diff --git a/22-minimal/s2i/bin/usage b/22-minimal/s2i/bin/usage new file mode 100755 index 00000000..b8c1dca8 --- /dev/null +++ b/22-minimal/s2i/bin/usage @@ -0,0 +1,15 @@ +#!/bin/sh + +DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` + +cat < nodejs-sample-app + +You can then run the resulting image via: +podman run -p 8080:8080 nodejs-sample-app +EOF diff --git a/22-minimal/test/check_imagestreams.py b/22-minimal/test/check_imagestreams.py new file mode 120000 index 00000000..56bb2be7 --- /dev/null +++ b/22-minimal/test/check_imagestreams.py @@ -0,0 +1 @@ +../../common/check_imagestreams.py \ No newline at end of file diff --git a/22-minimal/test/examples b/22-minimal/test/examples new file mode 120000 index 00000000..da7b1965 --- /dev/null +++ b/22-minimal/test/examples @@ -0,0 +1 @@ +../../examples/ \ No newline at end of file diff --git a/22-minimal/test/imagestreams b/22-minimal/test/imagestreams new file mode 120000 index 00000000..0dcbe9e0 --- /dev/null +++ b/22-minimal/test/imagestreams @@ -0,0 +1 @@ +../../imagestreams/ \ No newline at end of file diff --git a/22-minimal/test/run b/22-minimal/test/run new file mode 120000 index 00000000..f446a740 --- /dev/null +++ b/22-minimal/test/run @@ -0,0 +1 @@ +../../test/run-minimal \ No newline at end of file diff --git a/22-minimal/test/run-openshift-remote-cluster b/22-minimal/test/run-openshift-remote-cluster new file mode 120000 index 00000000..1bffcba8 --- /dev/null +++ b/22-minimal/test/run-openshift-remote-cluster @@ -0,0 +1 @@ +../../test/run-openshift-remote-cluster \ No newline at end of file diff --git a/22-minimal/test/test-app b/22-minimal/test/test-app new file mode 120000 index 00000000..6ba4f290 --- /dev/null +++ b/22-minimal/test/test-app @@ -0,0 +1 @@ +../../test/test-app \ No newline at end of file diff --git a/22-minimal/test/test-binary b/22-minimal/test/test-binary new file mode 120000 index 00000000..cd7b631f --- /dev/null +++ b/22-minimal/test/test-binary @@ -0,0 +1 @@ +../../test/test-binary \ No newline at end of file diff --git a/22-minimal/test/test-express-webapp b/22-minimal/test/test-express-webapp new file mode 120000 index 00000000..6a5bbd41 --- /dev/null +++ b/22-minimal/test/test-express-webapp @@ -0,0 +1 @@ +../../test/test-express-webapp \ No newline at end of file diff --git a/22-minimal/test/test-hw b/22-minimal/test/test-hw new file mode 120000 index 00000000..ad784558 --- /dev/null +++ b/22-minimal/test/test-hw @@ -0,0 +1 @@ +../../test/test-hw \ No newline at end of file diff --git a/22-minimal/test/test-incremental b/22-minimal/test/test-incremental new file mode 120000 index 00000000..0a357b1f --- /dev/null +++ b/22-minimal/test/test-incremental @@ -0,0 +1 @@ +../../test/test-incremental \ No newline at end of file diff --git a/22-minimal/test/test-lib-nodejs.sh b/22-minimal/test/test-lib-nodejs.sh new file mode 120000 index 00000000..8915d844 --- /dev/null +++ b/22-minimal/test/test-lib-nodejs.sh @@ -0,0 +1 @@ +../../test/test-lib-nodejs.sh \ No newline at end of file diff --git a/22-minimal/test/test-lib-openshift.sh b/22-minimal/test/test-lib-openshift.sh new file mode 120000 index 00000000..4f9f2996 --- /dev/null +++ b/22-minimal/test/test-lib-openshift.sh @@ -0,0 +1 @@ +../../common/test-lib-openshift.sh \ No newline at end of file diff --git a/22-minimal/test/test-lib-remote-openshift.sh b/22-minimal/test/test-lib-remote-openshift.sh new file mode 120000 index 00000000..92ad2f4d --- /dev/null +++ b/22-minimal/test/test-lib-remote-openshift.sh @@ -0,0 +1 @@ +../../common/test-lib-remote-openshift.sh \ No newline at end of file diff --git a/22-minimal/test/test-lib.sh b/22-minimal/test/test-lib.sh new file mode 120000 index 00000000..1ac99b93 --- /dev/null +++ b/22-minimal/test/test-lib.sh @@ -0,0 +1 @@ +../../common/test-lib.sh \ No newline at end of file diff --git a/22-minimal/test/test-openshift.yaml b/22-minimal/test/test-openshift.yaml new file mode 120000 index 00000000..8613fbba --- /dev/null +++ b/22-minimal/test/test-openshift.yaml @@ -0,0 +1 @@ +../../common/test-openshift.yaml \ No newline at end of file diff --git a/22/.exclude-c8s b/22/.exclude-c8s new file mode 100644 index 00000000..e69de29b diff --git a/22/.exclude-c9s b/22/.exclude-c9s new file mode 100644 index 00000000..e69de29b diff --git a/22/Dockerfile.c10s b/22/Dockerfile.c10s new file mode 100644 index 00000000..0cc8da62 --- /dev/null +++ b/22/Dockerfile.c10s @@ -0,0 +1,80 @@ +FROM quay.io/sclorg/s2i-core-c10s:c10s + +# This image provides a Node.JS environment you can use to run your Node.JS +# applications. + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application + +ENV NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ + CNB_STACK_ID=com.redhat.stacks.c10s-nodejs-22 \ + CNB_USER_ID=1001 \ + CNB_GROUP_ID=0 + +ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +building and running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.buildpacks.stack.id="com.redhat.stacks.c10s-nodejs-22" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-container" \ + name="sclorg/$NAME-$NODEJS_VERSION-c10s" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ + usage="s2i build quay.io/sclorg/$NAME-$NODEJS_VERSION-c10s:latest " + +# Package libatomic_ops was removed +RUN INSTALL_PKGS="make gcc gcc-c++ git openssl-devel nodejs nodejs-nodemon nodejs-npm nss_wrapper-libs which" && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + rm /usr/bin/node && ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \ + rm /usr/bin/npm && ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \ + rm /usr/bin/npx && ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + dnf -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/22/Dockerfile.c8s b/22/Dockerfile.c8s new file mode 100644 index 00000000..6a7e0501 --- /dev/null +++ b/22/Dockerfile.c8s @@ -0,0 +1,80 @@ +FROM quay.io/sclorg/s2i-core-c8s + +# This image provides a Node.JS environment you can use to run your Node.JS +# applications. + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application + +ENV NODEJS_VERSION=20 \ + NPM_RUN=start \ + NAME=nodejs \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ + CNB_STACK_ID=com.redhat.stacks.c8s-nodejs-20 \ + CNB_USER_ID=1001 \ + CNB_GROUP_ID=0 + +ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +building and running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.buildpacks.stack.id="com.redhat.stacks.c8s-nodejs-20" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-container" \ + name="sclorg/$NAME-$NODEJS_VERSION-c8s" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ + usage="s2i build quay.io/sclorg/$NAME-$NODEJS_VERSION-c8s:latest " + +RUN yum -y module enable nodejs:$NODEJS_VERSION && \ + MODULE_DEPS="make gcc gcc-c++ libatomic_ops git openssl-devel" && \ + INSTALL_PKGS="$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper-libs which" && \ + 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 && \ + rpm -V $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + yum -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/22/Dockerfile.c9s b/22/Dockerfile.c9s new file mode 100644 index 00000000..0b47eefa --- /dev/null +++ b/22/Dockerfile.c9s @@ -0,0 +1,80 @@ +FROM quay.io/sclorg/s2i-core-c9s:c9s + +# This image provides a Node.JS environment you can use to run your Node.JS +# applications. + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application + +ENV NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ + CNB_STACK_ID=com.redhat.stacks.c9s-nodejs-22 \ + CNB_USER_ID=1001 \ + CNB_GROUP_ID=0 + +ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +building and running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.buildpacks.stack.id="com.redhat.stacks.c9s-nodejs-22" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-container" \ + name="sclorg/$NAME-$NODEJS_VERSION-c9s" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ + usage="s2i build quay.io/sclorg/$NAME-$NODEJS_VERSION-c9s:latest " + +# Package libatomic_ops was removed +RUN dnf -y module enable nodejs:$NODEJS_VERSION && \ + MODULE_DEPS="make gcc gcc-c++ git openssl-devel" && \ + INSTALL_PKGS="$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper-libs which" && \ + ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + dnf -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/22/Dockerfile.fedora b/22/Dockerfile.fedora new file mode 100644 index 00000000..49a16b05 --- /dev/null +++ b/22/Dockerfile.fedora @@ -0,0 +1,74 @@ +FROM quay.io/fedora/s2i-core:40 + +# This image provides a Node.JS environment you can use to run your Node.JS +# applications. + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application + +ENV NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH + +ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +building and running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,$NAME$NODEJS_VERSION" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858"\ + com.redhat.component="$NAME" \ + name="fedora/$NAME-$NODEJS_VERSION" \ + version="$NODEJS_VERSION" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ + usage="oc new-app $FGC/$NAME~" + +RUN INSTALL_PKGS="make gcc gcc-c++ libatomic_ops git openssl-devel nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-npm nss_wrapper-libs which" && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \ + ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \ + ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + dnf -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image, including help file. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/22/Dockerfile.rhel10 b/22/Dockerfile.rhel10 new file mode 100644 index 00000000..9d90d4e6 --- /dev/null +++ b/22/Dockerfile.rhel10 @@ -0,0 +1,80 @@ +FROM ubi10/s2i-core:latest + +# This image provides a Node.JS environment you can use to run your Node.JS +# applications. + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application + +ENV NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ + CNB_STACK_ID=com.redhat.stacks.c10s-nodejs-22 \ + CNB_USER_ID=1001 \ + CNB_GROUP_ID=0 + +ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +building and running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.buildpacks.stack.id="com.redhat.stacks.c10s-nodejs-22" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-container" \ + name="ubi10/$NAME-$NODEJS_VERSION" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ + usage="s2i build ubi10/$NAME-$NODEJS_VERSION " + +# Package libatomic_ops was removed +RUN INSTALL_PKGS="make gcc gcc-c++ git openssl-devel nodejs nodejs-nodemon nodejs-npm nss_wrapper-libs which" && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + rm /usr/bin/node && ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \ + rm /usr/bin/npm && ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \ + rm /usr/bin/npx && ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + dnf -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/22/Dockerfile.rhel8 b/22/Dockerfile.rhel8 new file mode 100644 index 00000000..1156ca11 --- /dev/null +++ b/22/Dockerfile.rhel8 @@ -0,0 +1,85 @@ +FROM ubi8/s2i-core:1 + +# This image provides a Node.JS environment you can use to run your Node.JS +# applications. + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application + +ENV NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ + CNB_STACK_ID=com.redhat.stacks.ubi8-nodejs-20 \ + CNB_USER_ID=1001 \ + CNB_GROUP_ID=0 + +ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +building and running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.buildpacks.stack.id="com.redhat.stacks.ubi8-nodejs-20" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-container" \ + name="ubi8/$NAME-$NODEJS_VERSION" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ + usage="s2i build ubi8/$NAME-$NODEJS_VERSION:latest " + +RUN dnf -y module enable nodejs:$NODEJS_VERSION && \ + MODULE_DEPS="make gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ gcc-toolset-13-runtime \ + libatomic_ops git openssl-devel python3.12" && \ + INSTALL_PKGS="$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper-libs which" && \ + ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + dnf -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Enable the SCL for all bash scripts. +ENV BASH_ENV=/opt/rh/gcc-toolset-13/enable \ + ENV=/opt/rh/gcc-toolset-13/enable \ + PROMPT_COMMAND=". /opt/rh/gcc-toolset-13/enable" + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/22/Dockerfile.rhel9 b/22/Dockerfile.rhel9 new file mode 100644 index 00000000..c6c4a1e6 --- /dev/null +++ b/22/Dockerfile.rhel9 @@ -0,0 +1,79 @@ +FROM ubi9/s2i-core:1 + +# This image provides a Node.JS environment you can use to run your Node.JS +# applications. + +EXPOSE 8080 + +# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts +# available on the CLI without using npm's --global installation mode +# This image will be initialized with "npm run $NPM_RUN" +# See https://docs.npmjs.com/misc/scripts, and your repo's package.json +# file for possible values of NPM_RUN +# Description +# Environment: +# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start"). +# Expose ports: +# * 8080 - Unprivileged port used by nodejs application + +ENV NODEJS_VERSION=22 \ + NPM_RUN=start \ + NAME=nodejs \ + NPM_CONFIG_PREFIX=$HOME/.npm-global \ + PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ + CNB_STACK_ID=com.redhat.stacks.ubi9-nodejs-20 \ + CNB_USER_ID=1001 \ + CNB_GROUP_ID=0 + +ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \ + DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \ +building and running various Node.js $NODEJS_VERSION applications and frameworks. \ +Node.js is a platform built on Chrome's JavaScript runtime for easily building \ +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \ +that makes it lightweight and efficient, perfect for data-intensive real-time applications \ +that run across distributed devices." + +LABEL summary="$SUMMARY" \ + description="$DESCRIPTION" \ + io.k8s.description="$DESCRIPTION" \ + io.k8s.display-name="Node.js $NODEJS_VERSION" \ + io.openshift.expose-services="8080:http" \ + io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ + io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.s2i.scripts-url="image:///usr/libexec/s2i" \ + io.buildpacks.stack.id="com.redhat.stacks.ubi9-nodejs-20" \ + com.redhat.dev-mode="DEV_MODE:false" \ + com.redhat.deployments-dir="${APP_ROOT}/src" \ + com.redhat.dev-mode.port="DEBUG_PORT:5858" \ + com.redhat.component="${NAME}-${NODEJS_VERSION}-container" \ + name="ubi9/$NAME-$NODEJS_VERSION" \ + version="1" \ + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ + maintainer="SoftwareCollections.org " \ + help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \ + usage="s2i build ubi9/$NAME-$NODEJS_VERSION:latest " + +RUN dnf -y module enable nodejs:$NODEJS_VERSION && \ + MODULE_DEPS="make gcc gcc-c++ git openssl-devel" && \ + INSTALL_PKGS="$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper-libs which" && \ + ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && \ + dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + dnf -y clean all --enablerepo='*' + +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH +COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x /usr/libexec/s2i/init-wrapper + +# Copy extra files to the image. +COPY ./root/ / + +# Drop the root user and make the content of /opt/app-root owned by user 1001 +RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \ + rpm-file-permissions + +USER 1001 + +# Set the default CMD to print the usage of the language image +CMD $STI_SCRIPTS_PATH/usage diff --git a/22/README.md b/22/README.md new file mode 100644 index 00000000..380cb26d --- /dev/null +++ b/22/README.md @@ -0,0 +1,302 @@ +NodeJS 22 container image +========================= + +This container image includes Node.JS 22 as a [S2I](https://github.com/openshift/source-to-image) base image for your Node.JS 22 applications. +Users can choose between RHEL, CentOS and Fedora based images. +The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), +and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora). +the CentOS Stream images are available in the [Quay.io](https://quay.io/organization/sclorg), +The resulting image can be run using [podman](https://github.com/containers/libpod). + +Note: while the examples in this README are calling `podman`, you can replace any such calls by `docker` with the same arguments + +Description +----------- + +Node.js 22 available as container is a base platform for +building and running various Node.js 22 applications and frameworks. +Node.js is a platform built on Chrome's JavaScript runtime for easily building +fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model +that makes it lightweight and efficient, perfect for data-intensive real-time applications +that run across distributed devices. + +Usage in OpenShift +------------------ +In this example, we will assume that you are using the `ubi8/nodejs-22` image, available via `nodejs:22` imagestream tag in Openshift. + +To build a simple [nodejs-sample-app](https://github.com/sclorg/nodejs-ex.git) application in Openshift: + +``` +oc new-app nodejs:22~https://github.com/sclorg/nodejs-ex.git +``` + +To access the application: +``` +$ oc get pods +$ oc exec -- curl 127.0.0.1:8080 +``` + +Source-to-Image framework and scripts +------------------------------------- +This image supports the [Source-to-Image](https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html#images-create-s2i_create-images) +(S2I) strategy in OpenShift. The Source-to-Image is an OpenShift framework +which makes it easy to write images that take application source code as +an input, use a builder image like this Node.js container image, and produce +a new image that runs the assembled application as an output. + +To support the Source-to-Image framework, important scripts are included in the builder image: + +* The `/usr/libexec/s2i/assemble` script inside the image is run to produce a new image with the application artifacts. The script takes sources of a given application and places them into appropriate directories inside the image. It utilizes some common patterns in Node.js application development (see the **Environment variables** section below). +* The `/usr/libexec/s2i/run` script is set as the default command in the resulting container image (the new image with the application artifacts). It runs `npm run` for production, or `nodemon` if `DEV_MODE` is set to `true` (see the **Environment variables** section below). + +Building an application using a Dockerfile +------------------------------------------ +Compared to the Source-to-Image strategy, using a Dockerfile is a more +flexible way to build a Node.js container image with an application. +Use a Dockerfile when Source-to-Image is not sufficiently flexible for you or +when you build the image outside of the OpenShift environment. + +To use the Node.js image in a Dockerfile, follow these steps: + +#### 1. Pull a base builder image to build on + +``` +podman pull ubi8/nodejs-22 +``` + +An UBI image `ubi8/nodejs-22` is used in this example. This image is usable and freely redistributable under the terms of the UBI End User License Agreement (EULA). See more about UBI at [UBI FAQ](https://developers.redhat.com/articles/ubi-faq). + +#### 2. Pull an application code + +An example application available at https://github.com/sclorg/nodejs-ex.git is used here. Feel free to clone the repository for further experiments. + +``` +git clone https://github.com/sclorg/nodejs-ex.git app-src +``` + +#### 3. Prepare an application inside a container + +This step usually consists of at least these parts: + +* putting the application source into the container +* installing the dependencies +* setting the default command in the resulting image + +For all these three parts, users can either setup all manually and use commands `nodejs` and `npm` explicitly in the Dockerfile ([3.1.](#31-to-use-your-own-setup-create-a-dockerfile-with-this-content)), or users can use the Source-to-Image scripts inside the image ([3.2.](#32-to-use-the-source-to-image-scripts-and-build-an-image-using-a-dockerfile-create-a-dockerfile-with-this-content); see more about these scripts in the section "Source-to-Image framework and scripts" above), that already know how to set-up and run some common Node.js applications. + +##### 3.1. To use your own setup, create a Dockerfile with this content: +``` +FROM ubi8/nodejs-22 + +# Add application sources +ADD app-src . + +# Install the dependencies +RUN npm install + +# Run script uses standard ways to run the application +CMD npm run -d start +``` + +##### 3.2. To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: +``` +FROM ubi8/nodejs-22 + +# Add application sources to a directory that the assemble script expects them +# and set permissions so that the container runs without root access +USER 0 +ADD app-src /tmp/src +RUN chown -R 1001:0 /tmp/src +USER 1001 + +# Install the dependencies +RUN /usr/libexec/s2i/assemble + +# Set the default command for the resulting image +CMD /usr/libexec/s2i/run +``` + +#### 4. Build a new image from a Dockerfile prepared in the previous step + +``` +podman build -t node-app . +``` + +#### 5. Run the resulting image with the final application + +``` +podman run -d node-app +``` + +Environment variables for Source-to-Image +--------------------- + +Application developers can use the following environment variables to configure the runtime behavior of this image in OpenShift: + +**`NODE_ENV`** + NodeJS runtime mode (default: "production") + +**`DEV_MODE`** + When set to "true", `nodemon` will be used to automatically reload the server while you work (default: "false"). Setting `DEV_MODE` to "true" will change the `NODE_ENV` default to "development" (if not explicitly set). + +**`NPM_BUILD`** + Select an alternate / custom build command, defined in your `package.json` file's [`scripts`](https://docs.npmjs.com/misc/scripts) section (default: npm run "build"). These user-defined run-scripts are unavailable while `DEV_MODE` is in use. + +**`NODE_CMD`** + When specified (e.g.Specify `NODE_CMD="node server.js"`) the value of `NODE_CMD` is used to start the application instead of `npm start`. + +**`INIT_WRAPPER`** + When set to "true", the application is started via the `init-wrapper` script instead of using `npm start`, by looking for the presence of the files `server.js`, `index.js` or `main.js` in the order in which they are listed. In case of `NODE_CMD` environemnt variale is specified, then `init-wrapper` script will use the value of `NODE_CMD` to start your application. + +**`NPM_RUN`** + Select an alternate / custom runtime mode, defined in your `package.json` file's [`scripts`](https://docs.npmjs.com/misc/scripts) section (default: npm run "start"). These user-defined run-scripts are unavailable while `DEV_MODE` is in use. + +**`HTTP_PROXY`** + Use an npm proxy during assembly + +**`HTTPS_PROXY`** + Use an npm proxy during assembly + +**`NPM_MIRROR`** + Use a custom NPM registry mirror to download packages during the build process + +One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file. + +Example: DATABASE_USER=sampleUser + +#### NOTE: Define your own "`DEV_MODE`": + +The following `package.json` example includes a `scripts.dev` entry. You can define your own custom [`NPM_RUN`](https://docs.npmjs.com/cli/run-script) scripts in your application's `package.json` file. + +#### Note: Setting logging output verbosity +To alter the level of logs output during an `npm install` the npm_config_loglevel environment variable can be set. See [npm-config](https://docs.npmjs.com/misc/config). + +Development Mode +---------------- +This image supports development mode. This mode can be switched on and off with the environment variable `DEV_MODE`. `DEV_MODE` can either be set to `true` or `false`. +Development mode supports two features: +* Hot Deploy +* Debugging + +The debug port can be specified with the environment variable `DEBUG_PORT`. `DEBUG_PORT` is only valid if `DEV_MODE=true`. + +A simple example command for running the container in development mode is: +``` +podman run --env DEV_MODE=true my-image-id +``` + +To run the container in development mode with a debug port of 5454, run: +``` +$ podman run --env DEV_MODE=true DEBUG_PORT=5454 my-image-id +``` + +To run the container in production mode, run: +``` +$ podman run --env DEV_MODE=false my-image-id +``` + +By default, `DEV_MODE` is set to `false`, and `DEBUG_PORT` is set to `5858`, however the `DEBUG_PORT` is only relevant if `DEV_MODE=true`. + +Hot deploy +---------- + +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. + +### Using Podman's exec + +To change your source code in a running container, use Podman's [exec](https://github.com/containers/libpod) command: +``` +$ podman exec -it /bin/bash +``` + +After you [Podman exec](https://github.com/containers/libpod) into the running container, your current directory is set to `/opt/app-root/src`, where the source code for your application is located. + +### Using OpenShift's rsync + +If you have deployed the container to OpenShift, you can use [oc rsync](https://docs.openshift.org/latest/dev_guide/copy_files_to_container.html) to copy local files to a remote container running in an OpenShift pod. + +#### Warning: + +The default behaviour of the s2i-nodejs container image is to run the Node.js application using the command `npm start`. This runs the _start_ script in the _package.json_ file. In developer mode, the application is run using the command `nodemon`. The default behaviour of nodemon is to look for the _main_ attribute in the _package.json_ file, and execute that script. If the _main_ attribute doesn't appear in the _package.json_ file, it executes the _start_ script. So, in order to achieve some sort of uniform functionality between production and development modes, the user should remove the _main_ attribute. + +Below is an example _package.json_ file with the _main_ attribute and _start_ script marked appropriately: + +```json +{ + "name": "node-echo", + "version": "0.0.1", + "description": "node-echo", + "main": "example.js", <--- main attribute + "dependencies": { + }, + "devDependencies": { + "nodemon": "*" + }, + "engine": { + "node": "*", + "npm": "*" + }, + "scripts": { + "dev": "nodemon --ignore node_modules/ server.js", + "start": "node server.js" <-- start script + }, + "keywords": [ + "Echo" + ], + "license": "", +} +``` + +#### Note: +`oc rsync` is only available in versions 3.1+ of OpenShift. + +## init-wrapper + +init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used to handle: + +- Proper signal handling and propagation, as Node.js was not designed to run as PID 1. +- Reaping zombie child processes +Avoiding use of npm, there is more information on why you want to avoid that in the [Node.js reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application). When the INIT_WRAPPER is set to true the application is started via the init script instead of using npm start. + +A detailed explanation on how the init-wrapper script works is avalable in +[this url](http://veithen.io/2014/11/16/sigterm-propagation.html). + +Example of using init-wrapper: + +**During image build** +``` +s2i -e INIT_WRAPPER=true build . buildImage node-app +docker run node-app +``` +**During container start** +``` +s2i build . buildImage node-app +docker run -e INIT_WRAPPER=true node-app +``` + +`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`. + +``` +docker run -e INIT_WRAPPER=false node-app +``` +`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap. + +For example: + +**during container build** +``` +s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app +``` +**during container start** +``` +docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app +``` + +See also +-------- +Dockerfile and other sources are available on https://github.com/sclorg/s2i-nodejs-container. +In that repository you also can find another versions of Node.js environment Dockerfiles. +Dockerfile for CentOS Stream 9 is called `Dockerfile.c9s`, +Dockerfile for CentOS Stream 10 is called `Dockerfile.c10s`, +for RHEL8 it's `Dockerfile.rhel8`, for RHEL9 it's `Dockerfile.rhel9`, +for RHEL10 it's `Dockerfile.rhel10` and the Fedora Dockerfile is called Dockerfile.fedora. diff --git a/22/root/opt/app-root/etc/generate_container_user b/22/root/opt/app-root/etc/generate_container_user new file mode 100644 index 00000000..b28a7a3d --- /dev/null +++ b/22/root/opt/app-root/etc/generate_container_user @@ -0,0 +1,17 @@ +# Set current user in nss_wrapper +USER_ID=$(id -u) +GROUP_ID=$(id -g) + +if [ x"$USER_ID" != x"0" -a x"$USER_ID" != x"1001" ]; then + + NSS_WRAPPER_PASSWD=/opt/app-root/etc/passwd + NSS_WRAPPER_GROUP=/etc/group + + cat /etc/passwd | sed -e 's/^default:/builder:/' > $NSS_WRAPPER_PASSWD + + echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD + + export NSS_WRAPPER_PASSWD + export NSS_WRAPPER_GROUP + export LD_PRELOAD=libnss_wrapper.so +fi diff --git a/22/root/opt/app-root/etc/npm_global_module_list b/22/root/opt/app-root/etc/npm_global_module_list new file mode 100644 index 00000000..005e1501 --- /dev/null +++ b/22/root/opt/app-root/etc/npm_global_module_list @@ -0,0 +1,5 @@ +async +mime +mkdirp +qs +minimatch diff --git a/22/root/opt/app-root/etc/scl_enable b/22/root/opt/app-root/etc/scl_enable new file mode 100644 index 00000000..4bfebea0 --- /dev/null +++ b/22/root/opt/app-root/etc/scl_enable @@ -0,0 +1,3 @@ +# This will make scl collection binaries work out of box. +unset BASH_ENV PROMPT_COMMAND ENV +source scl_source enable rh-nodejs${NODEJS_VERSION} diff --git a/22/s2i/bin/assemble b/22/s2i/bin/assemble new file mode 100755 index 00000000..f644a811 --- /dev/null +++ b/22/s2i/bin/assemble @@ -0,0 +1,116 @@ +#!/bin/bash + +# Prevent running assemble in builders different than official STI image. +# The official nodejs:8-onbuild already run npm install and use different +# application folder. +[ -d "/usr/src/app" ] && exit 0 + +set -e + +# FIXME: Linking of global modules is disabled for now as it causes npm failures +# under RHEL7 +# Global modules good to have +# npmgl=$(grep "^\s*[^#\s]" ../etc/npm_global_module_list | sort -u) +# Available global modules; only match top-level npm packages +#global_modules=$(npm ls -g 2> /dev/null | perl -ne 'print "$1\n" if /^\S+\s(\S+)\@[\d\.-]+/' | sort -u) +# List all modules in common +#module_list=$(/usr/bin/comm -12 <(echo "${global_modules}") | tr '\n' ' ') +# Link the modules +#npm link $module_list + +safeLogging () { + if [[ $1 =~ http[s]?://.*@.*$ ]]; then + echo $1 | sed 's/^.*@/redacted@/' + else + echo $1 + fi +} + +shopt -s dotglob +if [ -d /tmp/artifacts ] && [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then + echo "---> Restoring previous build artifacts ..." + mv -T --verbose /tmp/artifacts/node_modules "${HOME}/node_modules" +fi + +echo "---> Installing application source ..." +mv /tmp/src/* ./ + +# Fix source directory permissions +fix-permissions ./ + +if [ ! -z $HTTP_PROXY ]; then + echo "---> Setting npm http proxy to" $(safeLogging $HTTP_PROXY) + npm config set proxy $HTTP_PROXY +fi + +if [ ! -z $http_proxy ]; then + echo "---> Setting npm http proxy to" $(safeLogging $http_proxy) + npm config set proxy $http_proxy +fi + +if [ ! -z $HTTPS_PROXY ]; then + echo "---> Setting npm https proxy to" $(safeLogging $HTTPS_PROXY) + npm config set https-proxy $HTTPS_PROXY +fi + +if [ ! -z $https_proxy ]; then + echo "---> Setting npm https proxy to" $(safeLogging $https_proxy) + npm config set https-proxy $https_proxy +fi + +# Change the npm registry mirror if provided +if [ -n "$NPM_MIRROR" ]; then + npm config set registry $NPM_MIRROR +fi + +# Set the DEV_MODE to false by default. +if [ -z "$DEV_MODE" ]; then + export DEV_MODE=false +fi + +# If NODE_ENV is not set by the user, then NODE_ENV is determined by whether +# the container is run in development mode. +if [ -z "$NODE_ENV" ]; then + if [ "$DEV_MODE" == true ]; then + export NODE_ENV=development + else + export NODE_ENV=production + fi +fi + +if [ "$NODE_ENV" != "production" ]; then + + echo "---> Building your Node application from source" + npm install + +else + + echo "---> Installing all dependencies" + NODE_ENV=development npm install + + #do not fail when there is no build script + echo "---> Building in production mode" + npm run ${NPM_BUILD:-build} --if-present + + echo "---> Pruning the development dependencies" + npm prune + + NPM_TMP=$(npm config get tmp) + if ! mountpoint $NPM_TMP; then + echo "---> Cleaning the $NPM_TMP/npm-*" + rm -rf $NPM_TMP/npm-* + fi + + # Clear the npm's cache and tmp directories only if they are not a docker volumes + NPM_CACHE=$(npm config get cache) + if ! mountpoint $NPM_CACHE; then + echo "---> Cleaning the npm cache $NPM_CACHE" + #As of npm@5 even the 'npm cache clean --force' does not fully remove the cache directory + # instead of $NPM_CACHE* use $NPM_CACHE/*. + # We do not want to delete .npmrc file. + rm -rf "${NPM_CACHE:?}/" + fi +fi + +# Fix source directory permissions +fix-permissions ./ diff --git a/22/s2i/bin/init-wrapper b/22/s2i/bin/init-wrapper new file mode 100644 index 00000000..24e0d078 --- /dev/null +++ b/22/s2i/bin/init-wrapper @@ -0,0 +1,18 @@ +#!/bin/bash + +# Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html +# Set a trap to kill the main app process when this +# init script receives SIGTERM or SIGINT +trap 'kill -s TERM $PID' TERM INT +# Execute the main application in the background +"$@" & +PID=$! +# wait command always terminates when trap is caught, even if the process hasn't finished yet +wait $PID +# Remove the trap and wait till the app process finishes completely +trap - TERM INT +# We wait again, since the first wait terminates when trap is caught +wait $PID +# Exit with the exit code of the app process +STATUS=$? +exit $STATUS \ No newline at end of file diff --git a/22/s2i/bin/run b/22/s2i/bin/run new file mode 100755 index 00000000..9a207bce --- /dev/null +++ b/22/s2i/bin/run @@ -0,0 +1,83 @@ +#!/bin/bash + +# S2I run script for the 'nodejs' image. +# The run script executes the server that runs your application. +# +# For more information see the documentation: +# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md +# + +set -e + +if [ -e "/opt/app-root/etc/generate_container_user" ]; then + source /opt/app-root/etc/generate_container_user +fi + +# Runs the nodejs application server. If the container is run in development mode, +# hot deploy and debugging are enabled. +run_node() { + echo -e "Environment: \n\tDEV_MODE=${DEV_MODE}\n\tNODE_ENV=${NODE_ENV}\n\tDEBUG_PORT=${DEBUG_PORT}" + if [ "$DEV_MODE" == true ]; then + echo "Launching via nodemon..." + exec nodemon --inspect="$DEBUG_PORT" + elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then + echo "launching via init wrapper..." + exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD + elif [ -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == false ]; then + echo "Launching via ${NODE_CMD}" + exec $NODE_CMD + elif [ ! -n "$NODE_CMD" ] && [ "$INIT_WRAPPER" == true ]; then + + 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 ." + elif [ -f "server.js" ]; then + start_command="node server.js" + else + echo "Failed to find file for starting the Node.js application" + exit 1 + fi + echo "launching via init wrapper..." + exec ${STI_SCRIPTS_PATH}/init-wrapper $start_command + else + echo "Launching via npm..." + exec npm run -d $NPM_RUN + fi +} + +#Set the debug port to 5858 by default. +if [ -z "$DEBUG_PORT" ]; then + export DEBUG_PORT=5858 +fi + +# Set the environment to development by default. +if [ -z "$DEV_MODE" ]; then + export DEV_MODE=false +fi + +# If NODE_ENV is not set by the user, then NODE_ENV is determined by whether +# the container is run in development mode. +if [ -z "$NODE_ENV" ]; then + if [ "$DEV_MODE" == true ]; then + export NODE_ENV=development + else + export NODE_ENV=production + fi +fi + +# If the official dockerhub node image is used, skip the SCL setup below +# and just run the nodejs server +if [ -d "/usr/src/app" ]; then + run_node +fi + +# Allow users to inspect/debug the builder image itself, by using: +# $ docker run -i -t openshift/centos-nodejs-builder --debug +# +[ "$1" == "--debug" ] && exec /bin/bash + +run_node diff --git a/22/s2i/bin/save-artifacts b/22/s2i/bin/save-artifacts new file mode 100755 index 00000000..16be05e7 --- /dev/null +++ b/22/s2i/bin/save-artifacts @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ -d "${HOME}/node_modules" ] && [ "$(ls "${HOME}/node_modules" 2>/dev/null)" ]; then + tar -C "${HOME}" -cf - node_modules +fi diff --git a/22/s2i/bin/usage b/22/s2i/bin/usage new file mode 100755 index 00000000..b8c1dca8 --- /dev/null +++ b/22/s2i/bin/usage @@ -0,0 +1,15 @@ +#!/bin/sh + +DISTRO=`cat /etc/*-release | grep ^ID= | grep -Po '".*?"' | tr -d '"'` + +cat < nodejs-sample-app + +You can then run the resulting image via: +podman run -p 8080:8080 nodejs-sample-app +EOF diff --git a/22/test b/22/test new file mode 120000 index 00000000..ae78e219 --- /dev/null +++ b/22/test @@ -0,0 +1 @@ +../test/ \ No newline at end of file From 72705dae4684f59a72199b554225cd0857849084 Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Wed, 16 Jul 2025 09:36:23 +0200 Subject: [PATCH 3/6] Add Node.js 24 (3/3 - s/22/24/) --- 24-minimal/Dockerfile.c10s | 4 ++-- 24-minimal/Dockerfile.c9s | 2 +- 24-minimal/Dockerfile.fedora | 2 +- 24-minimal/Dockerfile.rhel10 | 2 +- 24-minimal/Dockerfile.rhel8 | 2 +- 24-minimal/Dockerfile.rhel9 | 2 +- 24-minimal/README.md | 36 ++++++++++++++++++------------------ 24/Dockerfile.c10s | 6 +++--- 24/Dockerfile.c9s | 6 +++--- 24/Dockerfile.fedora | 2 +- 24/Dockerfile.rhel10 | 6 +++--- 24/Dockerfile.rhel8 | 2 +- 24/Dockerfile.rhel9 | 2 +- 24/README.md | 20 ++++++++++---------- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/24-minimal/Dockerfile.c10s b/24-minimal/Dockerfile.c10s index b558a0ba..ac0e602f 100644 --- a/24-minimal/Dockerfile.c10s +++ b/24-minimal/Dockerfile.c10s @@ -17,7 +17,7 @@ ENV APP_ROOT=/opt/app-root \ HOME=/opt/app-root/src \ NPM_RUN=start \ PLATFORM="el10" \ - NODEJS_VERSION=22 \ + NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs @@ -51,7 +51,7 @@ LABEL summary="$SUMMARY" \ # nodejs-full-i18n is included for error strings RUN INSTALL_PKGS="nodejs$NODEJS_VERSION nodejs-nodemon nodejs$NODEJS_VERSION-full-i18n npm findutils tar which" && \ dnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \ - node-22 -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ + node-24 -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \ dnf clean all && \ rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* diff --git a/24-minimal/Dockerfile.c9s b/24-minimal/Dockerfile.c9s index 92275fbe..37aa5e8e 100644 --- a/24-minimal/Dockerfile.c9s +++ b/24-minimal/Dockerfile.c9s @@ -17,7 +17,7 @@ ENV APP_ROOT=/opt/app-root \ HOME=/opt/app-root/src \ NPM_RUN=start \ PLATFORM="el9" \ - NODEJS_VERSION=22 \ + NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs diff --git a/24-minimal/Dockerfile.fedora b/24-minimal/Dockerfile.fedora index 149c4955..f106a04d 100644 --- a/24-minimal/Dockerfile.fedora +++ b/24-minimal/Dockerfile.fedora @@ -17,7 +17,7 @@ ENV APP_ROOT=/opt/app-root \ HOME=/opt/app-root/src \ NPM_RUN=start \ PLATFORM="fedora" \ - NODEJS_VERSION=22 \ + NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs diff --git a/24-minimal/Dockerfile.rhel10 b/24-minimal/Dockerfile.rhel10 index 1ded9dd1..a23134fe 100644 --- a/24-minimal/Dockerfile.rhel10 +++ b/24-minimal/Dockerfile.rhel10 @@ -17,7 +17,7 @@ ENV APP_ROOT=/opt/app-root \ HOME=/opt/app-root/src \ NPM_RUN=start \ PLATFORM="el10" \ - NODEJS_VERSION=22 \ + NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs diff --git a/24-minimal/Dockerfile.rhel8 b/24-minimal/Dockerfile.rhel8 index 5f6d0bc3..56635add 100644 --- a/24-minimal/Dockerfile.rhel8 +++ b/24-minimal/Dockerfile.rhel8 @@ -17,7 +17,7 @@ ENV APP_ROOT=/opt/app-root \ HOME=/opt/app-root/src \ NPM_RUN=start \ PLATFORM="el8" \ - NODEJS_VERSION=22 \ + NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs diff --git a/24-minimal/Dockerfile.rhel9 b/24-minimal/Dockerfile.rhel9 index 9a18e3ec..27247979 100644 --- a/24-minimal/Dockerfile.rhel9 +++ b/24-minimal/Dockerfile.rhel9 @@ -17,7 +17,7 @@ ENV APP_ROOT=/opt/app-root \ HOME=/opt/app-root/src \ NPM_RUN=start \ PLATFORM="el9" \ - NODEJS_VERSION=22 \ + NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs diff --git a/24-minimal/README.md b/24-minimal/README.md index e9e5170a..3c2bb864 100644 --- a/24-minimal/README.md +++ b/24-minimal/README.md @@ -1,9 +1,9 @@ -NodeJS 22 minimal container image +NodeJS 24 minimal container image ========================= -This container image includes Node.JS 22 on top of a minimal base image for your Node.JS 22 applications. This image is designed to be used -with the full-sized s2i-enabled Node.JS 22 image to build the application. The image can be used as a standalone s2i-enabled image as well, -but compared to the full-sized Node.JS 22 image it will be missing many build-time dependencies. +This container image includes Node.JS 24 on top of a minimal base image for your Node.JS 24 applications. This image is designed to be used +with the full-sized s2i-enabled Node.JS 24 image to build the application. The image can be used as a standalone s2i-enabled image as well, +but compared to the full-sized Node.JS 24 image it will be missing many build-time dependencies. Users can choose between RHEL, CentOS and Fedora based images. The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), the CentOS Stream images are available in the [Quay.io](https://quay.io/organization/sclorg), @@ -15,8 +15,8 @@ Note: while the examples in this README are calling `podman`, you can replace an Description ----------- -Node.js 22 available as a minimal container is a base platform for -running various Node.js 22 applications and frameworks. +Node.js 24 available as a minimal container is a base platform for +running various Node.js 24 applications and frameworks. Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications @@ -24,8 +24,8 @@ that run across distributed devices. Usage in OpenShift ------------------ -In this example, we will assume that you are using the `ubi8/nodejs-22` image, available via `nodejs:22-ubi8` imagestream tag in Openshift -to build the application, as well as the `ubi8/nodejs-22-minimal` image, available via `nodejs:22-ubi8-minimal` image stream +In this example, we will assume that you are using the `ubi8/nodejs-24` image, available via `nodejs:24-ubi8` imagestream tag in Openshift +to build the application, as well as the `ubi8/nodejs-24-minimal` image, available via `nodejs:24-ubi8-minimal` image stream for running the resulting application. With these two images we can create a [chained build](https://docs.openshift.com/container-platform/4.7/cicd/builds/advanced-build-operations.html#builds-chaining-builds_advanced-build-operations) in Openshift using two BuildConfigs: @@ -50,7 +50,7 @@ spec: sourceStrategy: from: kind: ImageStreamTag - name: nodejs:22-ubi8 + name: nodejs:24-ubi8 namespace: openshift ``` @@ -70,7 +70,7 @@ spec: name: nodejs-runtime-image:latest source: dockerfile: |- - FROM nodejs:22-ubi8-minimal + FROM nodejs:24-ubi8-minimal COPY src $HOME CMD /usr/libexec/s2i/run images: @@ -84,7 +84,7 @@ spec: dockerStrategy: from: kind: ImageStreamTag - name: nodejs:22-ubi8-minimal + name: nodejs:24-ubi8-minimal triggers: - imageChange: {} type: ImageChange @@ -114,11 +114,11 @@ To use the Node.js image in a Dockerfile, follow these steps: #### 1. Pull the base builder and minimal runtime images ``` -podman pull ubi8/nodejs-22 -podman pull ubi8/nodejs-22-minimal +podman pull ubi8/nodejs-24 +podman pull ubi8/nodejs-24-minimal ``` -The UBI images `ubi8/nodejs-22` and `ubi8/nodejs-22-minimal` that are used in this example are both usable and freely redistributable under the terms of the UBI End User License Agreement (EULA). See more about UBI at [UBI FAQ](https://developers.redhat.com/articles/ubi-faq). +The UBI images `ubi8/nodejs-24` and `ubi8/nodejs-24-minimal` that are used in this example are both usable and freely redistributable under the terms of the UBI End User License Agreement (EULA). See more about UBI at [UBI FAQ](https://developers.redhat.com/articles/ubi-faq). #### 2. Pull an application code @@ -141,7 +141,7 @@ For all these three parts, users can either setup all manually and use commands ##### 3.1. To use your own setup, create a Dockerfile with this content: ``` # First stage builds the application -FROM ubi8/nodejs-22 as builder +FROM ubi8/nodejs-24 as builder # Add application sources ADD app-src $HOME @@ -150,7 +150,7 @@ ADD app-src $HOME RUN npm install # Second stage copies the application to the minimal image -FROM ubi8/nodejs-22-minimal +FROM ubi8/nodejs-24-minimal # Copy the application source and build artifacts from the builder image to this one COPY --from=builder $HOME $HOME @@ -162,7 +162,7 @@ CMD npm run -d start ##### 3.2. To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: ``` # First stage builds the application -FROM ubi8/nodejs-22 as builder +FROM ubi8/nodejs-24 as builder # Add application sources to a directory that the assemble script expects them # and set permissions so that the container runs without root access @@ -175,7 +175,7 @@ USER 1001 RUN /usr/libexec/s2i/assemble # Second stage copies the application to the minimal image -FROM ubi8/nodejs-22-minimal +FROM ubi8/nodejs-24-minimal # Copy the application source and build artifacts from the builder image to this one COPY --from=builder $HOME $HOME diff --git a/24/Dockerfile.c10s b/24/Dockerfile.c10s index 0cc8da62..53cb44e1 100644 --- a/24/Dockerfile.c10s +++ b/24/Dockerfile.c10s @@ -16,12 +16,12 @@ EXPOSE 8080 # Expose ports: # * 8080 - Unprivileged port used by nodejs application -ENV NODEJS_VERSION=22 \ +ENV NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs \ NPM_CONFIG_PREFIX=$HOME/.npm-global \ PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ - CNB_STACK_ID=com.redhat.stacks.c10s-nodejs-22 \ + CNB_STACK_ID=com.redhat.stacks.c10s-nodejs-24 \ CNB_USER_ID=1001 \ CNB_GROUP_ID=0 @@ -41,7 +41,7 @@ LABEL summary="$SUMMARY" \ io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ io.s2i.scripts-url="image:///usr/libexec/s2i" \ - io.buildpacks.stack.id="com.redhat.stacks.c10s-nodejs-22" \ + io.buildpacks.stack.id="com.redhat.stacks.c10s-nodejs-24" \ com.redhat.dev-mode="DEV_MODE:false" \ com.redhat.deployments-dir="${APP_ROOT}/src" \ com.redhat.dev-mode.port="DEBUG_PORT:5858" \ diff --git a/24/Dockerfile.c9s b/24/Dockerfile.c9s index 0b47eefa..f297ee4f 100644 --- a/24/Dockerfile.c9s +++ b/24/Dockerfile.c9s @@ -16,12 +16,12 @@ EXPOSE 8080 # Expose ports: # * 8080 - Unprivileged port used by nodejs application -ENV NODEJS_VERSION=22 \ +ENV NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs \ NPM_CONFIG_PREFIX=$HOME/.npm-global \ PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ - CNB_STACK_ID=com.redhat.stacks.c9s-nodejs-22 \ + CNB_STACK_ID=com.redhat.stacks.c9s-nodejs-24 \ CNB_USER_ID=1001 \ CNB_GROUP_ID=0 @@ -41,7 +41,7 @@ LABEL summary="$SUMMARY" \ io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ io.s2i.scripts-url="image:///usr/libexec/s2i" \ - io.buildpacks.stack.id="com.redhat.stacks.c9s-nodejs-22" \ + io.buildpacks.stack.id="com.redhat.stacks.c9s-nodejs-24" \ com.redhat.dev-mode="DEV_MODE:false" \ com.redhat.deployments-dir="${APP_ROOT}/src" \ com.redhat.dev-mode.port="DEBUG_PORT:5858" \ diff --git a/24/Dockerfile.fedora b/24/Dockerfile.fedora index 49a16b05..a1f23043 100644 --- a/24/Dockerfile.fedora +++ b/24/Dockerfile.fedora @@ -16,7 +16,7 @@ EXPOSE 8080 # Expose ports: # * 8080 - Unprivileged port used by nodejs application -ENV NODEJS_VERSION=22 \ +ENV NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs \ NPM_CONFIG_PREFIX=$HOME/.npm-global \ diff --git a/24/Dockerfile.rhel10 b/24/Dockerfile.rhel10 index 9d90d4e6..77f775f4 100644 --- a/24/Dockerfile.rhel10 +++ b/24/Dockerfile.rhel10 @@ -16,12 +16,12 @@ EXPOSE 8080 # Expose ports: # * 8080 - Unprivileged port used by nodejs application -ENV NODEJS_VERSION=22 \ +ENV NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs \ NPM_CONFIG_PREFIX=$HOME/.npm-global \ PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ - CNB_STACK_ID=com.redhat.stacks.c10s-nodejs-22 \ + CNB_STACK_ID=com.redhat.stacks.c10s-nodejs-24 \ CNB_USER_ID=1001 \ CNB_GROUP_ID=0 @@ -41,7 +41,7 @@ LABEL summary="$SUMMARY" \ io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \ io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \ io.s2i.scripts-url="image:///usr/libexec/s2i" \ - io.buildpacks.stack.id="com.redhat.stacks.c10s-nodejs-22" \ + io.buildpacks.stack.id="com.redhat.stacks.c10s-nodejs-24" \ com.redhat.dev-mode="DEV_MODE:false" \ com.redhat.deployments-dir="${APP_ROOT}/src" \ com.redhat.dev-mode.port="DEBUG_PORT:5858" \ diff --git a/24/Dockerfile.rhel8 b/24/Dockerfile.rhel8 index 1156ca11..aa3026c5 100644 --- a/24/Dockerfile.rhel8 +++ b/24/Dockerfile.rhel8 @@ -16,7 +16,7 @@ EXPOSE 8080 # Expose ports: # * 8080 - Unprivileged port used by nodejs application -ENV NODEJS_VERSION=22 \ +ENV NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs \ NPM_CONFIG_PREFIX=$HOME/.npm-global \ diff --git a/24/Dockerfile.rhel9 b/24/Dockerfile.rhel9 index c6c4a1e6..bbdb9f51 100644 --- a/24/Dockerfile.rhel9 +++ b/24/Dockerfile.rhel9 @@ -16,7 +16,7 @@ EXPOSE 8080 # Expose ports: # * 8080 - Unprivileged port used by nodejs application -ENV NODEJS_VERSION=22 \ +ENV NODEJS_VERSION=24 \ NPM_RUN=start \ NAME=nodejs \ NPM_CONFIG_PREFIX=$HOME/.npm-global \ diff --git a/24/README.md b/24/README.md index 380cb26d..7d28862f 100644 --- a/24/README.md +++ b/24/README.md @@ -1,7 +1,7 @@ -NodeJS 22 container image +NodeJS 24 container image ========================= -This container image includes Node.JS 22 as a [S2I](https://github.com/openshift/source-to-image) base image for your Node.JS 22 applications. +This container image includes Node.JS 24 as a [S2I](https://github.com/openshift/source-to-image) base image for your Node.JS 24 applications. Users can choose between RHEL, CentOS and Fedora based images. The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), and the Fedora images are available in [Quay.io](https://quay.io/organization/fedora). @@ -13,8 +13,8 @@ Note: while the examples in this README are calling `podman`, you can replace an Description ----------- -Node.js 22 available as container is a base platform for -building and running various Node.js 22 applications and frameworks. +Node.js 24 available as container is a base platform for +building and running various Node.js 24 applications and frameworks. Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications @@ -22,12 +22,12 @@ that run across distributed devices. Usage in OpenShift ------------------ -In this example, we will assume that you are using the `ubi8/nodejs-22` image, available via `nodejs:22` imagestream tag in Openshift. +In this example, we will assume that you are using the `ubi8/nodejs-24` image, available via `nodejs:24` imagestream tag in Openshift. To build a simple [nodejs-sample-app](https://github.com/sclorg/nodejs-ex.git) application in Openshift: ``` -oc new-app nodejs:22~https://github.com/sclorg/nodejs-ex.git +oc new-app nodejs:24~https://github.com/sclorg/nodejs-ex.git ``` To access the application: @@ -61,10 +61,10 @@ To use the Node.js image in a Dockerfile, follow these steps: #### 1. Pull a base builder image to build on ``` -podman pull ubi8/nodejs-22 +podman pull ubi8/nodejs-24 ``` -An UBI image `ubi8/nodejs-22` is used in this example. This image is usable and freely redistributable under the terms of the UBI End User License Agreement (EULA). See more about UBI at [UBI FAQ](https://developers.redhat.com/articles/ubi-faq). +An UBI image `ubi8/nodejs-24` is used in this example. This image is usable and freely redistributable under the terms of the UBI End User License Agreement (EULA). See more about UBI at [UBI FAQ](https://developers.redhat.com/articles/ubi-faq). #### 2. Pull an application code @@ -86,7 +86,7 @@ For all these three parts, users can either setup all manually and use commands ##### 3.1. To use your own setup, create a Dockerfile with this content: ``` -FROM ubi8/nodejs-22 +FROM ubi8/nodejs-24 # Add application sources ADD app-src . @@ -100,7 +100,7 @@ CMD npm run -d start ##### 3.2. To use the Source-to-Image scripts and build an image using a Dockerfile, create a Dockerfile with this content: ``` -FROM ubi8/nodejs-22 +FROM ubi8/nodejs-24 # Add application sources to a directory that the assemble script expects them # and set permissions so that the container runs without root access From 0ed03dc2f058036c9bbd2b033c67f326ba51907a Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Mon, 21 Jul 2025 12:40:32 +0200 Subject: [PATCH 4/6] Add exclude files for not-yet-available OSs --- 24-minimal/.exclude-c10s | 0 24-minimal/.exclude-rhel10 | 0 24-minimal/.exclude-rhel8 | 0 24-minimal/.exclude-rhel9 | 0 24/.exclude-c10s | 0 24/.exclude-rhel10 | 0 24/.exclude-rhel8 | 0 24/.exclude-rhel9 | 0 8 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 24-minimal/.exclude-c10s create mode 100644 24-minimal/.exclude-rhel10 create mode 100644 24-minimal/.exclude-rhel8 create mode 100644 24-minimal/.exclude-rhel9 create mode 100644 24/.exclude-c10s create mode 100644 24/.exclude-rhel10 create mode 100644 24/.exclude-rhel8 create mode 100644 24/.exclude-rhel9 diff --git a/24-minimal/.exclude-c10s b/24-minimal/.exclude-c10s new file mode 100644 index 00000000..e69de29b diff --git a/24-minimal/.exclude-rhel10 b/24-minimal/.exclude-rhel10 new file mode 100644 index 00000000..e69de29b diff --git a/24-minimal/.exclude-rhel8 b/24-minimal/.exclude-rhel8 new file mode 100644 index 00000000..e69de29b diff --git a/24-minimal/.exclude-rhel9 b/24-minimal/.exclude-rhel9 new file mode 100644 index 00000000..e69de29b diff --git a/24/.exclude-c10s b/24/.exclude-c10s new file mode 100644 index 00000000..e69de29b diff --git a/24/.exclude-rhel10 b/24/.exclude-rhel10 new file mode 100644 index 00000000..e69de29b diff --git a/24/.exclude-rhel8 b/24/.exclude-rhel8 new file mode 100644 index 00000000..e69de29b diff --git a/24/.exclude-rhel9 b/24/.exclude-rhel9 new file mode 100644 index 00000000..e69de29b From bfc4869975bffb0c54e1ac1b9fe0e9038c8b6bdf Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Mon, 21 Jul 2025 13:26:51 +0200 Subject: [PATCH 5/6] Add v24 into build-and-push.yml --- .github/workflows/build-and-push.yml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 906a46cf..af10aeeb 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -46,6 +46,22 @@ jobs: quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME" quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN" + - dockerfile: "24/Dockerfile.c10s" + docker_context: 24 + registry_namespace: "sclorg" + tag: "c10s" + image_name: "nodejs-24-c10s" + quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME" + quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN" + + - dockerfile: "24-minimal/Dockerfile.c10s" + docker_context: 24-minimal + registry_namespace: "sclorg" + tag: "c10s" + image_name: "nodejs-24-minimal-c10s" + quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME" + quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN" + - dockerfile: "18/Dockerfile.fedora" docker_context: 18 registry_namespace: "fedora" @@ -94,6 +110,22 @@ jobs: quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" image_name: "nodejs-22-minimal" + - dockerfile: "24/Dockerfile.fedora" + docker_context: 24 + registry_namespace: "fedora" + tag: "fedora" + quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME" + quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" + image_name: "nodejs-24" + + - dockerfile: "24-minimal/Dockerfile.fedora" + docker_context: 24-minimal + registry_namespace: "fedora" + tag: "fedora" + quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME" + quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" + image_name: "nodejs-24-minimal" + steps: - name: Build and push to quay.io registry uses: sclorg/build-and-push-action@v4 From 04983c5b1d90537c9fe7e23cad57bd83e2f044f1 Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Tue, 29 Jul 2025 10:30:49 +0200 Subject: [PATCH 6/6] Move to F42 to get the v24 --- 24-minimal/Dockerfile.fedora | 2 +- 24/Dockerfile.fedora | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/24-minimal/Dockerfile.fedora b/24-minimal/Dockerfile.fedora index f106a04d..0bafeebd 100644 --- a/24-minimal/Dockerfile.fedora +++ b/24-minimal/Dockerfile.fedora @@ -1,4 +1,4 @@ -FROM quay.io/fedora/fedora-minimal:40 +FROM quay.io/fedora/fedora-minimal:42 EXPOSE 8080 diff --git a/24/Dockerfile.fedora b/24/Dockerfile.fedora index a1f23043..1880a2ed 100644 --- a/24/Dockerfile.fedora +++ b/24/Dockerfile.fedora @@ -1,4 +1,4 @@ -FROM quay.io/fedora/s2i-core:40 +FROM quay.io/fedora/s2i-core:42 # This image provides a Node.JS environment you can use to run your Node.JS # applications.