Deploying a git subtree to Heroku (or other PaaS)

Most of the common PaaS platforms like OpenShift and Heroku deploy code based on a source in a git repo – you push your local repo containing source to the remote repo on the platform, the build is performed remotely and then deploys the built artifacts.

What if you want to deploy an app that is prebuilt, or you have a git repo that contains various subfolders, and only part of the folder structure in the repo is what you need deployed?

I’ve been experimenting with a simple React app that also has a node.js backend. In hindsight restructuring the source tree to make the app easier to deploy may have been simpler, but it turns out you can push part of your source subtree to a remote repo, like an application deployed to Heroku, using ‘git subtree’:

git subtree push –prefix subfoldername heroku master

This is discussed in this post here.

OpenShift 2.0 Hot Deploy option

I’m not sure why I haven’t tried this earlier, but by default, when you git push your updates to OpenShift Online, it stops all your cartridges, builds, deploys and then restarts everything, which can take a few minutes.

OpenShift 2.0 supports a hot deploy option to minimize the amount of time that your app is down – details are in the docs here.

Wildfly CLI on OpenShift

SSH into server using ‘rhc ssh appname’, then:

jboss-cli.sh -c --controller=$OPENSHIFT_WILDFLY_IP:$OPENSHIFT_WILDFLY_MANAGEMENT_HTTP_PORT

Then you can cd to the service that you want to inspect, eg:

cd /subsystem=messaging/hornetq-server=default/jms-queue=exampleQueue

and from there, ls will list all the properties available.

More info here and here.

Another server drive failure – so migrated my WordPress blog to OpenShift

So it happened. Again. Although the last time was at least 5 years ago. A ton of i/o errors in syslog, and one of my drives in a RAID1 array is not responding. Strangely the other drive although still working is reporting in SMART that it is also about to die. That seems unlikely to have two drives go at the same time?

SMART overall-health self-assessment test result: FAILED!
Drive failure expected in less than 24 hours. SAVE ALL DATA.

Uh-oh.

So here’s the deal. The last time, roughly 5 years ago, I had a drive completely die and my Ubuntu server than I run from home wouldn’t boot. I lost several months of blog posts and notes. When I rebuilt it, I installed a pair of 250GB Hitachi Deskstar P7K500 drives in RAID1 configuration. The odd thing is that one of the drives kept dropping out of the array every few months in the last year, but it could be added back with the mdadm commands so I didn’t think much of it. Maybe I should have looked more closely in the logs what was going on.

So I’m at the decision point. Probably shouldn’t just replace one of the drives if one is alreay bad, should probably replace them both. Do I want to spend a couple of hundred on another pair of drives? At least the RAID array probably saved me from completely losing everything again.

I’ve run my own Linux server from home since about 2000. It’s physically changed motherboards a couple of times, its been a PIII and most recently a P4 with just 512MB of RAM and I’ve run JBoss versions from 3.x or so upto 5.x, Glassfish 3.x, I’ve run my blog on on my own custom app (BBWeblog), then Drupal, Joomla, and most recently WordPress on Apache. I’ve enjoyed running my own server since it means I can do whatever I like with it, and other than the cost for the hardware, there’s no hosting costs for my sites.

I think it’s reached the point though where enough is enough. Time to move online somewhere. Given that I’ve been using OpenShift for a number of projects at work, it seemed an easy choice to spin up a gear using the WordPress template and just import my site. And it only took a couple of minutes to get it up and running. I spent more time playing around with the WordPress Themes than I did actually setting it up and importing my site.

The only slightly tricky part was to update the DNS entry to point to OpenShift, which involved the following steps:

  • Update my record on zoneedit.com to delete the entry for my domain. I’ve been using ZoneEdit because they support Dynamic IP addresses by giving you a script to run locally to update what your actual IP address is periodically.
  • Update my GoDaddy account to remove the ZoneEdit DNS servers, switch from Custom DNS settings to Standard, click on DNS Zone File, and then add a CNAME record for ‘www’ pointing to my apps’s URL on OpenShift
  • Back to OpenShift, run ‘rhc add-alias wordpress www.kevinhooke.com’ where wordpress is the name of my app.

This post was useful, and here’s the docs for ‘rhc add-alias’

Done! It actually only took a couple of minutes for the changes to get reflected too, i.e. if I ping www.kevinhooke.com it’s now picking up the new IP for my OpenShift server on AWS.

I’m probably still going to play around with some customization options on WordPress, but  from start to finish it was probably less than an hour. It would have taken me far much longer than that to install new drives in my server, reinstall from a drive image, and get it all set up again. So, fingers crossed, here’s looking forward to my new home on OpenShift 🙂