Running io.js on OpenShift

io.js is still beta stability - so please proceed with caution.

I threw together a quick io.js cartridge that can be used on OpenShift.

Two options for testing:

  1. Bare bones cartridge: rhc create-app <name> http://tinyurl.com/OpenShiftIOJS
  2. Cartridge with an express.js hello world example: rhc create-app <name> http://tinyurl.com/OpenShiftIOJS --from-code https://github.com/connyay/express-openshift-iojs.git

You can find the source for the cartridge here.

I hope you find this useful! If you have any questions feel free to reach out at @_connyay

Hosting PencilBlue on OpenShift by Red Hat

Intro

What is PencilBlue?

The first open source content management system to meet all the needs of a modern website.

PencilBlue is a CMS built with modern technologies (Node.js, Mongo, and Angular) and has a lot of potential to shake things up. It is light, fast, and extremely flexible.

What is OpenShift?

OpenShift is an application platform in the cloud where application developers and teams can build, test, deploy, and run their applications.

OpenShift manages your cloud infrastructure so all you have to worry about is development. Updating your application on OpenShift is as simple as git push.

Prerequisites

  1. Have created an account with OpenShift
  2. Have installed the rhc command line tools
  3. Have setup the rhc command line tools by running rhc setup
  4. Have added an ssh key via the online console or the rhc sshkey-add <name> <path to SSH key file> command
  5. Have Mac / Linux (Not really, but Windows users will need to adjust some commands. :grimacing:)

Let’s get started!

  1. Navigate to the directory you’d like to create your new blog in
  2. Create a new app on OpenShift with the following command: (replacing <name> with your desired application name)

    Note: If desired, adding -s to the below command will automatically scale the application with traffic. This setting has to be set during application creation, and can not be changed.

     rhc create-app <name> http://tinyurl.com/OpenShiftNodeDIY http://tinyurl.com/OpenShiftRedisCart mongodb-2.4
    
  3. After the create-app is finished (it will probably take a bit) navigate into the cloned directory (cd <name>)
  4. Add a reference to PencilBlue upstream
    git remote add upstream https://github.com/pencilblue/pencilblue.git
  5. Fetch upstream remote
    git fetch upstream
  6. Pull in master from PencilBlue
    git reset --hard upstream/master
  7. Create (or download) a config.js file
    vi config.js
    or
    curl -O https://gist.githubusercontent.com/connyay/76102b76413588f68d12/raw/config.js

    Your config.js should look like this:

  8. Add an .openshift/action_hooks directory
    mkdir -p .openshift/action_hooks
  9. Create (or download) an .openshift build action_hook
    vi .openshift/action_hooks/build
    or
    curl -o .openshift/action_hooks/build https://gist.githubusercontent.com/connyay/76102b76413588f68d12/raw/build

    Your build action_hook should look like this:

  10. Make the build action hook executable
    chmod +x .openshift/action_hooks/build
  11. git add -> git commit -> git push
    git add -f config.js && git add -A && git commit -m 'Hello PencilBlue!' && git push origin master -f
  12. Visit your new PencilBlue website at: http://<your app name>-<your namespace>.rhcloud.com

Prefer a shell script? Steps 4-11 can be completed by using this script

(Only tested on Mac)
curl https://gist.githubusercontent.com/connyay/76102b76413588f68d12/raw/setup.sh | bash

Troubleshooting

If navigating to your app in the browser throws an error, then the first thing you’ll want to do is check the logs:
rhc tail <name>

I hope you find this useful! If you have any questions feel free to reach out at @_connyay

A workaround for --from-code on openshift

I have been unable to get the --from-code flag to work on openshift… I may be doing something incorrectly, but I am not sure. Every attempt I make results in 504 errors and an overall bad time.

Here is what I am talking about:
rhc create-app <app-name> "http://cartreflect-claytondev.rhcloud.com/reflect?github=connyay/openshift-node-diy" --from-code https://github.com/connyay/rh-labs-angular.git

After getting frustrated with this, I wrote a script. I integrated this script into my cartridge and have found it very useful.

Usage

Make the app
rhc create-app <app name> "http://cartreflect-claytondev.rhcloud.com/reflect?github=connyay/openshift-node-diy"

Go into the directory
cd <app name>

Lay down your code
./init.sh -r <your repo> -t <your tag> -n <app name>

How I use the script (as an example)

./init.sh -r connyay/rh-labs-angular -t 1.0.1 -n <app name>

What the script does

  1. Removes everything from the directory except for the init script, and the .git directory.
  2. Downloads the tarball for the repository at the optional tag.
  3. Replaces references to the ‘boilerplate app name’ to the optional name
  4. Does the first git push to the repository. (can be disabled with -no-push)

I hope you find this useful! If you have any questions feel free to reach out at @_connyay

Hello GitHub pages

I am slowly migrating to GitHub pages. Bear with me!