Skip to content

introduce include to depend on another compose file#363

Merged
ndeloof merged 1 commit intocompose-spec:masterfrom
ndeloof:require
Jun 22, 2023
Merged

introduce include to depend on another compose file#363
ndeloof merged 1 commit intocompose-spec:masterfrom
ndeloof:require

Conversation

@ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Jun 8, 2023

What this PR does / why we need it:
introduce include to depend on another compose file
this will allow to modularize complex compose file, share some common definition with other teams, and also resolve issue for users to extend a compose file from a distinct folder

Which issue(s) this PR fixes:
illustrated by compose-spec/compose-go#416
closes docker/compose#318 after ... 9 years ! 😅

@ndeloof ndeloof force-pushed the require branch 3 times, most recently from 68ab3a7 to 318a09e Compare June 8, 2023 15:54
Copy link
Member

@milas milas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot, in particular the long syntax will be very helpful for complex projects, I imagine!

Made a couple tiny suggestions for clarification/precision and I think we need a bit more clarification on paths

@ndeloof
Copy link
Collaborator Author

ndeloof commented Jun 12, 2023

long syntax indeed let us introduce way much advanced features in the future to address complex usages, like includes/excludes/rename or any sort of such conflict resolution logic.

@ndeloof ndeloof force-pushed the require branch 2 times, most recently from 4800534 to 559dfd5 Compare June 13, 2023 18:07
@ndeloof ndeloof changed the title introduce require to depend on another compose file introduce include to depend on another compose file Jun 13, 2023
@ndeloof ndeloof changed the title introduce include to depend on another compose file introduce import to depend on another compose file Jun 14, 2023
Copy link
Contributor

@ulyssessouza ulyssessouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one important thing to mention here is the order in what -f files and compose.override.yml are merged (which already exists) and when the imports are evaluated.

Also maybe turn it explicit the recursive nature of the import. Because if we import a file that has imports, we need to evaluate those before integrating in the final project. And obviously manage circular dependency.

@ndeloof
Copy link
Collaborator Author

ndeloof commented Jun 15, 2023

@ulyssessouza good point, added to #363

About circular references, the compose specification doesn't define such rule for extends not depends_on while those are actually implemented in Docker Compose. We could look into this in a separate PR

@ulyssessouza ulyssessouza self-requested a review June 15, 2023 10:41
@ndeloof ndeloof changed the title introduce import to depend on another compose file introduce include to depend on another compose file Jun 21, 2023
@ndeloof
Copy link
Collaborator Author

ndeloof commented Jun 21, 2023

@ulyssessouza comments have been addressed, can you please retrace request for change so I can merge ?

Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can apply those few changes I think we're ready to go!!!

Copy link
Member

@milas milas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clarifications to the spec. I think the JSON schema needs a couple tiny fixes but LGTM otherwise!

@reddec
Copy link

reddec commented Jul 11, 2023

May I ask for clarification?
In the case of a default network (ie, not defined explicitly), all services will share the network space unless changed by the - networks parameter, right?

Example:

foo/docker-compose.yaml:

services:
  foo:
    image: busybox

bar/docker-compose.yaml:

services:
  bar:
    image: busybox

docker-compose.yaml:

include:
- foo/docker-compose.yaml
- bar/docker-compose.yaml

bar and foo services will share the same default network and should be to communicate with each other (including hostname links).

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

Successfully merging this pull request may close these issues.

feature: including external docker-compose.yml

6 participants