Skip to content

Commit ba53dd5

Browse files
committed
Add Dockerfile.rhel10 to building and testing nodejs containers in RHEL10 host
Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent 21cb1d1 commit ba53dd5

File tree

3 files changed

+152
-2
lines changed

3 files changed

+152
-2
lines changed

22-minimal/Dockerfile.rhel10

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
FROM ubi10/ubi-minimal
2+
3+
EXPOSE 8080
4+
5+
# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts
6+
# available on the CLI without using npm's --global installation mode
7+
# This image will be initialized with "npm run $NPM_RUN"
8+
# See https://docs.npmjs.com/misc/scripts, and your repo's package.json
9+
# file for possible values of NPM_RUN
10+
# Description
11+
# Environment:
12+
# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start").
13+
# Expose ports:
14+
# * 8080 - Unprivileged port used by nodejs application
15+
ENV APP_ROOT=/opt/app-root \
16+
# The $HOME is not set by default, but some applications need this variable
17+
HOME=/opt/app-root/src \
18+
NPM_RUN=start \
19+
PLATFORM="el10" \
20+
NODEJS_VERSION=22 \
21+
NPM_RUN=start \
22+
NAME=nodejs
23+
24+
ENV SUMMARY="Minimal image for running Node.js $NODEJS_VERSION applications" \
25+
DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \
26+
running various Node.js $NODEJS_VERSION applications and frameworks. \
27+
Node.js is a platform built on Chrome's JavaScript runtime for easily building \
28+
fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \
29+
that makes it lightweight and efficient, perfect for data-intensive real-time applications \
30+
that run across distributed devices." \
31+
NPM_CONFIG_PREFIX=$HOME/.npm-global \
32+
PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH
33+
34+
LABEL summary="$SUMMARY" \
35+
description="$DESCRIPTION" \
36+
io.k8s.description="$DESCRIPTION" \
37+
io.k8s.display-name="Node.js $NODEJS_VERSION Micro" \
38+
io.openshift.expose-services="8080:http" \
39+
io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \
40+
io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \
41+
io.s2i.scripts-url="image:///usr/libexec/s2i" \
42+
com.redhat.dev-mode="DEV_MODE:false" \
43+
com.redhat.deployments-dir="${APP_ROOT}/src" \
44+
com.redhat.dev-mode.port="DEBUG_PORT:5858" \
45+
com.redhat.component="${NAME}-${NODEJS_VERSION}-minimal-container" \
46+
name="ubi9/$NAME-$NODEJS_VERSION-minimal" \
47+
version="1" \
48+
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
49+
maintainer="SoftwareCollections.org <[email protected]>" \
50+
help="For more information visit https://github.com/sclorg/s2i-nodejs-container"
51+
52+
# nodejs-full-i18n is included for error strings
53+
RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar which" && \
54+
microdnf -y module disable nodejs && \
55+
microdnf -y module enable nodejs:$NODEJS_VERSION && \
56+
microdnf -y --nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \
57+
node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \
58+
microdnf clean all && \
59+
rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.*
60+
61+
COPY ./s2i/bin/ /usr/libexec/s2i
62+
RUN chmod +x /usr/libexec/s2i/init-wrapper
63+
64+
# Copy extra files to the image.
65+
COPY ./root/ /
66+
67+
# Drop the root user and make the content of /opt/app-root owned by user 1001
68+
RUN mkdir -p "$HOME" && chown -R 1001:0 "$APP_ROOT" && chmod -R ug+rwx "$APP_ROOT"
69+
WORKDIR "$HOME"
70+
USER 1001

