Docker-sync: Multiple docker-compose configuration files

Created on 10 Aug 2016  路  4Comments  路  Source: EugenMayer/docker-sync

I wanted to drop a little question in here, I see the configuration override setup is using configuration values for 2 docker-compose files. The options I mean are 'compose-file-path' and 'compose-dev-file-path'.

This will be sufficient in most cases, but docker-compose itself supports adding more configuration files than 2. We use this to have a default setup for docker environments in a git submodule, and then use an override file for a specific project. In this setup we need a 3rd docker-compose file to allow custom configuration for a developer.

Currently we've a set of shell scripts that check if the 3rd file exists yes / no and builds the docker-compose command to execute.

I am now testing if docker-sync would be feasible to fix the performance issues with docker on mac, but the limitation of just 2 configuration files would be problematic to us. Is it in some way possible to pass an extra option? Or to extend the 'compose-dev-file-path' option to allow a list of files (that are only added to the docker-compose command if the file exists)?

question

Most helpful comment

There's already overriding happening in docker-sync-stack, with the compose-dev-file-path option though. Could that argument be instead generalized to use take multiple overrides and run them in order? Something like:

compose-override-paths:
  - '/path/to/foo.yml'
  - '/path/to/bar.yml'

That would still cover the normal use case for the single sync override, but would also allow more flexibility in cases like this.

All 4 comments

Docker-Sync is split into 2, maybe 3 parts. Sync, Stack (Compose starter), and compose itself.

To achieve what you need, you have 2 options:

_a) Scaffolding_
That is what we do at our company. We call those variations, so for specific features we start use something like thor docksync:start --php7 --specialfeature
Both of those options end up passing a additional compose-file to the docker-compose gem. In general, scaffolding is described here https://github.com/EugenMayer/docker-sync/wiki/7.-Scripting-with-docker-sync

What you end up is calling docker-compose manually, using a list of files you decided to be the docker-compose files like here files=> compose_files https://github.com/EugenMayer/docker-sync/blob/master/lib/docker-sync/compose.rb#L40

So what you do is:
writing a thor/rake task (i would use thor) and include docker-sync as a library, then start the sync like described in scripting and implement some custom logic to select the docker-compose files you want based on the thor-options the user passed on.
That sounds like work, yes it is, but no matter what you will do, you have to implement your custom logic. Docker-Sync is about sync, not about being a development-all-in-one solution with any kind of stuff in it. Though, as told you above, we are ourself using docker-sync as a library in a tool handling the special docker-compose file variants.

b) Use docker-sync start (not docker-sync-stack start which will start compose automatically) and after that, use docker-compose -f docker-compose.yml -f docker-compose-dev.yml -f docker-compose-variantA.yml in a second console - or you the script you are using right now, to start up the compose stack.

Hope that helps, you basically are free to do what you have done before by using b) or try to completely automate the start using a)

Thanks for the info ;-) By quickly scanning the code / docs I assumed docker-sync start also used those variables, but as b is possible I can just do that.

There's already overriding happening in docker-sync-stack, with the compose-dev-file-path option though. Could that argument be instead generalized to use take multiple overrides and run them in order? Something like:

compose-override-paths:
  - '/path/to/foo.yml'
  - '/path/to/bar.yml'

That would still cover the normal use case for the single sync override, but would also allow more flexibility in cases like this.

@zxaos I don't know if this is still relevant to you, however, I was looking for the same and this seems to be covered by #222 since early this year 馃帀.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EugenMayer picture EugenMayer  路  9Comments

markglenn picture markglenn  路  7Comments

donnykurnia picture donnykurnia  路  8Comments

b1alpha picture b1alpha  路  7Comments

YouriT picture YouriT  路  4Comments