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/README.md b/22-minimal/README.md index ae1beedb..e9e5170a 100644 --- a/22-minimal/README.md +++ b/22-minimal/README.md @@ -369,4 +369,5 @@ Dockerfile and other sources are available on https://github.com/sclorg/s2i-node 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` and the Fedora Dockerfile is called Dockerfile.fedora. +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/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/README.md b/22/README.md index 3d814e81..380cb26d 100644 --- a/22/README.md +++ b/22/README.md @@ -298,4 +298,5 @@ Dockerfile and other sources are available on https://github.com/sclorg/s2i-node 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` and the Fedora Dockerfile is called Dockerfile.fedora. +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/README.md b/README.md index 9c7c2a2f..649e29b5 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Node.JS versions currently provided are: RHEL versions currently supported are: * RHEL8 * RHEL9 +* RHEL10 CentOS Stream versions currently available are: * CentOS Stream 9 diff --git a/test/run-minimal b/test/run-minimal index f02bac0a..3d999502 100755 --- a/test/run-minimal +++ b/test/run-minimal @@ -90,16 +90,22 @@ prepare app check_prep_result $? app || exit echo "Testing the production image build" -FULL_IMAGE=${FULL_IMAGE:-${IMAGE_NAME//-minimal:1/}} +FULL_IMAGE=${FULL_IMAGE:-${IMAGE_NAME//-minimal:latest/}} # if FULL_IMAGE is not found, try to pull it, if that does not work, try to pull ubi9 one if [ -z "$(docker images -q "$FULL_IMAGE")" ] ; then echo "Image $FULL_IMAGE not found, trying to pull $FULL_IMAGE from registry" docker pull "$FULL_IMAGE" fi if [ -z "$(docker images -q "$FULL_IMAGE")" ] ; then - echo "Image $FULL_IMAGE still not found, trying to use ubi9/nodejs-${VERSION//-minimal/}:latest and pull it" - FULL_IMAGE="ubi9/nodejs-${VERSION//-minimal/}:latest" - docker pull "$FULL_IMAGE" + if [[ "$OS" == "rhel9" ]]; then + echo "Image $FULL_IMAGE still not found, trying to use ubi9/nodejs-${VERSION//-minimal/}:latest and pull it" + FULL_IMAGE="ubi9/nodejs-${VERSION//-minimal/}:latest" + docker pull "$FULL_IMAGE" + elif [[ "$OS" == "rhel10" ]]; then + echo "Image $FULL_IMAGE still not found, trying to use ubi10/nodejs-${VERSION//-minimal/}:latest and pull it" + FULL_IMAGE="ubi10/nodejs-${VERSION//-minimal/}:latest" + docker pull "$FULL_IMAGE" + fi fi if [ -z "$(docker images -q "$FULL_IMAGE")" ] ; then echo "Image $FULL_IMAGE could not be found nor pulled, giving up." diff --git a/test/test-lib-nodejs.sh b/test/test-lib-nodejs.sh index 8566b1a8..1487f825 100644 --- a/test/test-lib-nodejs.sh +++ b/test/test-lib-nodejs.sh @@ -458,8 +458,8 @@ function test_client_fastify() { VERSION=$(echo "${VERSION}" | cut -d "-" -f 1) fi if [[ "$VERSION" == "18" ]]; then - if [ "$OS" == "rhel8" ] || [ "$OS" == "rhel9" ]; then - echo "Fastify is not supported in $VERSION and rhel8 and rhel9" + if [ "$OS" == "rhel8" ] || [ "$OS" == "rhel9" ] || [ "$OS" == "rhel10" ]; then + echo "Fastify is not supported in $VERSION and rhel8, rhel9, and rhel10" return fi fi