Deploying your existing StrongLoop application to IBM Bluemix

If you are not familiar with StrongLoop, you may need to check my previous post:

Deploying StrongLoop applications in Bluemix is tricky and requires you to do some modifications to your application. This post discusses the steps required to deploy a StrongLoop application that uses MongoDB to IBM Bluemix.

1. Create your StrongLoop Application in Bluemix

Before deploying your local Strongloop application in IBM Bluemix, make sure to create a Bluemix “StrongLoop Arc” application from the Bluemix Boilerplates as shown below.
StrongLoop Arc App

Then create and bind a MongoDB Service to your created StrongLoop application in IBM Bluemix.
Bind MongoDB to Bluemix app

Then download the application starter code from "Start Coding" page, extract the zip file, and then get the manifest.yml file which is as follows in my case.

- path: .
  memory: 512M
  instances: 1
  name: iReport
  host: iReport
  disk_quota: 1024M
  - iReport-MongoDB

Copy the manifest.yml file to your local StrongLoop application’s directory.

2. Use VCAP_APP_HOST and VCAP_APP_PORT inside server.js file

In server.js file under the server directory, make sure to Use process.env.VCAP_APP_HOST and process.env.VCAP_APP_PORT as shown in the code below.

boot(app, __dirname, function(err) {
  if (err) throw err;
  //Use Bluemix host and port ...  
  var host = process.env.VCAP_APP_HOST || 'localhost';
  var port = process.env.VCAP_APP_PORT || 1337;
  app.set('host', host);
  app.set('port', port);  

  // start the server if `$ node server.js`
  if (require.main === module)

3. Use the “start” attribute in package.json

If you do not use the "start" attribute in your package.json file, you may face the following exception when pushing your application to IBM Bluemix.

[App/0]  ERR npm ERR! Linux 3.19.0-25-generic
[App/0]  ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
[App/0]  ERR npm ERR! node v0.12.7
[App/0]  ERR npm ERR! npm  v2.11.3
[App/0]  ERR npm ERR! missing script: start
[App/0]  ERR npm ERR! 
[App/0]  ERR npm ERR! If you need help, you may report this error at:
[App/0]  ERR npm ERR!     <>
[App/0]  ERR npm ERR! Please include the following file with any support request:
[App/0]  ERR npm ERR!     /home/vcap/app/npm-debug.log
[DEA/14] ERR Instance (index 0) failed to start accepting connections

This is my package.json file which uses the "start" attribute as follows.

  "name": "iReport-Services",
  "version": "1.0.0",
  "scripts": {
    "pretest": "jshint .",
    "start": "node server/server.js"
  "dependencies": {
    "compression": "^1.0.3",
    "cors": "^2.5.2",
    "loopback": "^2.22.0",
    "loopback-boot": "^2.6.5",
    "loopback-component-explorer": "^2.1.0",
    "loopback-connector-mongodb": "^1.13.0",
    "loopback-datasource-juggler": "^2.39.0",
    "serve-favicon": "^2.0.1"
  "devDependencies": {
    "jshint": "^2.5.6"
  "repository": {
    "type": "",
    "url": ""
  "description": "iReport-Services"

4. Update datasources.json file under the application’s server directory

Under the server directory, there is a file called datasources.json which holds the application’s data source configurations, edit this file to point your application to the Bluemix MongoDB instead of your old MongoDB.

Below is my datasources.json file.

  "iReport-db": {
    "connector": "mongodb",
    "url": "mongodb://xxx"

You can get the "url" attribute from the MongoDB Bluemix configuration as shown in the screenshot below.
Bluemix MongoDB

After doing the previous steps, you can finally, cf push [your local strongloop application] to IBM Bluemix,

These are all the steps you need to do in order to have your StrongLoop application up-and-running in Bluemix, Enjoy!

Build and customize your first API with StrongLoop in less than 7 minutes

The StrongLoop API Platform features the popular open source LoopBack framework. LoopBack enables you to quickly compose scalable APIs, runs on top of the Express web framework and conforms to the Swagger 2.0 specification.

In this video, I showed how to quickly build and customize a REST API powered by LoopBack. Some things to make sure that they are there before applying this video:

  1. The model object (Cafeteria) used in this API is persistent in MongoDB. So make sure to start MongoDB before applying this video steps.
  2. Make sure to create an account in because you will use this account to access the API Composer.
  3. Make sure to have Node.JS installed in your machine:
  4. Install StrongLoop by executing the following command:
    $ npm install -g strongloop
  5. Know the purpose of the following commands:
    $ slc loopback

    This command creates a Node.js application using the LoopBack framework.

    $ slc arc

    This command runs StrongLoop Arc (which provides a GUI to define the app model), by default opening it in a web browser window.

  6. The last part of this video shows how to customize the Cafeteria RESTful API by implementing a new attribute status. The cafeteria status can be accessed using "GET /api/Cafeteria/status".

Enjoy watching the video: