Deploying Apps to Heroku with Docker
Yesterday Heroku released beta support to build and deploy Heroku apps with Docker. It would be an understatement to say that this created quite a bit of buzz with the Appirio and topcoder communities. We are big fans of Docker and have been promoting it for all types of uses, blogging about it and using it for topcoder challenges. With so many developers on the topcoder platform (750,000+), Docker mitigates environment issues involved with launching challenges, evaluating submissions and putting code into production.
Since Heroku has their own LXC container technology, we didn’t expect them to adopt Docker this soon… if at all. We are super-excited to see Heroku starting to support Docker! The service is still beta, only supporting Node.js and Ruby for now (more languages to come), but looks promising.
The announcement blog post does a good job of walking you through the new functionality but assumes that you have a strong grasp of Docker and your installation is up to date. A number of my teammates had issues with Docker Hub and getting their containers to run on Heroku but these are Docker problems, not Heroku’s.
If you are new to Docker and running OSX, try installing Kitematic or use this page to install Docker and Boot2Docker. You can download Docker for other platforms here. If you already have a version of Docker installed, I would highly recommend that you upgrade your client and server. You’ll probably need to update your virtual machine as well so check out these instructions. It’s pretty simple.
With everything installed/updated you should be able to run boot2docker up
which will fire up Docker and your VM. Now you’re all set to follow Heroku’s blog post to deploy your container to their platform.
Heroku’s Docker toolbelt plugin makes dockerizing apps a breeze. You can run heroku docker:init
in your app’s directory and the CLI will try to detect what language and framework is used for your app and in what versions, and write the appropriate Dockerfile for you! Feel free to make modifications and rebuild your images as necessary.
A simple heroku docker:start
fires up your app locally in the virtual machine and returns an accessible IP address. You can then do all sorts of crazy stuff like installing dependencies with `heroku docker:exec and modifying your app in real-time against the virtual machine (it mounts a working directory) before deploying to Heroku.
Once again, Heroku has made deployment a snap. When you run heroku docker:release
, the CLI will create a slug from your local Docker image and deploy it to Heroku. You can still use git push
as well if you like watching the buildpack logs. Who doesn’t?!
Overall, this is a good start. I’m not sure how much I like the being forced into Heroku’s /app
structure but I can understand the need for it. It will be exciting to see how their support progresses in the near term. Over the past six months Heroku has made it much simpler to deploy apps with options from github and Dropbox and now Docker!