Deploying Octopress on Openshift
Today I am going to lightly touch on how to install Octopress on Openshift. This post assumes you have a common understanding of the command line and its processes.
The Software / Services
- Octopress is a framework designed for jekyll to produce lightweight blogs.
- Openshift is an auto-scaling Platform as a Service (PaaS) for applications developed by RedHat.
This how-to is my workflow. It may not work for you and I will not be held accountable if it blows up your site, deletes your internets or kills your kitten.
- A terminal with access to git and ruby 1.9.3.
- A brain and the ability to think outside the box.
Step 1. Obtain an Openshift account.
At the time of this writing, openshift was free with 3 gears. You simply have to signup at Openshift and complete the registration steps. Once you have your account up and are logged into your Openshift account, do the following.
- Click on Add Application
- Install a Ruby 1.9 application.
- Leave the settings at default and put in your application name and namespace.
- Copy down the git repository url that openshift gives you on step 2.
(example) ssh://[email protected]/~/git/app.git/
If needed, upload your public SSH key from the server/PC you are going to be working with if this is your first application, they will prompt you for it.
Step 2. Getting Octopress Ready
Get the Octopress source and set it up.
1 2 3 4 5 6
At this point you should have a fully operational Octopress setup! That sure was easy. Moving on…
Step 3. Staging a public directory
I do not deploy the entire octopress directory to Openshift. It really is not needed at all and doing it this way takes up less space on your application. At this point you can just push it to your openshift git and it will probably just work. I like making things complicated though.
So we need to make another git repository somewhere outside octopress. Here is what I do.
1 2 3 4
I normally at this point modify my
_deployment/Gemfile to remove the –development stuff. All that should remain is the source and sinatra gem. Once you edited your file move on.
1 2 3 4 5 6 7
You should now see two directories.
octopress. We need to move that
_deployment directory into octopress.
At this point your probably asking why we did Step 3 outside the
octopress directory. Well when you initialize a git repo inside of another repo it adds it as a submodule. And to be honest, it’s never worked out well for me.
I keep my octopress synced with another repo on the internet and adding the repo as a directory instead of a submodule keeps it all in sync with no fuss. Your milage may vary.
Step 4. Putting it all together
Now we have to add this
_deployment directory into our
octopress repo. Generate a post and publish this sucker. Lets do this.
1 2 3 4 5
Now at this point in time, we have our static blog that we just generated in
octopress/public but we need that data into
_deployment/public to push it to Openshift. I have a modified Rakefile that does this for me, please modify it before using it and make you make sure you take a backup of your original. Download the Rakefile @ gist.github.com
If you use my Rakefile, you simply have to run
rake deploy and it will do everything for you. Your blog should now be live on http://app-domain.rhcloud.com/ go check it out..
If you want to do this manually, here is what you need to do. Again starting in the
Now we have a copy of our site in the
_deployment directory ready for publishing. Lets get it on the internets!
1 2 3 4
At this point Openshift will start spitting out what it’s doing in the background. Once it is done, you should see something like this.
1 2 3
Congrats! Your blog should now be live on http://application-namespace.rhcloud.com/ so go check it out.
If you get any errors, just remove the files in your _deployment/public/ and start over. I am sure there is an easier way for all of this, but I am used to doing it this way.
See any mistakes, ways this can go better or just want to say hey? Drop me a comment below!
Free Software, Hell Yeah!