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 multiple docker-compose files #90

Open
davenuman opened this issue Mar 31, 2020 · 2 comments
Open

Support multiple docker-compose files #90

davenuman opened this issue Mar 31, 2020 · 2 comments
Assignees

Comments

@davenuman
Copy link
Contributor

Currently only the docker-compose.yml file is supported and if other docker-compose files exist in a project, they are ignored.

See also fd9aee2

@davenuman davenuman self-assigned this Apr 24, 2020
@davenuman
Copy link
Contributor Author

Here are my thoughts for expected usage:

$ # example 1
$ COMPOSE_FILE="docker-compose.yml:docker-compose.test.yml"
$ . activate
Bowline activated.
Commands added to shell: "test"
$ alias test
alias test='COMPOSE_FILE="docker-compose.yml:docker-compose.test.yml" docker-compose run --rm test test'
$
$ # example 2
$ unset COMPOSE_FILE
$ . activate
Bowline activated.
Commands added to shell: "test"
$ alias test
alias test='COMPOSE_FILE="docker-compose.yml" docker-compose run --rm test test'

Also, one could add a export COMPOSE_FILE line to the project's activate script or source an env file which exports it for a consistent set of docker-compose files that are read by bowline.

@davenuman davenuman changed the title Support other docker-compose files Support multiple docker-compose files Apr 27, 2020
@grugnog
Copy link
Member

grugnog commented May 22, 2020

@davenuman a couple of thoughts:

  • Supporting COMPOSE_FILE sounds like a good start, but some projects might want only persistent services in context, so that docker-compose up doesn't start random dev/test commands. Technically this is possible, but you would need to change the value of COMPOSE_FILE in the activate script after bowline runs, which seems a bit complex.
  • I was thinking it might be good to have some separate variable, perhaps BOWLINE_COMPOSE_FILE which, iff set, is used instead of the COMPOSE_FILE variable. BOWLINE_COMPOSE_FILE could of course include COMPOSE_FILE by reference, if the project wanted to supplement COMPOSE_FILE).
  • It might also be interesting to allow this to support masks (for example docker-compose.test.*.yml) so that compose files could be added/removed without needing to update the list - this would sacrifice sort control (if used), but I think that is really more of a factor with services than commands.

So I think it would behave like this:

$ COMPOSE_FILE="docker-compose.yml:docker-compose.test.yml"
# In this case, lets say the project just wants to extend the COMPOSE_FILE list, so it is included, like with $PATH
$ BOWLINE_COMPOSE_FILE="${COMPOSE_FILE}:docker-compose.cli.*.yml"
$ ls docker-compose.cli.*.yml
docker-compose.cli.foo.yml
docker-compose.cli.bar.yml
$ . activate
Bowline activated.
Commands added to shell: "test,foo,bar"
$ alias test
alias test='COMPOSE_FILE="docker-compose.yml:docker-compose.test.yml:docker-compose.cli.foo.yml:docker-compose.cli.bar.yml" docker-compose run --rm test test'
$ alias foo
alias foo='COMPOSE_FILE="docker-compose.yml:docker-compose.test.yml:docker-compose.cli.foo.yml:docker-compose.cli.bar.yml" docker-compose run --rm foo foo'
$ alias bar
alias bar='COMPOSE_FILE="docker-compose.yml:docker-compose.test.yml:docker-compose.cli.foo.yml:docker-compose.cli.bar.yml" docker-compose run --rm bar bar'

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