6

I plan to use docker to build my dev and production environment. I build Django based app.

On dev I use docker-compose to mange all local containers. It's a nice and convenient solution. I run Django, 3 celery queues, rabbitmq, 2 postgresql DBs.

But my production environment is quite different. I need to run gunicorn and nginx. Moreover DBs will be ran using AWS RDS. Of course Django app will require more stuff, like different settings file or more env vars.

I'm wandering how to divide it. Should I docker-compose there as well? That will require separate files for dev and prod, maybe more in future for staging etc... If yes, how to deploy it? Using Jenkins, pull, restart all using compose?

Or maybe I should use ansible to run docker commands directly? But then I have no confidence that my dev is the same as live and it's harder to predict its behaviour.

I like the idea of running compose files on all environments, but I'm not sure if maintaining multiple files for different environments is a good idea. Dev requires less env vars and less configuration. I can use env file to set all of them on production. But should I keep my live settings in the se repo? Previously I was setting all env vars while provisioning and this was separate process. Now it looks like provisioning and deploy are the same? Maybe this is the way with Docker?

nwinkler
  • 52,665
  • 21
  • 154
  • 168
tunarob
  • 2,768
  • 4
  • 31
  • 48
  • 2
    Ideally the only difference between Dev and Prod should be scale and access to data. Docker swarm can be run on EC2 which enables you to have the same workflow in production. If you're using RDS, then DB URL and credentials can be injected into the containers using environment variables. This can be simulated in Dev using database(s) running standalone within Docker containers. – Mark O'Connor Nov 15 '15 at 21:05
  • In the third project in a row I'm using separate files for each environment. – Opal Nov 16 '15 at 18:20

1 Answers1

10

Using http://docs.docker.com/compose/extends/#multiple-compose-files you can keep all the common stuff in a docker-compose.yml and use docker-compose.prod.yml to add extra services, change links, environment, and ports.

dnephin
  • 25,944
  • 9
  • 55
  • 45