Cloudy With a Chance of Meteor.js

meteor on openshift picture

Meteor is a hot new javascript-based application framework which uses node.js and MongoDB to help you build realtime, interactive websites in a snap.

It emphasizes the use of fibers for writing node.js applications, which may make it easier to pick up for those of you who are not used to making heavy use of callbacks in your code.

Take a look at Meteor’s screencast, docs, and example apps to learn more, and to reset your expectations for what is possible with modern application development.

WARNING: This guide isn’t compatible with recent versions of Meteor.  A meteor Cartridge is needed.

Basic Setup

If this is your first time using OpenShift Online or meteor.js, you’ll have a few setup tasks to do:

  1. Create an OpenShift Online account
  2. If you don’t already have the rhc (Red Hat Cloud) command-line tools, run: sudo gem install rhc
  3. Run rhc setup to link your OpenShift Online account with your local development environment, and to select an application namespace
  4. Install Node.js, MongoDB. Then add Meteor to your local development environment: curl https://install.meteor.com | sh

For additional assistance setting up the rhc command-line tool, see the following page: https://www.openshift.com/developers/rhc-client-tools-install

Configure your OpenShift gear

Spin up a new OpenShift gear with Node.js, MongoDB, and a shim to help meteor.js connect to the correct ports. This example uses the application name: “meteor

rhc app create meteor nodejs-0.10 mongodb-2.2 --from-code=https://github.com/openshift-quickstart/openshift-meteorjs-quickstart.git

The above command will output a local copy of your OpenShift application source in a folder matching your application name. Be sure to run this command from within a folder where you would like to keep your project source.

Create a Meteor.js example project

To see a list of all available meteor.js example projects, type meteor create --list.

In this guide, we’ll use the meteor.js “leaderboard” example:

meteor create --example leaderboard

See http://meteor.com/examples/ to learn about what other example applications are available. Feel free to try them all.

Bundle and merge your meteor.js code

Bundle up your meteor application source:

cd leaderboard # if you chose the leaderboard example
meteor bundle bundle.tar.gz # to prep for deployment

Next, you’ll need to extract the resulting code into your OpenShift application folder (minus the “bundle/” folder wrapper that Meteor will automatically include). Use the -k flag when extracting to prevent the existing DB connection code from being overwritten during this merge process.

If you are developing on Linux, or using GNU tar, this command should work:

tar -xvf bundle.tar.gz --transform 's|^bundle/||' -C ../meteor/

For Mac or BSD-based operating systems:

tar -xvf bundle.tar.gz -s '/^bundle//' -C ../meteor/

The above example assumes that you named your OpenShift application “meteor”, as shown in the rhc app create step. And, that your OpenShift application source code is available at this relative path: ../meteor

Add these new files to your OpenShift application’s Git repo:

cd ../meteor
git add .
git commit -am "Adding a meteor.js application bundle"

Deploy to OpenShift

Then, push the new code to OpenShift to deploy your meteor.js application bundle:

git push

That’s it! Check out your new Meteor.js application at:

http://meteor-$yournamespace.rhcloud.com

Thanks for following along!

An OpenShift + Meteor quickstart guide is also available on GitHub – https://github.com/openshift-quickstart/openshift-meteorjs-quickstart

Next Steps

Automatic Updates

Stay informed and learn more about OpenShift by receiving email updates.

Get blog updates by email
Categories
Node.js, OpenShift Online
Tags
, , ,
Comments are closed.