I've had a draft post on Docker sitting in my in-tray for a couple of weeks now. The essence of the post is encapsulated in the related Trello card notes:
Having spent time working with Docker**, I've now got a much better (albeit still naive) understanding of what it is and how it works, and have switched focus. Phase one is now not running the app in development (runserver), but instead I'm going to work on getting a from-scratch test environment running.
The intention now is for the following Dockerfile setup:
- Copy requirements.txt into the container and run
- Copy the application directory into the container
- Entrypoint to run the tests inside the container
- Fabric task to combine the above into single
** I've got a base image that contains a bare bones python and ruby environment, with foreman installed, and then a Dockerfile that can be used to run the project Procfile through foreman. Works like a charm, but needs to be restarted to pick up changes, so for now is less practical than the current Vagrant setup.
Things moved on a little since that card was last edited, but the fact remained that Docker didn't really prove any better as a development environment for us than our (1GB) Vagrant image. What we seemed to be missing was something that allowed us to knit together all of our services (Postgres, Redis, Memcache, SMTP server etc.) and our application into a complete environment.
Something a lot like Fig, from Orchard. I'm happy to say that Orchard's Dockerfile for running a Python app looks remarkably like mine (almost line-for-line), which gives me some confidence that I was heading in the right direction (as they definitely do know what they're doing). However, it's the fig.yml file that holds the magic. This is the glue that pulls together all the services into a complete environment. (It's probably worth pointing out that others have pointed out that this is such a valuable piece of the Docker ecosystem that it's inevitable that Docker themselves will eventually roll something like Fig into their product. Perhaps, but if so it's only because people like Orchard are pushing forward so fast, so they deserve the kudos.)
I haven't yet given it a go, but we do have a new developer starting tomorrow, so I have 24 hours to get something up and running...
[Edit] In the interests of clarity - the reason we might want to use Docker, when we already have a scripted Vagrant development environment, is that we want to make setting up a new environment as smooth as possible for new developers, and as easy to upgrade as possible for existing developers. Hoicking a 1GB VM around is fine if you do it once, but not that practical to keep updating. (We also want the dev environment to match live as closely as possible - so whilst running the app on SQLite, and turning off all async queues, is possible, it's highly undesirable.)