14 February 2017 - Upkar Lidder Open Issue


  1. Sign up for Bluemix

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

Create nodejs application on Bluemix

  1. Create a new application from the main dashboard. Bluemix shows you all the available boiler plates.

  2. Go to Cloud Foundry Apps and pick SDK for Node.js

    ![Create Application]

  3. Specify application details

    ![Create Application]

  4. Click on Create. You will be taken to the application dashboard

    ![Create Application]

  5. This is good place to download the CF CLI if you haven't done so already. Get it from here.

Download Sample code

  1. Download sample code by clicking on "Download Starter Code". You don't necessarily need this starter code, but it has manifest.yml and package.json with some important dependencies. Also, app.js has some code to define the cloudfoundry environment variable and shows you how to use it. I would advise using this starter code if this is your first time with Bluemix.

  2. manifest.yml file

        - path: .
        memory: 256M
        instances: 1
        domain: mybluemix.net
        name: upkar-github-static-site
        host: upkar-github-static-site
        disk_quota: 1024M
This file defines memory and server instance requirements for your application along with total disk quota, domain and name.
  1. Package.json file
            "name": "NodejsStarterApp",
            "version": "0.0.1",
            "private": true,
            "scripts": {
                "start": "node app.js"
            "dependencies": {
                "express": "4.13.x",
                "cfenv": "1.0.x"
            "repository": {},
            "engines": {
                "node": "4.x"
These are the node.js dependencies for your application. For starting, it has express framework which will serve the static site as well as cfenv, which is a handy utility to get and set environment variables through your application code.

Nodejs magic to serve static site

  1. This use to be a manual step. But it now comes buit with the starter code
        app.use(express.static(__dirname + '/public'));

That single line in your app.js tells node.js where to fetch the static files from. You can just place your static site in the public directory and publish back to Bluemix using the next step

Publish app to Bluemix

These directions are also available in the app dashboard under "Getting Started".

  1. Connect to Bluemix using the CLI
    cf api https://api.ng.bluemix.net
  2. Login into your space
    cf login -u -o -s dev
  3. Deploy your changes to Bluemix
    cf push upkar-github-static-site

That's it. You are done! You can look at the static app at Upkar - static app

Open Issue

Back home