From 514e3fce22d6c564831605677c45ec1564d803fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 26 Apr 2022 14:11:26 +0100 Subject: [PATCH 1/2] fix: compose error on "dev --mount=learning:..." When mounting a directory in a dev-only container, such as the "learning" mfe, docker-compose is failing because it is attempting to run "docker-compose stop" in the local context -- which knows nothing about the learning container. To resolve this, we store tmp volumes either in the local or dev docker-compose.yml, and load either one depending on the context. --- CHANGELOG.md | 1 + tutor/commands/compose.py | 1 + tutor/commands/dev.py | 3 ++- tutor/commands/local.py | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f7ba17..8017c6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Fix] "The Compose file is invalid" error on mounting dev-only folders. - [Fix] CMS settings in development. ## v13.2.0 (2022-04-24) diff --git a/tutor/commands/compose.py b/tutor/commands/compose.py index ea2c0a3..53c0791 100644 --- a/tutor/commands/compose.py +++ b/tutor/commands/compose.py @@ -19,6 +19,7 @@ class ComposeJobRunner(jobs.BaseComposeJobRunner): self.project_name = "" self.docker_compose_files: t.List[str] = [] self.docker_compose_job_files: t.List[str] = [] + self.docker_compose_tmp_path = "" def docker_compose(self, *command: str) -> int: """ diff --git a/tutor/commands/dev.py b/tutor/commands/dev.py index a3778cb..184b99b 100644 --- a/tutor/commands/dev.py +++ b/tutor/commands/dev.py @@ -18,10 +18,11 @@ class DevJobRunner(compose.ComposeJobRunner): """ super().__init__(root, config) self.project_name = get_typed(self.config, "DEV_PROJECT_NAME", str) + self.docker_compose_tmp_path = tutor_env.pathjoin(self.root, "dev", "docker-compose.tmp.yml") self.docker_compose_files += [ tutor_env.pathjoin(self.root, "local", "docker-compose.yml"), tutor_env.pathjoin(self.root, "dev", "docker-compose.yml"), - tutor_env.pathjoin(self.root, "local", "docker-compose.tmp.yml"), + self.docker_compose_tmp_path, tutor_env.pathjoin(self.root, "local", "docker-compose.override.yml"), tutor_env.pathjoin(self.root, "dev", "docker-compose.override.yml"), ] diff --git a/tutor/commands/local.py b/tutor/commands/local.py index f731049..5adda36 100644 --- a/tutor/commands/local.py +++ b/tutor/commands/local.py @@ -20,10 +20,11 @@ class LocalJobRunner(compose.ComposeJobRunner): """ super().__init__(root, config) self.project_name = get_typed(self.config, "LOCAL_PROJECT_NAME", str) + self.docker_compose_tmp_path = tutor_env.pathjoin(self.root, "dev", "docker-compose.tmp.yml") self.docker_compose_files += [ tutor_env.pathjoin(self.root, "local", "docker-compose.yml"), tutor_env.pathjoin(self.root, "local", "docker-compose.prod.yml"), - tutor_env.pathjoin(self.root, "local", "docker-compose.tmp.yml"), + self.docker_compose_tmp_path, tutor_env.pathjoin(self.root, "local", "docker-compose.override.yml"), ] self.docker_compose_job_files += [ From 1a4c904d7f2b1473a56b9972225f43fcdf67ec72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 26 Apr 2022 14:21:18 +0100 Subject: [PATCH 2/2] fix: formatting --- tutor/commands/dev.py | 4 +++- tutor/commands/local.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tutor/commands/dev.py b/tutor/commands/dev.py index 184b99b..46f500e 100644 --- a/tutor/commands/dev.py +++ b/tutor/commands/dev.py @@ -18,7 +18,9 @@ class DevJobRunner(compose.ComposeJobRunner): """ super().__init__(root, config) self.project_name = get_typed(self.config, "DEV_PROJECT_NAME", str) - self.docker_compose_tmp_path = tutor_env.pathjoin(self.root, "dev", "docker-compose.tmp.yml") + self.docker_compose_tmp_path = tutor_env.pathjoin( + self.root, "dev", "docker-compose.tmp.yml" + ) self.docker_compose_files += [ tutor_env.pathjoin(self.root, "local", "docker-compose.yml"), tutor_env.pathjoin(self.root, "dev", "docker-compose.yml"), diff --git a/tutor/commands/local.py b/tutor/commands/local.py index 5adda36..a26ee07 100644 --- a/tutor/commands/local.py +++ b/tutor/commands/local.py @@ -20,7 +20,9 @@ class LocalJobRunner(compose.ComposeJobRunner): """ super().__init__(root, config) self.project_name = get_typed(self.config, "LOCAL_PROJECT_NAME", str) - self.docker_compose_tmp_path = tutor_env.pathjoin(self.root, "dev", "docker-compose.tmp.yml") + self.docker_compose_tmp_path = tutor_env.pathjoin( + self.root, "dev", "docker-compose.tmp.yml" + ) self.docker_compose_files += [ tutor_env.pathjoin(self.root, "local", "docker-compose.yml"), tutor_env.pathjoin(self.root, "local", "docker-compose.prod.yml"),