Meteor 1.4 on IBM Bluemix

How to host your app in the IBM cloud for free

A client of mine wanted to use Bluemix as an hosting platform for their new iPhone hybrid app.

I went through many docs, stackoverflow and various posts about it but it was all with previous versions of Meteor. Mainly installing Meteor with a build pack then building the app in the cloud and doing some other setups before launching the resulting node app. But since this app is for web and iOS the cloud build crashed. I tried to cook my own build pack but without more success…

Building in the cloud was not successful :(

Although I’m not comfortable with a YAML config files and I do prefer to use a clean package.json file since we can use npm now with Meteor. So I knew I could find the Node path with all the docs I’ve been true, some were speaking about demeteorizer, but there had to be a better way. This is how I did.

This recipe assume that you have Node, Meteor, the cloudfoundry CLI and the Bluemix CLI installed. And also that you have setted up your Bluemix account.

To start we need to create an app in Bluemix with the online console. It’s going to be a web app of course.

And we are going to need the SDK for Node.js™ to get started.

Now let’s input the name of the app and soon the container is created. It’s empty, but it exist. Please don’t start it yet, we need a MongoDB.

Again in the Bluemix console but in the hidden labs catalog, let’s create the MongoDB service that we are going to bind to the app container.

Use the free plan and bind the MongoDB service to the web app

We are almost ready to deploy and start the app, we just need to set up the famous Meteor environment variables and specifically the MONGO_URL and the ROOT_URL. You will find them both in you Bluemix console. The ROOT_URL is shown at the top, right under your app container name. For the MONGO_URL just click on Show Credentials button at the bottom of the binded MongoDB service of your app. Copy the founded URLs in your favorite code editor.

And finally, still in the console, on the left, click on the Environment Variables menu. Now select the USER-DEFINED tab to set the founded URLs by pasting the values for the MONGO_URL and ROOT_URL variables.

Please change the values with the one you found in the Bluemix console website ;)

We are now ready to deploy some code. Open a terminal and make sure your are at the root of your Meteor app. We’re going to reset and build it locally for server only, with the right architecture, to make it a runnable Node.js app.

meteor reset && meteor build ../builds/. --server-only --architecture os.linux.x86_64

Now we need to have the package.json file I like added to this builded bundle. Go to the builds folder and extract the .tar.gz file. Go in the resulting bundle folder and add this package.json file:

"name": "myNewApp",
"private": true,
"scripts": {
"start": "node main.js"
"engines" : {
"node" : "4.5"
"dependencies": {
"bcrypt": "^0.8.7",
"jquery": "^3.1.0",
"meteor-node-stubs": "~0.2.3",
"moment": "^2.15.0"
Spoiler: You might need more dependencies, check the package.json file at the root of your Meteor app (it might not exist). This are the packages you installed with the command: meteor npm install -save packageName

We also need to install the server npm packages locally. This should be done with the following commands from the root of the bundle folder

cd programs/server/
npm install

Once all the packages are installed, we are almost good to go. We just need a little files rights fix (to do so we have to go back to the root of the bundle folder we just built and unpacked)

cd ../../
chmod -R +w+x *

Now is the time to deploy with a one line command from bundle directory root (please change app name with the one you used)

cf push mynewapp

You can now sit back, relax and enjoy your freshly deployed app on the IBM Bluemix cloud.

If you liked this post, please consider pressing the ❤ button and/or follow me on Twitter. Cheers fellow Meteor developer :)