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
Add project-name
option to compose schema
#106
Comments
@ndeloof @chris-crone @nebuk89 @EricHripko need your advice on this issue. |
I'm +1 for this |
I absolutely ❤️ this idea because it's benefits both users and tooling built on top of Compose spec:
IMO, the latter is especially useful for inexperienced users since integrations might create additional services to go into the local setup. This confuses such users when they attempt to use plain Compose tooling and get orphan warnings. |
Summarizing the notes from the community meeting last week:
|
just override the name by |
that's also a valid option. For flexibility and backward compatibility docker-compose could write such a file if it didn't existed on |
+1 for this |
Could you elaborate on this @chris-crone?
Is the suggested mitigation to generate object names with directory + project name + object name? Or is this talking about attaching some extra metadata to the object? |
@EricHripko it would be extra metadata, something like what docker-compose does already with the working_dir label:
|
@chris-crone when adding the (absolute) project path to object identifiers what would be the expected behavior in the following case:
I would argue, the user expects the running services to be stopped by this (as it is the current behavior). Also not knowing why this doesn't work the user would have "no" clean way to stop the already running services using But this - again - is not specific to this proposal but a problem we already have/would add by adding the current path to the object identifiers. |
for these
These are already issues if you use a standard directory structure like I think this is really for local development, I really can't think of other use cases. I really wouldn't want to mix the parent directory into that, but would be fine with that behaviour being configurable, but it feels like its getting pretty clunky pretty quickly. Maybe either-or, or changing the parent dir to use, this is about the smoothest I can think of without introducing another configuration option. version: "3"
project-name: "my_custom_project" | "." [default] | "../" # use parent dir |
and to add my 2¢: regarding docker/compose#745 (comment)
Since the error-proneness of Because this would solve the issue but at the same time would allow the user to opt-in to # use $COMPOSE_PROJECT_NAME if set or fallback to static project name
project_name: ${COMPOSE_PROJECT_NAME:-my_custom_project} |
@chris-crone, looks like a very reasonable approach 👍 Is the suggestion to use this label as a filter for selecting stack objects or as just a verification mechanism? @acran, "changing project path" workflow seems like something that wouldn't happen very often and it could possibly be solved in tooling? Compose implementations could error out with "path mismatch" message, but have a flag to override this behaviour. What do you think? @rijnhard I agree with your general sentiment that "parent directory" approach isn't ideal 🙈 |
👍 this would make it transparent to the user what is happening, why and how to solve this |
additionally I would propose to automatically import project_name into any containers built from given docker-compose file |
@wibed can you explain this with an example use case? |
@acran au contraire: renaming the project should result in a new container and not reference a build with a discarded purpose |
@wibed yes, it should rename the container/allow multiple separate instances of the same project with different names. But: I don't think these containers should have different behavior based on the project name. Rather this should be controlled by environment variables or configuration files. |
@thaJeztah raised to me that he still thinks adding it to the |
@acran could you elaborate what you meant with "different behaviour" further? |
@wibed I was referring to
I understand "import project_name into containers" as making the current if [ "$COMPOSE_PROJECT_NAME" = myapp_prod ]; then
./myapp --prod
else
./myapp --dev
fi With such an application simply changing the name of the directory containing the And even using the So, however you want to import the But maybe you meant it a completely other way or see another way of implementing. That's why I asked if you can provide an example use case in case there is something I don't quite understand correctly right now^^ |
so far, this is how i am calculating project name: func projectName(file string) (pn string) {
pn = os.Getenv("COMPOSE_PROJECT_NAME")
if pn != "" {
return pn
}
fileAbs, err := filepath.Abs(file)
if err != nil {
log.Fatal(err)
}
dir := filepath.Dir(fileAbs)
return filepath.Base(dir)
} i would prefer that this module provides it out of the box |
@ndeloof but it's not exposed. Right? |
Fixed by #206 |
Many docker-compose users have asked to have the option of defining the project name via a
project-name
field in the compose file, linked issue: docker/compose#745docker/compose#745 (comment)
Can we add this property to the compose schema? What is your advice on this topic?
The text was updated successfully, but these errors were encountered: