Skip to content

Commit

Permalink
now calls docker-compose-config.bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Mar 21, 2023
1 parent b4304b6 commit 3be0dbd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/pytest-simcore/src/pytest_simcore/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def env_file_for_testing(
@pytest.fixture(scope="module")
def simcore_docker_compose(
osparc_simcore_root_dir: Path,
osparc_simcore_scripts_dir: Path,
env_file_for_testing: Path,
temp_folder: Path,
) -> dict[str, Any]:
Expand All @@ -155,6 +156,7 @@ def simcore_docker_compose(

compose_specs = run_docker_compose_config(
project_dir=osparc_simcore_root_dir / "services",
scripts_dir=osparc_simcore_scripts_dir,
docker_compose_paths=docker_compose_paths,
env_file_path=env_file_for_testing,
destination_path=temp_folder / "simcore_docker_compose.yml",
Expand Down Expand Up @@ -205,6 +207,7 @@ def inject_filestash_config_path(
@pytest.fixture(scope="module")
def ops_docker_compose(
osparc_simcore_root_dir: Path,
osparc_simcore_scripts_dir: Path,
env_file_for_testing: Path,
temp_folder: Path,
inject_filestash_config_path: None,
Expand All @@ -224,6 +227,7 @@ def ops_docker_compose(

compose_specs = run_docker_compose_config(
project_dir=osparc_simcore_root_dir / "services",
scripts_dir=osparc_simcore_scripts_dir,
docker_compose_paths=docker_compose_path,
env_file_path=env_file_for_testing,
destination_path=temp_folder / "ops_docker_compose.yml",
Expand Down
21 changes: 11 additions & 10 deletions packages/pytest-simcore/src/pytest_simcore/helpers/utils_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def get_service_published_port(

def run_docker_compose_config(
docker_compose_paths: Union[list[Path], Path],
scripts_dir: Path,
project_dir: Path,
env_file_path: Path,
destination_path: Optional[Path] = None,
Expand Down Expand Up @@ -131,26 +132,26 @@ def run_docker_compose_config(
# SEE https://docs.docker.com/compose/reference/

global_options = [
"--project-directory",
"-p",
str(project_dir), # Specify an alternate working directory
]
# https://docs.docker.com/compose/environment-variables/#using-the---env-file--option
global_options += [
"-e",
str(env_file_path), # Custom environment variables
]

# Specify an alternate compose files
# - When you use multiple Compose files, all paths in the files are relative to the first configuration file specified with -f.
# You can use the --project-directory option to override this base path.
for docker_compose_path in docker_compose_paths:
global_options += ["--file", os.path.relpath(docker_compose_path, project_dir)]

# https://docs.docker.com/compose/environment-variables/#using-the---env-file--option
global_options += [
"--env-file",
str(env_file_path), # Custom environment variables
]
global_options += [os.path.relpath(docker_compose_path, project_dir)]

# SEE https://docs.docker.com/compose/reference/config/
cmd_options = []
docker_compose_path = scripts_dir / "docker" / "docker-compose-config.bash"
assert docker_compose_path.exists()

cmd = ["docker-compose"] + global_options + ["config"] + cmd_options
cmd = [f"{docker_compose_path}"] + global_options
print(" ".join(cmd))

process = subprocess.run(
Expand Down

0 comments on commit 3be0dbd

Please sign in to comment.