23 February 2017 - Upkar Lidder Open Issue


  1. Sign up for Bluemix

  2. Download Cloud Foundry command line interface (CLI) tools here

Create nodejs application locally

  1. This is not a nodejs or express tutorial. So we will create the simple hello world application as listed here.

        $ mkdir upkar-nodejs
        $ cd upkar-nodejs/
    $ npm init
            This utility will walk you through creating a package.json file.
            It only covers the most common items, and tries to guess sensible defaults.
            See `npm help json` for definitive documentation on these fields
            and exactly what they do.
            Use `npm install <pkg> --save` afterwards to install a package and
            save it as a dependency in the package.json file.
            Press ^C at any time to quit.
            name: (upkar-nodejs)
            version: (1.0.0)
            entry point: (index.js)
            test command:
            git repository:
            license: (ISC)
            About to write to /Users/upkar/Documents/code-upkar/upkar-nodejs/package.json:
            "name": "upkar-nodejs",
            "version": "1.0.0",
            "description": "",
            "main": "index.js",
            "scripts": {
                "test": "echo \"Error: no test specified\" && exit 1"
            "author": "",
            "license": "ISC"
  2. Install express to use as web server and also cvenf as a convenient library to access cloudfoundry environment variables

    $ npm install cfenv --save
    $ npm install express --save

  3. Create app.js

            $ touch app.js

    Content for app.js. We simple create a '/' endpoint that returns "hello world" and start the server.

            var express = require('express');
            var app = express();
            var cfenv = require('cfenv');
        var appEnv = cfenv.getAppEnv();
        app.get('/', function(req, res){
            res.send('Hello World');
        var port = appEnv.port || 3000;
        app.listen(port, function(){
            console.log('Example app listening on port: ' + port);
  4. Test locally using

            $ node app.js
            Example app listening on port: 6007
        $ curl http://localhost:6007
        Hello World

Publish app to Bluemix

  1. Before we actually push to Bluemix, we need to describe how to start the nodejs application. Add the following "start:" script to the package.json file.

    "scripts": {
    "start": "node app.js",
    "test": "echo "Error: no test specified" && exit 1"

  2. Connect to Bluemix using the CLI

        cf api https://api.ng.bluemix.net
  3. Login into your space

        cf login -u <user> -o <org> -s dev
  4. Deploy your changes to Bluemix

        cf push upkar-nodejs
  5. You can tail the logs using

        cf logs upkar-nodejs

    ![App logs]

  6. Final site
    That's it. You are done! You can look at nodejs site at


    ![Final App]


  1. If you look at the logs, IBM Bluemix is trying to figure out what kind of application you are trying to deploy. It goes through

    • ruby
    • swift
    • java (liberty)
    • go
    • dotnet

    before finally downloading the javascript nodejs buildpack.

    We could have helped out a little by creating am manifest.yml file at the root of our application directory.

  2. Sample manifest file

            - path: .
              memory: 256M
              instances: 1
              domain: mybluemix.net
              buildpack: nodejs_buildpack
              name: upkar-nodejs
              host: upkar-nodejs
              disk_quota: 1024M

Open Issue

Back home