Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple Docker compose files #7

Open
wilkko opened this issue Apr 29, 2016 · 9 comments
Open

Support for multiple Docker compose files #7

wilkko opened this issue Apr 29, 2016 · 9 comments

Comments

@wilkko
Copy link

wilkko commented Apr 29, 2016

Sometimes multiple Docker compose files form a hierarchy to avoid duplication as described here https://docs.docker.com/compose/extends/

We for example have

  • docker-compose.yml
  • docker-compose.override.yml
  • docker-compose-ci.yml
  • docker-compose-deploy.yml

First two are used when running the application locally. Files contain sensible default configuration (for example ports or application properties) and contain no variables to substitute. The last two files serve special purposes in the CD pipeline and either add, override or use the configuration from the first file.

Application is deployed to Swarm with command:
docker-compose -f docker-compose.yml -f docker-compose-deploy.yml up -d

Locally you can just run:
docker-compose up -d

@vfarcic
Copy link
Owner

vfarcic commented Apr 30, 2016

I had a bad experience using multiple compose files in the docker-compose up command. Instead, in cases when it was appropriate to have multiple compose files, I tend to specify only one as part of the docker-compose up command and include targets from other files inside it (e.g. extends > file).

So, following your example, application would be deployed to Swarm with:

docker-compose -f docker-compose-deploy.yml up -d

The docker-compose-deploy.yml would extend/modify services it needs with extends: followed by file:.

Before we start adding this feature, I'd appreciate if I could get a bit more info on your use case and motivations behind using multiple compose files specified with the -f argument instead using extends inside the compose file. Can you share compose files you're using?

@wilkko
Copy link
Author

wilkko commented Apr 30, 2016

Motivation was to avoid duplication. We seem to have some Spring boot application properties in the command sections. Maybe due to bad design elsewhere but they are environment specific (Datasource settings, API keys etc.) so they belong to compose files.

I'll see if I can clean up the compose files for sharing. I can also see how multiple files add complexity and should probably concider moving back to single file.

@vfarcic
Copy link
Owner

vfarcic commented Apr 30, 2016

I also often have multiple compose files. The difference is that I tend to use only one of them when running docker-compose. If that file needs targets from another, I include it through extends.

Please note that I am not against adding the support for your use case. I'd just like to understand better the use case. Feel free to replace sensitive data in your compose files with some random values before sending them.

@wilkko
Copy link
Author

wilkko commented Apr 30, 2016

I guess the worst part of multiple files per for compose up approach is that you cannot always easily see how compose is going to merge those services.

@vfarcic
Copy link
Owner

vfarcic commented Apr 30, 2016

That was one of my problems, besides errors caused by the incorrect order of files specified in docker-compose up. Also, I had situations when people add or modify a target inside one file not understanding that it will affect the other. Many of those (and other) problems exist with one file per docker-compose up command but, at least, it is easier to open it and follow the logic.

@wilkko
Copy link
Author

wilkko commented Apr 30, 2016

I don't have access to codes during the weekend so cannot post those examples yet. I wanted to try out blue green deployment this week but that multiple compose file issue prevented me.

Off topic but I did not find any installation instructions for Docker-flow. Is the recommendation just to wget it to the build slave, make it executable and fire? Can the binary be used within a container?

@vfarcic
Copy link
Owner

vfarcic commented Apr 30, 2016

Docker Flow is a single binary (just like docker-compose). As long as it's executable, there's nothing else to do. I can put it inside an alpine container but I'm not sure there is a benefit in doing that.

However, you might benefit from making a container with docker-flow that would be specific to your use case. It can, for example, contain environment variables (e.g. proxy IP), docker-flow.yml, and so on. Besides having a single binary, the purpose would be only for storing configuration.

@wilkko
Copy link
Author

wilkko commented Apr 30, 2016

Ok, additional benefits in managing the binary within container is that Docker takes care of downloading, upgrading versions, cleaning up etc. and the build slave are kept simple. I also avoid changing our Puppet managed build slaves until they are migrated to Ansible.

@vfarcic
Copy link
Owner

vfarcic commented Apr 30, 2016

I'll make it soon (#8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants