IBM Bluemix : For those of you who have not heard about IBM
Bluemix, IBM Bluemix is the latest PAAS environment from IBM, which is based on
open technologies like CloudFoundry, supporting various development languages
and service.
Before you go further reading a bit on IBM Bluemix would help : Bluemix Introduction
Bluemix supports lot of popular runtimes including Node.js
which makes it platform of choice for all the recent deployements, customer
demos etc. by my team. If you do not have a Bluemix account, you can register here
: Registration for Bluemix
Node.js : Node.js uses the popular javascript language for
server-side business applications, instead of the conventional client-side
logic. Its based on an event-driven model, so you basically develop functions
which can executed on occurrence of specific events. A great place to get
started with Node.js and download all installers is the home page https://nodejs.org/en/. Download and install
the version which matches your OS.
Lets get on with Developing a Hello World Application using IBM SDK Node.js and IBM
Bluemix.
High Level Architecture of Hello World Application
Steps
- You can use 2 ways to create Skelton Node js
application and deploy it to Bluemix.
-
First way is to do it directly from IBM Bluemix
Web Dashboard. Navigate to IBM Bluemix from your browser (https://console.bluemix.net)
- From Dashboard click on Create button, under
apps section.
- Select SDK for Node.js from the section Cloud
Foundry Apps
- Enter the AppName and you can leave rest of the
boxes as default. Kindly note Host name would be the public route to your
application.
- That
is it, our boilerplate Node application is ready and can be downloaded for any
modifications.
- Second
way is to create a sample node application locally and push it to bluemix.
- Use the npm init command to create the node
project skelton.
- Next install express dependency locally in your
project using the command npm install express
- Create your main javascript file, named app.js.
This can be done through command
touch app.js. - Content of your app.js could be
var express = require('express');var app = express();app.get('/', function(req, res){res.send('Hello World');});app.listen(8080);console.log("Sample Node application is now running on port 8080");
- You
can test this application locally by running it on local node server, using the
command
node app.js - You
can open the application in browser through url : http://localhost:8080/
-
1. Now let’s push this app to our Bluemix server, you can use below commandsa. bluemix login -o user@ibm.com -s dev -ssob. Get the one time code and paste in back for authentication to proceed.c. bluemix app push bluemixnodesampleapplication
No comments:
Post a Comment