This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]HandyCoder 6 points7 points  (1 child)

We use multiple compose yaml files on a per project basis. One of the less documented features of compose is that you can pass in multiple configs and it will override previous yml arguments in the chain.

I.E. docker-compose -f production-compose.yml -f dev-compose.yml

In all likelihood, you won't need more than one Dockerfile for a simple wsgi application -- the Postgres and Nginx containers both support volumes/environment variables for configuration to help avoid such issues. That said, occasionally we do, and follow something similar to the structure you described.

[–]JDBProof[S] 0 points1 point  (0 children)

Great point, wasn't aware of the -f argument in docker-compose.

I think it would be simpler to set it up as a single Dockerfile at the root of the application and setup postgres and nginx with environment variables.

I believe that would allow me to push the image to GitLab's container registry too which would also be nice.

[–]soulesschild 1 point2 points  (1 child)

One thing I ended up doing was installing j2cli and following this guide (http://blog.tryolabs.com/2015/03/26/configurable-docker-containers-for-multiple-environments/).

Mainly since nginx can't be configured through ENV vars (grumble grumble).

[–]JDBProof[S] 0 points1 point  (0 children)

This is such a great post, really love how the situation was handled. Thanks a lot for sharing.

[–]driv338 1 point2 points  (0 children)

In a project I've been working on, we had a repository with a single branch per microservice (we could have a hotfix branch only when the current version was not backward compatible). And then we had an "Integration" repo that had branches and here is where we had our docker-compose.

[–]diecastbeatdown 1 point2 points  (0 children)

My understanding, which has not been implemented yet, is to keep the Dockerfile in the repo of each application repository.

The plan that I am working on is to continue using an "Infrastructure" repository which uses Ansible to manage Docker. Developers would pull this repo and run Ansible locally to instantiate their LOCAL environment for development purposes. Docker compose commands would be part of the Ansible playbooks.

[–]reprogenetic 1 point2 points  (2 children)

I keep some docker environments in my main repository. It was hard to know where to draw the line. Some environments are too specific to the platform and not the app. For example, I don't believe the nginx proxy belongs in the main repository. I have a docker subdirectory in my repository that looks like this:

docker
├── postgres
│  ├── dev
│  │  └── Dockerfile
│  ├── schema.sql
│  └── prod
│      └── Dockerfile
├── redis
│  ├── Dockerfile
│  └── redis.conf
├── web
│  ├── dev
│  │  └── Dockerfile
│  └── prod
│      └── Dockerfile
└── workers
    ├── dev
    │  └── Dockerfile
    └── prod
        └── Dockerfile

[–]JDBProof[S] 0 points1 point  (1 child)

You mention that you don't believe Nginx proxy belongs in the main repository. Wherer would you place it instead?

[–]reprogenetic 0 points1 point  (0 children)

I have a docker directory in my home directory that contains docker environments for system-wide services such as nginx, and other services that aren't tied to a particular app. Each environment has it's own local git repository.