Tuesday, May 27, 2014

Use Eclipse to deploy node.js application on BlueMix

IBM has release a plug-in called BlueMix for Eclipse Kepler Beta.You can see the detail in the link. It said not only support java liberty and also node.js deployment.I wrote the blog about how to use eclipse to deploy liberty demo to BlueMix.But how about node.js? There is little document about these things.I saw the internal email has this kind of information,so I forward here if you are interested in.

Creating a Node.js application for BlueMix from scratch
Summary of features covered:
- The ability to add JavaScript project to BlueMix
- Auto generation of required files to enable new projects to quickly be added to BlueMix
- Easily fill in the cloud deployment information via wizards
- The package.json file is parsed to determine which JavaScript entry file to run
- Easily allow the user to visit the URL of the project once it's on BlueMix
- Republish a project (that is, make a change and have it reflected without removing the application and then adding it back again)
- Allow the user to update existing cloud deployment information via the Applications Editor page
- Ability to remove the application from BlueMix

1. Create a JavaScript project in Eclipse. Let's call it HelloWorldNode

2. This project is empty and the user cannot add this application to BlueMix, until a facet is added to this project
Right click on the HelloWordlNode project > Properties > Project Facets

3.Click on "Convert to faceted form..." and select "Node.js Application"


4. Press OK
2 files will be generated if they don't already exist:
1. app.js - a skeleton entry JavaScript file
2. package.json - defines what the starting JavaScript should be, dependencies, and more. This is not cloud specific and is standard in Node.js applications

5.Right click on the BlueMix server > Add and Remove.HelloWorldNode to the right panel and click finish.

6. the deployment information wizards will now come up. This will enable the user to specify their application name and buildpack URL They can also choose the "Save to manifest file" option if they would like to save the properties that are being set by this wizard

7.Feature: the subdomain, domain, deployed URL, and memory limit can be set .If you don;t want to choose service you can pass the next wizard.

8 When you finish most of setting,you can see the console log.

Checking application - HelloWorldNode
Generating application archive
Creating application in Cloud Foundry server
Pushing application to Cloud Foundry server
Application successfully pushed to Cloud Foundry server
Staging application

-----> Downloaded app package (4.0K)
-----> Buildpack Version: 20140522-0208
-----> Resolving node version by IBM

       PRO TIP: Specify a node version in package.json

-----> Defaulting to latest stable node: 0.10.21
-----> Installing IBM SDK for Node.js from admin cache
-----> Read service config: MonitoringAndAnalytics.json at the start
-----> Read service config: SQLDB_BLUAcceleration.json at the start
-----> Writing a custom .npmrc to circumvent npm bugs
-----> Installing dependencies
       npm WARN package.json insert-title-here@0.0.1 No repository field.
       npm WARN package.json insert-title-here@0.0.1 No README data
-----> Cleaning up node-gyp and npm artifacts
-----> No Procfile found; Adding npm start to new Procfile
-----> Building runtime environment
-----> Read service config: MonitoringAndAnalytics.json at the end
-----> Read service config: SQLDB_BLUAcceleration.json at the end

9.Right click on the project in the Servers View > Open Home Page  you can see your application via the browser.


10.If you change the app.js code,you need to re-publish your application in the BlueMix server.

3 comments:

  1. Excuse me!

    Do you know how to install node.js application facet on Eclipse?

    I wanna push node.js project to cloud foundry via Eclipse , but I can't find the node.js application facet in my project facets list.

    Thank you!!

    ReplyDelete
  2. How do you run this node.js application in Eclipse first, before you push it to Bluemix?

    ReplyDelete