Exercise 6: Deploy a Node application with Build Config (CLI version)
In this exercise we'll revisit the application from exercise 1, except we'll use equivalent CLI commands to deploy our "Example Health" application.
From the IBM Cloud console launch the IBM Cloud Shell. Refer to our Getting Starting material to learn how to access the IBM Cloud Shell.
Deploy Example Health (CLI version)
First, clone the Example Health source code and change to that directory.
git clone https://github.com/IBM/node-build-config-openshift
cd node-build-config-openshiftTake note of the new Dockerfile in the application's root directory. We've pre-written it for you. But we've copied it here too, go through each line and read the corresponding comment.
# Use the official Node 10 image
FROM node:10
# Change directory to /usr/src/app
WORKDIR /usr/src/app
# Copy the application source code
COPY . .
# Change directory to site/
WORKDIR site/
# Install dependencies
RUN npm install
# Allow traffic on port 8080
EXPOSE 8080
# Start the application
CMD [ "npm", "start" ]From the OpenShift console click the user name in the top right corner and select Copy Login Command.

The login command will be copied to the clipboard, in the IBM Cloud Shell, paste that command. For example:
Create a new OpenShift project to deploy our application, call it example-health-ns.
Build your application's image by running the oc new-build command from your source code root directory. This will create a Build and an ImageStream of the app.
The output should look like below:
Start a new build using the oc start-build command.
The output should look like below:
Finally, deploy the application by running oc new-app.
The output should look like below:
Expose the service using oc expose, a route will be created.
Find the application's route by running oc get routes.
The output should look like below:
Copy the URL into a browser and log into the site with admin:test.

Congratulations on completing this exercise!
Last updated
Was this helpful?