We’ve been discussing a lot about Docker as a mean to build and expose Web applications, here is another way to use it as a native distribution package building tool.
You want to product deb and rpm package for applications written in Ruby, Nodes.js, Python… These technologies usually rely on specific packaging tools which need internet to work (gem for Ruby, npm for Node.js, pip or easy_install for Python).
Having a compiling chain or an internet access on a production server is bad for security reason so you must use a specific server.
It’s difficult to maintain different compiling chains on a single server. You have to manage different versions of different kinds of technologies. Moreover, provisioning a server just for that need has a cost you can’t always afford.
The solution is to use container. One container embeds one compilation chain. Docker can help you for that.
An other difficulty concerns the production of the rpm and deb packages. Some tools exist to do it simply like the Opscode’s Omnibus framework.
Our example combine Docker and Opscode’s Omnibus framework.
Let’s dig into more details by building a Capistrano package as a DEB (for Ubuntu Precise) and as a RPM (for Centos 6). Capistrano is a CLI Ruby application with some gems as prerequisites.