Sunday, 31 December 2017

The year that was, 2017

Time to once again take stock of the last 12 months and that leads to an important question about 2017. Was it worse than 2016? For me, the answer is yes. Assorted burn-out issues have resulted in a significant decline in physical and mental health and a marked reduction in making things. That is something to fix for next year. Looking at the positives, I've survived a year in a new job and city and I've managed to catch up with a lot of friends from The Past. I've also managed to do Some Things, albeit Fewer Things than I'd have liked. Still, it hasn't all been Killing Floor 2 and Ultimate Chicken Horse.

  • 12 posts on this blog (13 including this one)
  • wrote a short story
  • another year of the Year in Pictures site, up to 15 photographers
  • over 385 contributions to various projects on github
  • completed GMing a 2 year 5th ed D&D game to great critical acclaim
  • got back in to playing D&D online
  • started planning a new regular game
  • created the university of bath RPG (post to follow on this)
  • went on a photography course to learn how to use my camera properly
  • 55+ pictures on my instagram account
  • loads of photos on my flickr stream
  • attended some cookery courses
  • updated my website and Gareth's website
  • lots of work with build pipelines and hosting
  • plenty of game recording, with sadly little to no video editing
  • a bit more voiceover work

I also hung up my abacus, finishing my time as a church treasurer and member of our church council with a financial presentation to the congregation. I've continued running the sound desk in the same church.

Resolution count: 3.5/10 - better than 2016. Still bad.

This coming year I'm going to try undoing the problems of this year - most notably fixing my health and writing more. I'm also starting a new role at work and I'm going to be spending more time going to see friends from university who have disappeared a bit. Here we go...

Thursday, 21 December 2017

Hosting a Rails App on Cloud Foundry - first impressions

From time to time I have been known to write a bit of code and whenever one writes a web application, there is always the question of hosting. I've done my time in Ops and I can certainly deploy an application to a VPS and run the surrounding infrastructure to make it work - however, that all sounds like more work than I'm willing to put in. This is the world of Cloud hosting and I'd like to spend my time writing applications, not deployment scripts. What I want is something I can throw code at and have it sort itself out but for my own projects the price needs to be low so I'm not spending a ton of money every month on my own games.

This is an interesting niche as I don't have the same requirements for my own stuff as I would for professional hosting. Initially my requirements were:

  • Very low monthly cost
  • Rails 5
  • Database (probably postgres)
  • Ability to hook it into some kind of CI (ideally Codeship, as I'm already using that)

For my own projects I'm not that bothered about high capacity, or extensive DR. These are great, but are also expensive.

I'm going to end up on Heroku, because the free tier appears to do everything I want and more. However along the way I tried out Cloud Foundry so I thought it worth writing up how I got started.

Easy stuff first

signed up for an account then created an org and a space on the dashboard. I also created a database within the space (no binding - it's better to do that with a manifest). This was all achievable via the web interface. The postgres service has the option of a free database, limited to 20mb storage.

Next, I installed the command line interface and logged in (cf l), choosing the space as the default.

Preparing the application

A Rails 5 application needs no additional configuration, beyond migrating it from sqlite to postgres. The easiest way to tie the application to the production database is via a manifest file. Mine looks like this:

- name: yip-helper
  random-route: true
  memory: 128M
  instances: 1
  path: .
  command: bundle exec rake db:migrate && bundle exec rails s -p $PORT
    - yip-postgres

The name becomes part of the subdomain on deployment. The memory is kept low to keep the costs down for a personal project. The service listed should match the name of the database created in the space, above. Stick this in the repository so it can be used with the CI later.

Now the application should be ready to deploy with a simple cf push.

Continuous integration

I use Codeship, and their docs worked fine for me with two modifications:

  • I dropped the CF_APPLICATION envar from the script as it's defined in the manifest file
  • My first deploy failed as it couldn't find the required gems - subsequent deploys worked fine, despite a warning about including the .bundle dir in my repo (which I didn't)


This all works with minimal fuss, however I'm going to end up going back to Heroku. I originally discounted it because it didn't play well with Docker (a requirement I've since abandoned). Also:

  • Heroku encrypts traffic for free on their own domain, whereas Cloud Foundry doesn't have this option. I can pay $20/month to use my own domain and cert but this breaks my first requirement. I can understand them charging for additional domain hosting but honestly, securing their own subdomains should be a given.
  • The Cloud Foundry free tier database is tiny. Paying for a database adds a lot to the monthly costs - this is true of all the hosting options I looked at - so a useful free tier offering is important.
  • Heroku is better supported. In Codeship, for example, there is a plugin to support it whereas Cloud Foundry requires a custom script. It's a simple one, to be fair, but it's symptomatic.
  • The Heroku tooling and web interface are nicer. Again, unsurprising given how much longer Heroku has been around. The Cloud Foundry tools are fine, but the doing the same things with Heroku is just easier.

So there it is. These are just my experiences, based on not a lot of time and with the intention of hosting for a personal project.