From 5ac6ea56191a0abcf8f61d92a138f2705c63efba Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Sat, 2 Oct 2021 17:52:11 +0200 Subject: [PATCH 1/3] introduce top-level `name` Signed-off-by: Nicolas De Loof --- schema/compose-spec.json | 7 ++++++- spec.md | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/schema/compose-spec.json b/schema/compose-spec.json index 91bdb342..d15a3356 100644 --- a/schema/compose-spec.json +++ b/schema/compose-spec.json @@ -8,7 +8,12 @@ "properties": { "version": { "type": "string", - "description": "Version of the Compose specification used. Tools not implementing required version MUST reject the configuration file." + "description": "declared for backward compatibility, ignored." + }, + + "name": { + "type": "string", + "description": "define the Compose project name, until user defines one explicitly." }, "services": { diff --git a/spec.md b/spec.md index 1cc1681a..b1719168 100644 --- a/spec.md +++ b/spec.md @@ -49,6 +49,8 @@ A **Project** is an individual deployment of an application specification on a p resources together and isolate them from other applications or other installation of the same Compose specified application with distinct parameters. A Compose implementation creating resources on a platform MUST prefix resource names by project and set the label `com.docker.compose.project`. +Project name can be set explicitely by top-level `name` attribute. Compose implementation MUST offer a way for user to set a custom project name and override this name, so that the same `compose.yaml` file can be deployed twice on the same infrastructure, without changes, by just passing a distinct name. + ### Illustrative example The following example illustrates Compose specification concepts with a concrete example application. The example is non-normative. @@ -223,6 +225,12 @@ Compose implementations SHOULD validate whether they can fully parse the Compose because the Compose file was written with fields defined by a newer version of the specification, Compose implementations SHOULD warn the user. Compose implementations MAY offer options to ignore unknown fields (as defined by ["loose"](#Requirements-and-optional-attributes) mode). +## Name top-level element + +Top-level `name` property is defined by the specification as project name to be used if user don't se one explicitly. +Compose implementations MUST offer a way for user to override this name, and SHOULD define a mechanism to compute a +default project name, to be used only if the top-level `name` element is not set. + ## Services top-level element A Service is an abstract definition of a computing resource within an application which can be scaled/replaced From bb155bbf1f8931f94ba2baeec70a506a67e1d5bc Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Tue, 16 Nov 2021 08:49:16 +0100 Subject: [PATCH 2/3] document use of COMPOSE_PROJECT_NAME as env variable Signed-off-by: Nicolas De Loof --- spec.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index b1719168..3cff453b 100644 --- a/spec.md +++ b/spec.md @@ -227,9 +227,21 @@ SHOULD warn the user. Compose implementations MAY offer options to ignore unknow ## Name top-level element -Top-level `name` property is defined by the specification as project name to be used if user don't se one explicitly. +Top-level `name` property is defined by the specification as project name to be used if user doesn't set one explicitly. Compose implementations MUST offer a way for user to override this name, and SHOULD define a mechanism to compute a -default project name, to be used only if the top-level `name` element is not set. +default project name, to be used if the top-level `name` element is not set. + +Whenever project name is defined by top-level `name` or by some custom mechanism, it MUST be exposed for +[interpolation](#Interpolation) and environment variable resolution as `COMPOSE_PROJECT_NAME` + +```yml +services: + foo: + image: busybox + environment: + - COMPOSE_PROJECT_NAME + command: echo "I'm running ${COMPOSE_PROJECT_NAME}" +``` ## Services top-level element From 5862d82c8176b06a454ddb4085449f1bd277d8ef Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Sun, 28 Nov 2021 12:53:02 +0100 Subject: [PATCH 3/3] typo Signed-off-by: Nicolas De Loof --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 3cff453b..86eeb262 100644 --- a/spec.md +++ b/spec.md @@ -49,7 +49,7 @@ A **Project** is an individual deployment of an application specification on a p resources together and isolate them from other applications or other installation of the same Compose specified application with distinct parameters. A Compose implementation creating resources on a platform MUST prefix resource names by project and set the label `com.docker.compose.project`. -Project name can be set explicitely by top-level `name` attribute. Compose implementation MUST offer a way for user to set a custom project name and override this name, so that the same `compose.yaml` file can be deployed twice on the same infrastructure, without changes, by just passing a distinct name. +Project name can be set explicitly by top-level `name` attribute. Compose implementation MUST offer a way for user to set a custom project name and override this name, so that the same `compose.yaml` file can be deployed twice on the same infrastructure, without changes, by just passing a distinct name. ### Illustrative example