If you’re like me when using a new system, it’s nice to have the simplest conceivable example to try out first and then play around a bit to make sure you’re in the driver’s seat. For the brand new IBM Bluemix user, here’s my attempt with no frills and no philosophy—just a very small amount of code and how-to. There are some wonderful directions on the fabulous Bluemix web UI available on the Bluemix website.
What you’ll be doing
You’re going to sign up to get an IBM ID, sign up for Bluemix, then run through a few simple commands to get your first piece of code up and running. This little run-through will use only the tiniest corner of the power of Bluemix—but every journey starts with a first step.
Micro-primer on Bluemix
Bluemix provides a platform as a service (PaaS) for several different runtimes, specifically:
• Liberty for Java – a highly composable, fast and light profile of IBM WebSphere Application Server designed for the cloud
• Ruby on Rails and Ruby Sinatra – focused on quickly creating web-applications in Ruby with minimal effort
This means that you can deploy an application of any of these types to Bluemix, without having to worry about server setup or configuration.
If you don’t have one already, sign up to get an IBM ID.
Step 1: Sign up for IBM Bluemix
This gets you an account on the brand new IBM Cloud Foundry-based platform as a service (PaaS) cloud. Sign up for the open beta.
It’s well worth exploring the website, the user interface and examples. The rest of this article takes another perspective—the command-line approach!
Step 2: Install the Cloud Foundry CLI, the official command line client for Cloud Foundry.
This is the command that you’ll use to get your code deployed and running on Bluemix.
Install the Cloud Foundry CLI for your system. Scroll down through the readme file to the Installers section for your platform
Step 3: Download the files you’re going to deploy
The kit includes the following parts:
• manifest.yml, which tells Bluemix that it’s being given a node.js application
• package.json, which defines to the node.js runtime the dependencies that server.js has
All of these are available as open source on JazzHub, where you will also find:
• readme.md, a very thorough description of server.js, in markdown format
Step 4: A tiny edit; edit manifest.yml to give your host a unique name.
This is important! Your little server will have a URL that starts with this name.
Step 5: Tell Cloud Foundry to use the Bluemix (web) application programming interface (API)
This command tells the cf command-line that it should direct its interactions at Bluemix. Since this is a web API, all you need to do is specify a URL.
$ cf api https://api.ng.bluemix.net
Setting api endpint to https://api.ng.bluemix.net... OK
You only need to do this once. All subsequent commands will interact with the Bluemix web API.
Step 6: Log in to Bluemix
Enter the IBM ID and password that you set up.
Step 7: Push your application to Bluemix!
Open up a command line for your operating system and navigate to the place where you saved the files from JazzHub and simply type:
Lots of magic happens now:
• Using the information in the manifest.yml file, Bluemix knows how to create a runtime for the application
• Using information in package.json, it will realize that this application needs express.js in order to run, and it will run the NodePackage Manager to get that dependency installed (you’ll see lots of information scroll up your screen as express.js and its dependencies get installed)
• Finally, it starts server.js
A few other useful commands to list your apps and to start or stop each one are:
cf apps Lists all of your applications
cf start app_name Starts app_name
cf stop app_name Stops app_name
Step 8. “Bonjour, tout le monde”
Go to your favorite browser and enter the URL:
Alternatively, you can try mine at
Let’s look at each file in turn:
manifest.yml is used by Bluemix to determine what to do with the other files it is given. You can think of it as a way of bundling up a pile of cf command-line options into a file.
# the URL for the application will be .
# in this example, that's change_this_to_something_unique.ng.bluemix.net
# !! YOU MUST CHANGE host TO SOMETHING UNIQUE !!
- host: change_this_to_something_unique
# the name of the application that you will see if you type 'cf apps'
# the files to 'push' are in the current directory
# bluemix runs this command to initiate the application
command: node server.js
# tell bluemix to create 1 server instance
This file is required by the node.js runtime. Apart from naming the package, it defines the dependencies. In this case, the only dependency is on express.js (http://expressjs.com/), a minimal and flexible node.js web application framework
"description": "Very simple node.js server using Express",
into your browser, it responds with “Hello world, from England.” While typing
gets you the response “Bonjour tout le monde, de la France.”
The only point I will note in this article is that these few lines of code (hopefully self evident) are there to provide the response in English.
// specify what to do when http GET is received on http:///english
res.send("Hello world, from England.");
Feel free to experiment by adding your own language support!
If you don’t know node.js
There is a very thorough analysis of every line of server.js in the overview on JazzHub.
It attempts to take you from zero knowledge of node.js to a thorough understanding of server.js.
In this post, I took you thorough a simple example to get some experience with Bluemix. If you would like to continue this discussion, you can connect with me on Twitter at @robphippen.
Share this post: