Saturday, August 17, 2013

Journeyman weeks - week one @ bitbond.net

After publishing my initial post and advertising it on Twitter I was quite overwhelmed with the positive reaction and offers of support. I also realised I had very little clue about how to do this from a logistical perspective.

Nevertheless, I quickly found the first two companies willing to host me. And so I decided to just set out and figure the rest out along the way. This will probably eventually involve having to consult with a tax accountant but that's for another day.

For the first week I returned to Berlin once more. My ex-colleague Gregor Russbuelt connected me to one of his former colleagues, Jürgen Walter, who heads up the technical side of a little startup at https://www.bitbond.net. I was looking forward to do a little Rails work in earnest and possibly also learn more about bitcoin. The latter part didn't actually happen but I'm quite happy with what other stuff I picked up along the way.

Balconia Berlin

Jürgen put me up in a room in his nice apartment in Prenzlauer Berg and we went out to a co-working space nearby each day to do our work. As a first problem we tried to change bitbond's capistrano scripts to work on docker images rather than straight on the remote server. Coincidentally, both Jürgen and myself had recently been pointed at docker.io and thought it was worth looking into further. It turned out that assessment was correct. It's a really neat little toolset. Although it did take us a while to get a clear understanding of how repositories, images, containers, tags and volumes fit together. (Now there's a new tutorial available. Maybe that makes things easier.)

Docker

Docker lets you spin up preconfigured ubuntu instances and run commands inside of them. The idea being that you have a little vm for each of your components. Spin up an image to run the rails app, one to run redis and maybe more for postgres and nginx. Each image is essentially disposable and changes in state to the image are only persisted if you use docker to commit the image. There is a concept of ephemeral, potentially persistent volumes that can be mounted and shared between images, allowing you to store e.g. the data of your postgres server.

Each image keeps a history of the commits made to it and you can run commands against each of these versions or base new images or repositories on them. A repository is maybe best described as a branch. Lastly, new images can also be built off of existing repositories and there is a public directory containing a lot of useful readily configured ones.

There is a limitation to the size of an image's history though, so you cannot run more than 42 (doubt that's unintentional) commands within an image while committing the results. This should usually not be an issue but while we were toying around with our deployments we committed quite a few changes and then were quite surprised when we ran into this problem. It didn't help that the error message is far from helpful.

Our plan then was to

  • build new images based on the default docker ubuntu repository, containing the debian packages necessary for rails/postgres/redis/nginx
  • in the case of rails, run each capistrano step inside of the docker image, committing the image after each step 
  • for the other images, run the respective service, making sure addresses and ports of related services are passed in as environment variables and passed on correctly
  • start rails from its image, also passing in information about related services 

(There is another project called coreos that would make the configuration a little more scalable by using etcd to handle service discovery but we didn't look into that)

We wrote a bunch of little shell scripts to help with the individual steps and also experimented a lot until we sort of figured out how docker volumes work. We spent some time working on creating a capistrano plugin to make this available to others. Hopefully it won't take too long to get that ready.

Working on the application

We eventually got to a point where we had a redis and postgres image serving data and a rails and nginx image serving up dynamic and static content, respectively, all working together. At this point we stopped and went to work on the actual application, going through the list of open bugs and features for bitbond.

I was quite impressed with the level of testing being done on bitbond and with Jürgen's TDD workflow and good naming of things. This last bit might sound like a minor thing until you've actually worked on code where people are diligent about keeping things appropriately named. It makes working with the code just so much easier.

And so when we were working on a little bug, we wrote a test that reproduced that behaviour and then fixed the code. When we worked on a new feature, we started with a small capybara script that described how that feature was supposed to work and then implemented against that. It's a very focused, quick and rewarding way of working and I always appreciative when I get to do it.

So we did that and then deployed to production, thereby also making sure we didn't screw up the current production deployment scripts too bad. Ah, the joy of releasing. I can't understand why so many people artificially limit themselves from having that experience more often.

I also got a glimpse of more of coffee script and haml for working on the client side of things. I always liked both of them but never had the opportunity to do any real work with them. At least in the case of coffee script I definitely need to finally change that. Hopefully my recent experiences with lineman will help with that.

Success

So I'm considering the first week of my little journeyman tour a smashing success. I learned new things, got to meet new people and helped ship code. I feel extremely privileged and happy that I have the opportunity to go on this little adventure and do so at such short notice. This community is really great. (And I'm not even sure what "this community" means, exactly.)

If you think what I'm doing here is interesting, please spread the word or invite me over. You can still contact me at dtemme@gmail.com or @dtemme on Twitter. My calendar is still available at this link as well as embedded at the end of this post.

Next up

I'm staying in the broader domain of financial services but moving to Frankfurt, where vaamo is hosting me. I'm really looking forward to working with old twitter and socrates friend Benjamin Reitzammer.

And if you're in Frankfurt and want to grab a beer, please do let me know!

(Write up for week 2 is up now.)