{"id":24849318,"url":"https://github.com/bugbiteme/nodejs-hello-world","last_synced_at":"2026-03-04T03:01:23.104Z","repository":{"id":71384911,"uuid":"106492907","full_name":"bugbiteme/nodejs-hello-world","owner":"bugbiteme","description":"A simple and stateless \"Hello World\" Application written in Node.js used to illustrate OpenShift functionality","archived":false,"fork":false,"pushed_at":"2019-05-20T03:30:45.000Z","size":2639,"stargazers_count":0,"open_issues_count":0,"forks_count":15,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T20:33:28.128Z","etag":null,"topics":["hello-world","helloworld","html","javascript","minishift","node","nodejs","openshift"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bugbiteme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-11T02:01:28.000Z","updated_at":"2020-08-10T15:30:54.000Z","dependencies_parsed_at":"2023-07-07T05:16:09.848Z","dependency_job_id":null,"html_url":"https://github.com/bugbiteme/nodejs-hello-world","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bugbiteme/nodejs-hello-world","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fnodejs-hello-world","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fnodejs-hello-world/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fnodejs-hello-world/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fnodejs-hello-world/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugbiteme","download_url":"https://codeload.github.com/bugbiteme/nodejs-hello-world/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2Fnodejs-hello-world/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30070479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T01:03:42.280Z","status":"online","status_checked_at":"2026-03-04T02:00:07.464Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hello-world","helloworld","html","javascript","minishift","node","nodejs","openshift"],"created_at":"2025-01-31T12:30:35.609Z","updated_at":"2026-03-04T03:01:23.085Z","avatar_url":"https://github.com/bugbiteme.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nodejs-hello-world\n\n**A simple and stateless \"Hello World\" Application written in Node.js used to illustrate OpenShift functionality**\n\nIn this lesson, we will ocver the following topics:\n\n* Creating and deploying a new application in OpenShift (via CLI and GUI)\n*  Scaling the application up and down (via CLI and GUI)\n*  Deploying changes to code to production using the rolling update method (via CLI and GUI)\n\n## Prerequisites\n- MiniShift environment is up and running\n- See [Lesson 1 - Install and run Minishift](https://github.com/bugbiteme/openshift_tutorials) for instructions on how to install and run MiniShift \n- Ability to edit files (you will be making some code changes)\n- \n## Relevent files we will be looking at\n\n- server.js - Node.js server\n- views/index.html - Node.js/HTML view\n\n## Overview\n- TODO: graphic showing how code is deployed from github\n![img/GitHub-GitLab.png](img/GitHub-GitLab.png)\n\n## Deploying an application to OpenShift\n### CLI Method\n\n* Log into OpenShift/Minishift\n \n        $ oc login https://192.168.99.100:8443\n        Authentication required for https://192.168.99.100:8443 (openshift)\n        Username: developer\n        Password: developer\n        Login successful.\n\n        You have one project on this server: \"my-project\"\n\n        Using project \"my-project\".\n    \nmy-project is the default new project living in the minishift environment\n\n* Using the default project (my-project) deploy the app located here in github\n\n        oc new-app https://github.com/bugbiteme/nodejs-hello-world -l name=myapp\n        \napp will build and deploy to OpenShift/MiniShift\n\n\n    Node.js 6 \n    --------- \n    Node.js 6 available as docker container is a base platform for building and running various Node.js 6 applications and frameworks. Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.\n\n    Tags: builder, nodejs, nodejs6\n\n    * The source repository appears to match: nodejs\n    * A source build using source code from https://github.com/bugbiteme/nodejs-hello-world will be created\n    * The resulting image will be pushed to image stream \"nodejs-hello-world:latest\"\n    * Use 'start-build' to trigger a new build\n    * This image will be deployed in deployment config \"nodejs-hello-world\"\n    * Port 8080/tcp will be load balanced by service \"nodejs-hello-world\"\n    * Other containers can access this service through the hostname \"nodejs-hello-world\"\n\n    --\u003e Creating resources with label name=myapp ...\n        imagestream \"nodejs-hello-world\" created\n        buildconfig \"nodejs-hello-world\" created\n        deploymentconfig \"nodejs-hello-world\" created\n        service \"nodejs-hello-world\" created\n    --\u003e Success\n        Build scheduled, use 'oc logs -f bc/nodejs-hello-world' to track its progress.\n        Run 'oc status' to view your app.\n* From here, OpenShift will pull the code from github, build and deploy the application. \n* You can check the build status of the newly deployed app by running the following command\n\n        $ oc logs -f bc/nodejs-hello-world\n      \n*Example:*\n         \n    $ oc logs -f bc/nodejs-hello-world\n    \n     Cloning \"https://github.com/bugbiteme/nodejs-hello-world\" ...\n\t          Commit:\t145f3bdbdecb49b735a602aedeb679c1747d5b51 (images)\n\t          Author:\tLeon Levy \u003cleon.s.levy@gmail.com\u003e\n\t          Date:\tTue Oct 17 10:21:20 2017 -0700\n     ---\u003e Installing application source ...\n     ---\u003e Building your Node application from source\n     .\n     .\n     .\n     Pushing image 172.30.1.1:5000/my-project/nodejs-hello-world:latest ...\n     Pushed 0/9 layers, 0% complete\n     Pushed 1/9 layers, 11% complete\n     Push successful\n\n* Once the application has been deployed, we must create a route to it, so users can access the deployed application's web interface\n\n        $ oc expose svc/nodejs-hello-world\n        route \"nodejs-hello-world\" exposed\n        \n* Now lets use minishift to access the application\n\n        $ minishift openshift service nodejs-hello-world  --in-browser\n        Opening the route/NodePort http://nodejs-hello-world-my-project.192.168.99.100.nip.io in the default browser...\n\n![Screenshot of web based application](img/web-app-screenshot.png)\n\n### GUI Method\n\nAfter starting up Mini/OpenShift, point your web browser to the IP address shown at startup\n\n*Example:*\n\n    The server is accessible via web console at:\n        https://192.168.99.100:8443\n\nLogin using the developer/developer credentials.\n![](img/openshift_login.png)\n\n\nFrom here, click on the default project \"My Project\", or create a new project and open it.\n![](img/openshift_projects_default.png)\n\n\nNow click \"Add to Project\" to add a containerized application to the project.\n![](img/openshift_add_app.png)\n\n\nYou are deploying a Node.js application, which is written in JavaScript, so select that as the language.\n![](img/openshift_cat.png)\n\n\nThis is a stateless Node.js app not using a database, so select \"Node.js\" and version \"4\", then click the \"Select\" button.\n![](img/openshift_node.png)\n\nEnter the name of your application.  You are free to choose any name. \"node-js-hello-world\" was chosen for consistancy with this git repository.\n\nEnter this git repository's URL:\n\n    https://github.com/bugbiteme/nodejs-hello-world.git\n    \nNow click \"Create\"\n![](img/openshift_create.png)\n\n*Note: \"advanced options\" is out of the scope of this turorial. The defaults are fine at this point, but feel free to poke around and look at the options avialable here. Some items can be modified after deployment*\n\n\nOnce you click \"Create\" OpenShift will pull the code fom github, build and deploy a single instance of the nodejs-hello-world application.\n\nClick \"Continue to overview\" to see the status of the deployed application.\n![](img/openshift_created.png)\n\n\nThe below shows a high level view of the application pod. In this example the pod is one contaider running node-js-hello-world container. If an application is made up of mulitple deployed containers, you will see them all in the pod here.\n![](img/openshift_deployed_short.png)\n\n\nExpand the \"node-js-hello-world\" container to see more information about the deployment.\n\nOne thing to take note of is the \"ROUTES section uner \"Networking\". The URL listed is the URL of this application service, which happens to be the entry point to our application. Go ahead and click on the URL to see the application via the web browser.\n![](img/openshift_deployed_long.png)\n\n*Application Screenshot*\n![Screenshot of web based application](img/web-app-screenshot.png)\n\n*Note: More information on pods in the next section.*\n \n## Scaling the application up and down\n\nReasons to use scaling in your application:\n\n* Non-disruptive deployments\n* Meet the demands of end users\n\n\n### CLI Method\nScaling containers that make up an application deployment from one to many instances is easy from OpenShift CLI management console.\n\nCheck status on the number of application instances currently running, run the following command from the CLI:\n\n    $ oc get dc nodejs-hello-world\n    NAME                 REVISION   DESIRED   CURRENT   TRIGGERED BY\n    nodejs-hello-world   1          1         1         config,image(nodejs-hello-world:latest)\n\nAfter the initial deployment of our application, lets scale the number of instances from 1 to 3\n\n`$ oc scale --replicas=3 dc nodejs-hello-world`\n\n*Note: dc = deploymentConfig*\n\nNow run the status command to verify the number of replicas have increased to the desired number:\n\n    $ oc get dc nodejs-hello-world\n    NAME                 REVISION   DESIRED   CURRENT   TRIGGERED BY\n    nnodejs-hello-world   1          3         3         config,image(nodejs-hello-world:latest)\n    \nFrom the web GUI you can also see the number of pods (aka \"instnances\" or \"replicas\") has changed from 1 to 3.\n\nUse the same command when you want to scale down bu setting the `--replicas` flag to the desired number of instances.\n\n*Note: Although we are doing this manually in the tutorial, this process can be automated to scale as demand fluctuates*\n\n### GUI Method\nScaling containers that make up an application deployment from one to many instances is very straight forward from the OpenShift GUI management console.\n\n* from the Overview tab, expand the *node-js-hello-world* deployment\n![](img/openshift_deployed_long.png)\n* You can see the container: NODE-JS-HELLO-WORLD is currently scaled to one pod. In order to scale it to more instances, simply click the up arrow next to the blue circle to scale the application to more instances/pods.\n![](img/openshift-2-pods.png)\n* scroll down further to get more information about the pods running for the deployment\n![](img/openshift_2_pods_detail.png)\n* You can experiment and scale the number of pods up and down. Note that you can open the deployed application in different browser tabs, and where you see the text *Hello from pod ID - X*, X will be the same in all tabs if only one pod is running, but will change in the different tabs based on the number of pods running.\n\n\n## Deploying changes to code to application\n\n### Prereqs - Deploy a forked version of the example project\n\nFor this section, you will want to fork the existing *nodejs-hello-world* project in git up to your own account. You will also change some code and deploy the changes to the application.\n\n#### Delete Existing Deployement\n\n* Before we do anything, delete the application we have been using as an example\n\n* Navigate to the application in the OpenShift console\n![](img/openshift_clean1.png)\n\n* Click on the nodejs-hello-world deployment\n![](img/openshift_clean2.png)\n\n* Select *Delete* from the drop down menu under *Action* in the upper right corner\n![](img/openshift_clean3.png)\n\n* Confirm that you want to delete *nodejs-hello-world* (it's OK)\n\n* Navigate to the old image in OpenShift (Builds-\u003eImages)\n![](img/openshift_clean4.png)\n\n* Click on *nodejs-hello-world*\n\n* From the *Action* drop down menue, select the *Delete* action\n\n* Perform the same action under Builds-\u003eBuilds (delete it)\n\n* Perform the same action under Applications-\u003eServices (and Routes) (delete it)\n\n* Now we are ready to deploy the forked project!!! \n\n\n\n#### Clone Project\n\n* Go to the github project [https://github.com/bugbiteme/nodejs-hello-world\n]() (the one you are reading right now)\n\n* Click the *Fork* button on the upper right hand of the webpage\n\n* This will fork the repository to your own github account (Example: **http://github.com.YOUR_ACCOUNT.nodejs-hello-world**). This will allow you to make and check in code changes.\n\n* Clone the project to your local system:\n\n`$ git clone http://github.com.YOUR_ACCOUNT.nodejs-hello-world.git`\n\n* This will create a folder on your workstation called *nodejs-hello-world*\n\n* Navigate to the directory *nodejs-hello-world*\n \n`$ cd nodejs-hello-world`\n\n* Navigate to the *views* directory. This is where part of the code lives. We will come back to this later.\n \n`$ cd views`\n\n#### Deploy and scale up forked project\n* deploy the forked project (using the CLI method or GUI methods discussed above).\n\n* Scale the deployed application to 8 pods\n\n![](img/openshift_scale_8.png)\n\n### Rolling update (default method)\n\nA rolling deployment slowly replaces instances of the previous version of an application with instances of the new version of the application. A rolling deployment typically waits for new pods to become ready via a readiness check before scaling down the old components. If a significant issue occurs, the rolling deployment can be aborted.\n\n#####When to Use a Rolling Deployment\n\n* When you want to take no downtime during an application update.\n\n* When your application supports having old code and new code running at the same time.\n\nA rolling deployment means you to have both old and new versions of your code running at the same time. This typically requires that your application handle N-1 compatibility, that data stored by the new version can be read and handled (or gracefully ignored) by the old version of the code. This can take many forms — data stored on disk, in a database, in a temporary cache, or that is part of a user’s browser session. While most web applications can support rolling deployments, it is important to test and design your application to handle it.\n\n### Make some code changes\n\nNow verify that your web application is up and running by going to the routed URL\n\n![](img/openshift_deploy_before.png)\n\nUsing your favorite text editor (TexWrangler, Notepad++, vi, etc...), open the file: \n\n* *nodejs-hello-world/views/index.html*\n\nand make some edits.\n\n*example before code change:*\n\n\t\n\t\u003cstyle\u003e\n\th2 {\n    \tfont-family: Arial, Helvetica, sans-serif;\n\t}\n\n\tp {\n    \tfont-family: Arial, Helvetica, sans-serif;\n\t}\n\t\u003c/style\u003e\n\t\t\n\t\t\u003ctitle\u003eNodejs Hello World Example for OpenShift!\u003c/title\u003e\n\t\u003c/head\u003e\t       \n\t\u003cbody\u003e\n\t\t\u003ch2\u003eHello World!!!\u003c/h2\u003e\n                \u003cp\u003e\u003cb\u003eMessage passed from nodejs server:\u003c/b\u003e\n                \u003c% if (messageFromNode) { %\u003e\n                   \u003cspan class=\"code\" id=\"count-value\"\u003e\u003c%=messageFromNode%\u003e\u003c/span\u003e\n                   \u003c/p\u003e\n                \u003c% } else { %\u003e\n                   \u003cspan class=\"code\" id=\"count-value\"\u003eNo value found\u003c/span\u003e\n                   \u003c/p\u003e\n                \u003c%} %\u003e\n\n\t\u003c/body\u003e\n\nChange the line:\n\n`\u003ch2\u003eHello World!!!\u003c/h2\u003e`\n\nto something else: \n\n*example:* `\u003ch2\u003eHello Code Change!!!\u003c/h2\u003e`\n\nNow save the file and push the changes to github:\n\n* From the command line, make sure you are in the repository root directory:\n\n    \n        $ pwd\n        /Users/user/projects/nodejs-hello-world\n\n* Push the code to github using the following three commands:\n\n        $ git add *\n        \n        $ git commit -m \"changes to index.html\"\n        \n        [master 8e47799] changes to index.html\n         2 files changed, 67 insertions(+), 1 deletion(-)\n         create mode 100644 img/openshift_deploy_before.png\n        \n        $ git push\n        \n        Counting objects: 5, done.\n        Delta compression using up to 8 threads.\n        Compressing objects: 100% (5/5), done.\n        Writing objects: 100% (5/5), 33.91 KiB | 0 bytes/s, done.\n        Total 5 (delta 2), reused 0 (delta 0)\n        remote: Resolving deltas: 100% (2/2), completed with 2 local objects.\n        To https://github.com/YOUR_ACCOUNT/nodejs-hello-world.git\n           2ba8d7d..8e47799  master -\u003e master        \n\nNow that your code changes are checked in, it's time to deploy them to your OpenShift environment!\n\n#### CLI Method\n\nFrom the CLI, type in the following command to build and deploy the code changes we just made:\n\n    $ oc start-build myapp\n    \nTo see logging in real time, append the `--follow` flag:\n\n    $ oc start-build myapp --follow\n    \n*Example*\n\n    $ oc start-build myapp --follow\n    build \"myapp-9\" started\n    Cloning \"https://github.com/team-bugbiteme/nodejs-hello-world.git\" ...\n\t    Commit:\t12ef08da162c3659e9384449a81c84565a9b8ddd (changes to index.html)\n\t    Author:\tLeon Levy \u003cleon.s.levy@gmail.com\u003e\n\t    Date:\tMon Dec 18 14:16:31 2017 -0800\n    ---\u003e Installing application source ...\n    ---\u003e Building your Node application from source\n    ...\n    Push successful\n\nFrom the log you can see all the automated build and deployment operations, such as:\n\n\n* Cloning updated code from version control (github)\n* Checking dependancies\n* Compiling the new code\n* Pushing the application to \"production\"\n\n#### GUI Method\n\nFrom the *Overview* page, select *Start Build\" from the drop down menu on the upper right corner. \n![](img/openshift_start_build_gui.png)\n\nThis will pull the latest code from github (the one we just checked in) build and deploy it as a rolling update.\n\nAs in the screenshot below, you should be able to see the existing deployment scaling down on the left, while the new build scales up on the right.\n\n![](img/openshift_rolling_gui.png)\n\nClick *View Full Log* to see all the automated the steps performed for the rebuild and deploy operation.\n\nThese steps include:\n\n* Cloning updated code from version control (github)\n* Checking dependancies\n* Compiling the new code\n* Pushing the application to \"production\"\n\nCheck to see if your code changes are visible in the application by refreshing the application URL.\n![](img/openshift_deploy_after.png)\n\nFor more information on other types of deployments, see: [Advanced Deployment Strategies](https://docs.openshift.com/container-platform/3.3/dev_guide/deployments/advanced_deployment_strategies.html) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugbiteme%2Fnodejs-hello-world","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugbiteme%2Fnodejs-hello-world","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugbiteme%2Fnodejs-hello-world/lists"}