Node.js on OpenShift

In the Enterprise

Lance Ball

Senior Software Engineer

[email protected]




Enterprise Architecture

Enterprise Architecture

Nahh... I'm good

Who Am I


Applications composed of small, independenly deployable services communicating 

over the network, usually with HTTP, transferring data/state between them, usually with JSON.


µ-Service Challenges

Operational Complexity




Service & Failure


Why OpenShift?

Red Hat



On Premise


OpenShift Building Blocks

  • Kubernetes

  • Docker

  • S2I - Source to Image

  • GitHub

OpenShift Origin

Origin is the upstream community project that powers OpenShift. Built around a core of Docker container packaging and Kubernetes container cluster management, Origin is also augmented by application lifecycle management functionality and DevOps tooling. Origin provides a complete open source container application platform.

Developer Tools

  • OpenShift Online

  • Minishift

  • Container Development Kit

  • Day to day developer environment
  • Single local cluster on your laptop
  • Download from GitHub


Brief Minishift Demo

# Start minishift
# Lots of output while minishift
# downloads docker images

$ minishift start --vm-driver=virtualbox

# Set local paths
$ eval $(minishift oc-env)

# Ensure oc is using minishift
$ oc config use-context minishift

# Open the web console
$ minishift console

Provided Builder Images

  • Provides runtime customization
  • Builtin with OpenShift
  • Also provided by community
  • "Easy" to create your own

Builder Images

Controlling Your Environment

# The parent image uses ONBUILD command
# to add package.json, run npm install and
# ultimately run the application

FROM bucharestgold/centos7-nodejs:7.10.0

# Set environment variables available
# in the runtime container
ENV ZIPKIN_SERVER_URL="http://zipkin"



ONBUILD COPY package.json /opt/app-root/src
ONBUILD COPY . /opt/app-root/src

# Drop the root user and make the content of
# /opt/app-root owned by user 1001
# Do this after we've copied the local directory
# to avoid UID conflicts
ONBUILD RUN chown -R 1001:0 /opt/app-root && chmod -R ug+rwx /opt/app-root

# Install the app
ONBUILD RUN npm -s install

CMD ["/bin/bash", "-c", "npm run -d $NPM_RUN" ]
$ oc new-project bonjour-tout-le-monde

$ oc new-build --binary --name=bonjour -l app=bonjour

$ oc start-build bonjour --from-dir=. --follow

$ oc new-app bonjour -l app=bonjour

$ oc expose service bonjour

New Project

$ oc new-build \
   --image-stream=centos7-s2i-nodejs:latest \
   --binary --name=hola -l app=hola

$ oc start-build hola --from-dir=. --follow

$ oc new-app hola -l app=hola

$ oc expose-service hola

s2i Builds

Importing Image Streams

  "kind": "ImageStream",
  "apiVersion": "v1",
  "metadata": {
    "name": "centos7-s2i-nodejs",
    "creationTimestamp": "2017-05-07T00:55:49.860Z"
  "spec": {
    "tags": [
        "name": "4.8.3",
        "annotations": {
          "description": "Build and run Node.js applications",
          "iconClass": "icon-nodejs",
          "tags": "builder, node, nodejs, nodejs-7.10.0, nodejs-7.10.0",
          "supports": "nodejs:7, nodejs:7.10, nodejs",
          "sampleRepo": ""
        "from": {
          "kind": "DockerImage",
          "name": "bucharestgold/centos7-s2i-nodejs:7.10.0"

Image Streams

Let's Try

Some Stuff Live!


Merci Beaucoup!

Lance Ball

Sr. Software Engineer

Red Hat

@lanceball  / @lance