Jenkins + Docker = nimble and cost-friendly Continuous Integration

By now you’ve heard all of the hype around Docker. No doubt you have begun forming your own opinion on whether that hype is deserved. (If you’re lacking in opinions, no doubt Reddit can help you find one.)

Conversely, I hope one thing all Engineering teams can agree on is the need for Continuous Integration testing. If your team is not employing a CI by now – there really is no excuse other than just bad engineering practices. With platforms like Jenkins available as open source and the wide-spread availability of cheap hosting solutions, what again was your Lead Engineer’s reasoning for not maintaining a current CI?

When it came time to setup yet another Jenkins-based CI for a Rails web application, I just had to see if I could dockerize the server installation to take advantage of all that Docker has to offer. I am happy to say that the results were particularly fruitful and I can now setup a new Jenkins container via a service like Tutum (backed by DigitalOcean, AWS, etc.) in just minutes.

I’ve rolled up the dockerfile into a repo here: https://github.com/alexagranov/jenkins-ansible-docker

The dockerfile of interest is the one in the images/jenkins-custom directory.

It offers:
– server based on Ubuntu 14.04
– latest Jenkins
– git-lfs (large-file support)
– RVM
– Ruby 2.1.5 (via RVM)
– Firefox – for Selenium-based tests
– Xvfb – for headless Firefox
– Postfix – for email notification

I’ve also included a sample job execution script in the Readme.md that demonstrates how to juggle a few environment variables.

If your application requires Redis and/or a Database, don’t forget the Docker paradigm calls for those services to run in their own containers.

Enjoy!