I’ll detail how to take a new or existing GH Pages blog in Octopress and deploy it to OpenShift.
I recently moved my blog from Github Pages to OpenShift Online. I did this because I wanted to utilize SSL with my custom domain - a feature not currently available on Github Pages (it’s 12/14/2014 - let me know when this becomes possible!). OpenShift supports SSL with a free account, so I decided to make the switch. I wanted to use the existing architecture set up by Octopress that built my GH Pages blog. Hopefully you see a little lock icon in your address bar if you’re reading this from the site.
Here’s the link: https://www.openshift.com/app/account/new. They’re serious about the first and second options being free. The difference is signing up for the second option requires credit card information to give you the possibility of scaling your application. The second option is what allows you to add certs for doing SSL.
Octopress still uses ruby 1.9.3; for simplicity’s sake, so will we. Assuming you have ruby-1.9.3 installed and the rhc gem installed (gem install rhc), create a new ruby-1.9 application on OpenShift:
replacing “octopress” with your desired application name. I’ve found this action takes some time, usually over a minute, while OpenShift allocates resources. When your application has been created, you should see an
ssh:// URL for your git repository on OpenShift. Make sure you can get access to this later.
If you’re using a custom domain, now is as good a time as any to set it up. OpenShift has its own docs to cover this topic.
I’ve made some updates to the octopress repo that I haven’t requested be pulled into the master branch yet. I’ll update this section in the future if necessary.
If you’re new to Octopress, clone from the master branch:
cd into your octopress directory and merge in my fork:
There is a rake task for setting up an OpenShift deployment called
setup_openshift. This rake task clobbers the
_deploy directory and reinitializes it using the URL for your OpenShift repository, which we committed to memory in Step 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Do you already have SSL for your domain? Bully for you! I’ve included an option to
setup_openshift to force traffic to use
https in a production environment. Just send a second parameter to rake and it’ll do the rest.
Note that you will still need to change your URL in
_config.yml if you are using a custom domain.
Now we can just run the
deploy rake tasks to deploy our app to OpenShift. This task verifies we have the latest version of our OpenShift
master branch, installs missing gems, copies over your
public folder, and pushes the application to OpenShift.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
That’s that. Treat it as any Octopress install. I’ll see if the owners of the octopress repository would be interested in pulling in my customizations and update this blog post as necessary.
As for my switch from GH Pages to OpenShift: I’ve found OpenShift to be just as fast as the GH Pages static server, especially when combined with Cloudflare’s CDN and optimization systems. No regrets so far. Drop me a line in the comments if you have a beef with OpenShift or know of any equivalent alternatives.