docksal / docksal

Unified, Docker 🐳 powered web development environments for macOS, Windows, and Linux
https://docksal.io
MIT License
688 stars 179 forks source link

Allow custom compose configuration and env files to be loaded per-project #1558

Open lpeabody opened 3 years ago

lpeabody commented 3 years ago

Feature request

Conversation driving request originates from https://github.com/docksal/docksal/pull/1557#issuecomment-907683694.

Summary

Be able to load in additional docker-compose configuration and env files in addition to docksal.yml, docksal.env, docksal-environment.yml and docksal-environment.env. These additional files would be chained in between Docksal's core configuration and environment files, the project's docksal.yml and docksal.env files, but before the environment specific files.

lpeabody commented 3 years ago

Use case copied from PR linked in summary:

@lpeabody Something like #2 sounds like it'd work great. I also had seen the documentation for docker-compose to allow for multiple configuration files, so I think that sounds great!

In my specific use case, our organization has a great many Drupal properties. which use Docksal for local development. These Drupal properties are mostly different enough to need their own unique configurations (their own custom docksal-local.yml), but there are common, shared tools that all properties utilize. A single team manages those shared tools. Currently, when a shared tool is implemented/updated, the Necessary Docksal updates to configuration have to be manually completed for each property, even though we also have the same team's non-docksal infrastructure updates ingested automatically to each property and built via composer. If we could have a separate docksal-configuration.yml file, each project would get the updates on a regular composer update, removing the manual updates.

I'll go one step further to demonstrate the need, even though that paragraph may have been enough—I have explored patching the docksal-local.yml files on composer install as a post script, but being that it's a .yml file, I can't rely on updates being appended under the correct properties. I say this just to demonstrate that altering an existing file doesn't seem feasible, causing us to look for a way to include a separate file.

ryanissamson commented 3 years ago

Thanks for opening this, @lpeabody. So far, we'd discussed that docker-compose compose supports multiple configuration files by stringing together files, e.g. docker-compose -f ~/.docksal/stacks/services.yml -f ~/.docksal/stacks/stack-acquia.yml -f ./project/.docksal/docksal.yml -f ./project/.docksal/docksal-local.yml

Ideally, Docksal would support one or more configuration files beyond the -local env and yml files. Furthermore, if it could do so without having to specify them in a command, that'd allow project maintainers to just inherit custom configuration updates without needing to modify scripts or commands. For example, if docksal-local.yml is automatically picked up, then being able to name a configuration file in a predictable way, docksal-local-overrides.yml or being able to define override files to in docksal.env. You had indicated that the -local.yml file should take priority, which I'm fine with as well.