Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building and testing NodeJS on RHEL10 host #471

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions 22-minimal/Dockerfile.rhel10
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>" \
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
3 changes: 2 additions & 1 deletion 22-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
80 changes: 80 additions & 0 deletions 22/Dockerfile.rhel10
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>" \
help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \
usage="s2i build <SOURCE-REPOSITORY> ubi10/$NAME-$NODEJS_VERSION <APP-NAME>"

# 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
3 changes: 2 additions & 1 deletion 22/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions test/run-minimal
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 2 additions & 2 deletions test/test-lib-nodejs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading