OpenShift S2I builder images for Node.js
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ISSUE_TEMPLATE chore: update to use nodeshift org Nov 5, 2018
contrib/etc
hooks (build) tag and push LTS images in hooks/post_push Jun 1, 2017
imagestreams src: update imagestream latest tag to point to upstream Nov 12, 2018
s2i chore: update to use nodeshift org Nov 5, 2018
templates chore: update to use nodeshift org Nov 5, 2018
test src: add usage label to Dockerfile Nov 16, 2018
.gitignore feat: install dev dependencies only in DEBUG mode (#36) Feb 26, 2018
.travis.yml build: unnecessary bits removed (#134) Sep 19, 2018
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Nov 12, 2018
CONTRIBUTING.md chore: update to use nodeshift org Nov 5, 2018
Dockerfile src: add usage label to Dockerfile Nov 16, 2018
LICENSE src: add full license to LICENSE file Dec 1, 2017
Makefile src: change namespace from bucharestgold to nodeshift Oct 25, 2018
PUBLISHING.md docs: Note added about to update version on readme Jul 18, 2018
README.md chore: update to use nodeshift org Nov 5, 2018
versions.mk src: update latest to 11.0.0 Oct 25, 2018

README.md

OpenShift Builder Images for Node.js Applications

Build Status

This repository contains sources for an s2i builder image, based on CentOS7 and Node.js RPM releases from https://github.com/nodeshift/node-rpm. The RPMs and this builder image are the upstream sources for the Red Hat OpenShift Application Runtimes Node.js distribution.

docker hub stats

Versions

Node.js versions currently provided.

Version Tag
11.0.0 (11.x, latest)
10.12.0 (10.x)
9.11.1 (9.x)
8.12.0 (8.x, Carbon)
7.10.1 (7.x)
6.11.4 (6.x, Boron)
5.12.0 (5.x)
4.8.4 (4.x, Argon)

Usage

Using this image with OpenShift oc command line tool, or with s2i directly, will assemble your application source with its required dependencies, creating a new container image. This image contains your Node.js application and all required dependencies, and can be run either on OpenShift or directly on Docker.

OpenShift

The oc command-line tool can be used to start a build, layering your desired nodejs REPO_URL sources into a centos7 image with your selected RELEASE of Node.js via the following command format:

oc new-app nodeshift/centos7-s2i-nodejs:latest~https://github.com/nodeshift/nodejs-rest-http

OpenShift Catalog

With OpenShift, it is also possible to import this builder image into the online Catalog, so that applications can be created and deployed using this Node.js image through the web-based user interface. To import the images, run the following openshift command.

oc create -f imagestreams/nodejs-centos7.json

Docker

The Source2Image cli tools are available as a standalone project, allowing you to run your application directly in Docker.

This example will produce a new Docker image named webapp:

s2i build https://github.com/nodeshift/nodejs-rest-http nodeshift/centos7-s2i-nodejs:latest webapp

Then you can run the application image like this.

docker run -p 8080:8080 --rm -it webapp

Configuration

Use the following environment variables to configure the runtime behavior of the application image created from this builder image.

NAME Description
NPM_RUN Select an alternate / custom runtime mode, defined in your package.json file's scripts section (default: npm run "start")
NPM_MIRROR Sets the npm registry URL
NODE_ENV Node.js runtime mode (default: "production")
HTTP_PROXY use an npm proxy during assembly
HTTPS_PROXY use an npm proxy during assembly

One way to define a set of environment variables is to include them as key value pairs in a .s2i/environment file in your source repository.

Example: DATABASE_USER=sampleUser

Debug Mode

When NODE_ENV is set to development or DEV_MODE is set to true, your Node.js application will be started using nodemon.

npx nodemon --inspect="$DEBUG_PORT"

Using Docker's exec

To change your source code in a running container, use Docker's exec command:

docker exec -it <CONTAINER_ID> /bin/bash

After you Docker exec into the running container, your current directory is set to /opt/app-root/src, where the source code for your application is located.

Using OpenShift's rsync

If you have deployed your application to OpenShift, you can use oc rsync to copy local files to a remote container running in an OpenShift pod.