Skip to Content

Cloud Foundry has several buildpacks. One of them is the system buildpack node.js. This buildpack enables us to deploy node.js applications on HCP in just a few easy steps.

Prerequisites

To deploy a node.js application there are a few prerequisites.These are:

1. Enable the Starter Edition for Cloud Foundry Services

Login to HCP and enable the service Starter Edition for Cloud Foundry Services. Yes, the Cloud Foundry Services are in beta. I have no idea when this will go into production but I cannot imagine this will be too long because it is working.

ScreenShot001.jpg

Go to the service and create an Organization and a project within that organization. There seems to be a litte meshup between the terms because the project you create within an organization is in fact the name you want to remember as the organization when you push your application to HCP-CF. When you’re done creating a project/organization, create a space.

Create a space by first go to Administration and add a subscription to the HCP Starter Edition. Make sure you have the left menu entry “SAP HANA Cloud Platform”.

ScreenShot002.jpg

2. Install cf cli

Cloud Foundry has it’s own command line interface like the Heroku Toolbelt which makes it very easy to deploy a node.js application to HCP.

Deployment process

Now create your application. I created a react-redux application node.js application which I bundled with WebPack but any node.js application you create or have created will do ofcourse .

The steps to follow are :

1. Add files to your node.js application

Add a .cfignore file to the root of your application and add node_modules. This will prevent node_modules being uploaded to HCP. You do not need the node_modules folder since HCP will do a npm install when you deploy your application. The .cfignore is much like your .gitignore file.

Add a Procfile (optional) and add the line:


web: node server/server.js
or
web: node app.js









Add a manifest.yml file with some basic information about the application


applications:
- name: my-reactredux-app






The best way imo is to use npm scripts in package.json and just let HCP execute the script npm start. This would avoid having to create a Procfile. So in my package.json HCP will execute $ node server/server.js

ScreenShot012.jpg

2. Run the cf api / login / push commands

The cf commands are basically the same as Heroku has.


//creates an endpoint
$ cf api https://api.cf.us10.hana.ondemand.com
//login to the organization(project) and space
$ cf login https://api.cf.us10.hana.ondemand.com -o bertdeterd -s dev
//deploy
$ cf push



ScreenShot009.jpg

3. check your application

Within the project click on the button MANAGE HCP APPLICATIONS. A project is made up of 1 or several spaces.

Click on the url in Application Routes to see your application working.

ScreenShot010.jpg

And the app:

ScreenShot013.jpg

That’s it. With just a few easy steps you can deploy your node.js application on HCP. If you have a trial HCP account, give it a try.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Radu Ionel Cioienaru

    Hi,

    I am looking in my Hana cockpit at the services section. I have quite a few of them (Git, Web IDE, OAuth), but there’s no Cloud Foundry. Any idea how to add that service?

    Thanks,

    Radu

    (0) 
  2. Anton Komratov

    Thanks for the post. I’ll follow your instructions to create my own app on CF.

    By the way, do you know if this Starter Edition for CF Services is a substitution of XSA on HCP?

    (To be honest, I was waiting for XSA on HCP).

    (0) 
  3. Jay Malla

    I do not see the option – HCP Starter Edition for Cloud Foundry Services in my trial account.  How do I get this option?

    (0) 

Leave a Reply