22/Dockerfile.rhel10

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
FROM ubi10/s2i-core:latest
2+
3+
# This image provides a Node.JS environment you can use to run your Node.JS
4+
# applications.
5+
6+
EXPOSE 8080
7+
8+
# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts
9+
# available on the CLI without using npm's --global installation mode
10+
# This image will be initialized with "npm run $NPM_RUN"
11+
# See https://docs.npmjs.com/misc/scripts, and your repo's package.json
12+
# file for possible values of NPM_RUN
13+
# Description
14+
# Environment:
15+
# * $NPM_RUN - Select an alternate / custom runtime mode, defined in your package.json files' scripts section (default: npm run "start").
16+
# Expose ports:
17+
# * 8080 - Unprivileged port used by nodejs application
18+
19+
ENV NODEJS_VERSION=22 \
20+
NPM_RUN=start \
21+
NAME=nodejs \
22+
NPM_CONFIG_PREFIX=$HOME/.npm-global \
23+
PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \
24+
CNB_STACK_ID=com.redhat.stacks.c10s-nodejs-22 \
25+
CNB_USER_ID=1001 \
26+
CNB_GROUP_ID=0
27+
28+
ENV SUMMARY="Platform for building and running Node.js $NODEJS_VERSION applications" \
29+
DESCRIPTION="Node.js $NODEJS_VERSION available as container is a base platform for \
30+
building and running various Node.js $NODEJS_VERSION applications and frameworks. \
31+
Node.js is a platform built on Chrome's JavaScript runtime for easily building \
32+
fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model \
33+
that makes it lightweight and efficient, perfect for data-intensive real-time applications \
34+
that run across distributed devices."
35+
36+
LABEL summary="$SUMMARY" \
37+
description="$DESCRIPTION" \
38+
io.k8s.description="$DESCRIPTION" \
39+
io.k8s.display-name="Node.js $NODEJS_VERSION" \
40+
io.openshift.expose-services="8080:http" \
41+
io.openshift.tags="builder,$NAME,${NAME}${NODEJS_VERSION}" \
42+
io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \
43+
io.s2i.scripts-url="image:///usr/libexec/s2i" \
44+
io.buildpacks.stack.id="com.redhat.stacks.c10s-nodejs-22" \
45+
com.redhat.dev-mode="DEV_MODE:false" \
46+
com.redhat.deployments-dir="${APP_ROOT}/src" \
47+
com.redhat.dev-mode.port="DEBUG_PORT:5858" \
48+
com.redhat.component="${NAME}-${NODEJS_VERSION}-container" \
49+
name="ubi10/$NAME-$NODEJS_VERSION" \
50+
version="1" \
51+
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
52+
maintainer="SoftwareCollections.org <[email protected]>" \
53+
help="For more information visit https://github.com/sclorg/s2i-nodejs-container" \
54+
usage="s2i build <SOURCE-REPOSITORY> ubi10/$NAME-$NODEJS_VERSION <APP-NAME>"
55+
56+
# Package libatomic_ops was removed
57+
RUN INSTALL_PKGS="make gcc gcc-c++ git openssl-devel nodejs nodejs-nodemon nodejs-npm nss_wrapper-libs which" && \
58+
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
59+
rpm -V $INSTALL_PKGS && \
60+
rm /usr/bin/node && ln -s /usr/bin/node-$NODEJS_VERSION /usr/bin/node && \
61+
rm /usr/bin/npm && ln -s /usr/bin/npm-$NODEJS_VERSION /usr/bin/npm && \
62+
rm /usr/bin/npx && ln -s /usr/bin/npx-$NODEJS_VERSION /usr/bin/npx && \
63+
node -v | grep -qe "^v$NODEJS_VERSION\." && echo "Found VERSION $NODEJS_VERSION" && \
64+
dnf -y clean all --enablerepo='*'
65+
66+
# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
67+
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
68+
RUN chmod +x /usr/libexec/s2i/init-wrapper
69+
70+
# Copy extra files to the image.
71+
COPY ./root/ /
72+
73+
# Drop the root user and make the content of /opt/app-root owned by user 1001
74+
RUN chown -R 1001:0 ${APP_ROOT} && chmod -R ug+rwx ${APP_ROOT} && \
75+
rpm-file-permissions
76+
77+
USER 1001
78+
79+
# Set the default CMD to print the usage of the language image
80+
CMD $STI_SCRIPTS_PATH/usage

test/test-lib-nodejs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ function test_client_fastify() {
458458
VERSION=$(echo "${VERSION}" | cut -d "-" -f 1)
459459
fi
460460
if [[ "$VERSION" == "18" ]]; then
461-
if [ "$OS" == "rhel8" ] || [ "$OS" == "rhel9" ]; then
462-
echo "Fastify is not supported in $VERSION and rhel8 and rhel9"
461+
if [ "$OS" == "rhel8" ] || [ "$OS" == "rhel9" ] || [ "$OS" == "rhel10" ]; then
462+
echo "Fastify is not supported in $VERSION and rhel8, rhel9, and rhel10"
463463
return
464464
fi
465465
fi

0 commit comments

Comments
 (0)