compose icon indicating copy to clipboard operation
compose copied to clipboard

Support defining profiles on includes

Open jalaziz opened this issue 1 year ago • 2 comments

Description

The ability to "include" a compose file into a parent file is incredibly powerful for supporting modular compose configurations. However, a key missing feature is the ability to add a global profile to the included file from the parent compose file.

Our use case is having multiple the ability to split a super compose file into separate child compose files, but allowing control over which child compose files are started by default. For example, we have a parent compose file that spins up most of the stack needed for resting. However, we have a separate compose file for the components related to our internal dashboard (this includes frontend, backend, and agent services). We would like the ability to optionally start the dashboard services from the main compose file when needed.

While we could define the profile on services in the "child" compose file, this is not desirable as then the child compose file can no longer be independently used without always starting the profile.

The ideal solution would be to add profiles as a configuration key alongside path under include and automatically extend all services from the included configuration with the defined profiles.

jalaziz avatar Nov 15 '24 05:11 jalaziz

IIUC you'd like to have an optional dashboard.yaml included as you run docker compose --profile dashboard up Can't you just run explicitly this sibling compose file as docker compose -f compose.yaml -f dashboard.yaml up ?

ndeloof avatar Nov 15 '24 08:11 ndeloof

Can't you just run explicitly this sibling compose file as docker compose -f compose.yaml -f dashboard.yaml up ?

Sure, but there may be many such things and the ergonomics of knowing and discovering what you can use can be complicated (e.g. dashboard.yaml could be in some nested subfolder). Also, things get extra complicated if we want to have services in compose.yaml that potentially depend on services within dashboard.yaml but are all started under the same profile.

jalaziz avatar Nov 16 '24 00:11 jalaziz