Using Docker in Production

Posted November 21, 2015

I have been using Docker since the beginning of this project and has worked out well so far. The last project I did we used the same Rails stack running on an EC2 instance and that was built with Chef using the chef knife commands. I wasn’t a big fan of chef and it was tough to use and mainly targeted the enterprise.

A little bit about GDEOnline. It is a companion platform for Game Data Editor. You would use Game Data Editor to create your schemas (definitions of your data). That outputs a JSON file that gets pulled into your game at runtime. You would use GDEOnline to host your JSON file and magically your data gets pulled in at runtime from the cloud and is usable in your game via the class methods that you normally would use.

So the GDEOnline website is going to be where a user can upload their datasets for their games. This can easily be used for other software too, not just games. The website consists of a Rails stack with a Javascript frontend.

Docker replaces all the server building/provisioning pieces. Given a Dockerfile, which is a list of commands saying what to add to the box, it outputs an image file that I can push to AWS ECS (EC2 Container Service). That image gets run by Amazon, I point DNS to the container & viola done!

My build setup consists of an Ubuntu box with users for staging and production. So I login to the box as the staging user, pull the code, and run a script to kick off the build. The environment variables are different for staging and production so having two separate users worked out well. For now this is repeatable and stable so far.

Here I timed the step where it’s building the Docker image which is the meat of the build. I updated the RAM in the box from 4GB to 16GB and halfed the build times ~10min down to ~5.

I really want to keep this time down to a minimum. When the site crashes and burns for whatever reason it should only take me about 5 min to make a new build. I will have my previous good image around in the docker cache but in the case everything gets hosed building from scratch is still viable.

If you’re putting together a site or building a server box for whatever task Docker is simple to use, powerful and mostly just works which is the part I like the best.