|
| 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 |
0 commit comments