There is a lot of movement in the PaaS world, many companies are trying to showcase what is the best platform and to be honest I don’t really know.
However I decided to try it out and I’ve choose Red Hat OpenShift.
Red Hat has done with OpenShift a great work, and any one could try it out with their free accounts.
These are the step that I’ve follow to get this done:
- Create an account in OpenShift
- Download the client tools as is described in this guide, as prerequisite you need Git and Ruby
- Create a folder and then set-up the tool
The set-up will create the domain for the apps and it will create & store a SSH certificate that identify the account.
- Create an application, it could be done as part of the set-up as well. I’ve choose NodeJS and MongoDB cartridge
- Edit package.json to edit the modules, I’ve add mongoose and bower, express was already there.
- Modify server.js code to connect to mongo using mongoose. They are environment variables already defined as its a cartridge in the app:
- Add your front side scripts dependencies using bower.json, like AngularJS.
- I’ve add and extra script step in package.json to launch bower when the app its build.
- Now to build the app.
If something went wrong we could view our logs, to access them:
Each time that we do a push the application will be sent to OpenShift and build, including update bower scripts. Them in OpenShift we could any time switch between builds in the Git repository or scale our app automatically.
We could choose to instead to do the bower step when we build, to do it in local and them upload to the repository the scripts dependencies, but the idea of a PaaS is that this is a standalone self contained app and it could be rebuild any time anywhere.
Additional we could add our own repository, as github just adding another remote:
So we could push to github whenever we like to:
Two prepare a local environment that we could use to build and test our app before sent to OpenShift we need to do some additional steps:
- Download and install NodeJS and MongoDB.
- Since we are going to build locally add .gitnore to node_module and bower_components folders so we don’t upload them to OpenShift.
- Configure MongoDB, including creating users and run the server.
- Set-up enviroment variables as the ones in OpenShift
Now we could build and run locally using
And that is the basic idea.
As I said I really like how OpenShift works and I’m looking forward to do more test with it.