diff --git a/services/tools/cli/docker_service.py b/services/tools/cli/docker_service.py index a8166c3..04cb364 100755 --- a/services/tools/cli/docker_service.py +++ b/services/tools/cli/docker_service.py @@ -62,6 +62,25 @@ class DockerServiceCLI(BaseCli): ) services.append(service) return services + + def create_docker_command(self, service: Service): + command_str = ['docker'] + + if service.host.ip != 'localhost': + command_str.append('-H') + command_str.append(f'{service.host.user}@{service.host.ip}') + command_str.append('compose') + command_str.append('-f') + command_str.append(f'{service.compose_file}') + if service.env_file: + command_str.append('--env-file') + command_str.append(f'{service.env_file}') + command_str.append('up') + command_str.append('-d') + self.info(f"Executing command: {' '.join(command_str)}") + return command_str + + def run_docker_command(self, service: Service): self.info(f"Processing service:\n{service}") @@ -69,14 +88,8 @@ class DockerServiceCLI(BaseCli): for i in range(0, len(service.ports)): self.info(f'Set env SVC_PORT_{i+1}={str(service.ports[i])}') os.environ[f'SVC_PORT_{i+1}'] = str(service.ports[i]) - - command = [ - 'docker', '-H', f"{service.host.user}@{service.host.ip}", - 'compose', '-f', f"{service.compose_file}", - '--env-file', f"{service.env_file}", - 'up', '-d' - ] - + os.environ['SVC_HOST'] = str(service.host.ip) + command = self.create_docker_command(service) try: subprocess.run(command, check=True) except subprocess.CalledProcessError as e: