$ docker pull registry.redhat.io/openshift3/nodejs-010-rhel7 $ docker pull registry.redhat.io/rhscl/nodejs-4-rhel7
OpenShift Online provides S2I enabled Node.js images for building and running Node.js applications. The Node.js S2I builder image assembles your application source with any required dependencies to create a new image containing your Node.js application. This resulting image can be run either by OpenShift Online or by a container runtime.
RHEL 7 images are available through the Red Hat Registry:
$ docker pull registry.redhat.io/openshift3/nodejs-010-rhel7 $ docker pull registry.redhat.io/rhscl/nodejs-4-rhel7
You can use these images through the nodejs
image stream.
S2I produces ready-to-run images by injecting source code into a container and letting the container prepare that source code for execution. It performs the following steps:
Starts a container from the builder image.
Downloads the application source.
Streams the scripts and application sources into the builder image container.
Runs the assemble script (from the builder image).
Saves the final image.
See S2I Build Process for a detailed overview of the build process.
The Node.js image supports a number of environment variables, which can be set to control the configuration and behavior of the Node.js runtime.
To set these environment variables as part of your image, you can place them into
a .s2i/environment file
inside your source code repository, or define them in
the environment
section of the build configuration’s sourceStrategy
definition.
You can also set environment variables to be used with an existing image when creating new applications, or by updating environment variables for existing objects such as deployment configurations.
Environment variables that control build behavior must be set as part of the s2i build configuration or in the .s2i/environment file to make them available to the build steps. |
Variable name | Description |
---|---|
|
When set to |
|
The debug port. Only valid if |
|
The custom NPM registry mirror URL. All NPM packages will be downloaded from the mirror link during the build process. |
Hot deployment allows you to quickly make and deploy changes to your application
without having to generate a new S2I build. In order to immediately pick up
changes made in your application source code, you must run your built image with
the DEV_MODE=true
environment variable.
You can set new environment variables when creating new applications, or updating environment variables for existing objects.
Only use the |
To change the source code of a running pod, open a remote shell into the container:
$ oc rsh <pod_id>
Entering into a running container changes your current directory to /opt/app-root/src, where the source code is located.
OpenShift Online includes an example template to deploy a sample Node.js application. This template builds and deploys the sample application on Node.js with a MongoDB database using a persistent volume for storage.
The sample application can be built and deployed using the
rhscl/nodejs-4-rhel7
image with the following command:
$ oc new-app --template=nodejs-mongo-persistent