From 521d64d6cd18782aa0b6b095e9bd0410e419e81c Mon Sep 17 00:00:00 2001 From: josep-tecnativa Date: Wed, 10 Apr 2024 11:47:22 +0200 Subject: [PATCH] [FIX] Correct always using docker compose, even if it not compatible. --- tasks_downstream.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tasks_downstream.py b/tasks_downstream.py index e8fb7d5f..b88897e7 100644 --- a/tasks_downstream.py +++ b/tasks_downstream.py @@ -8,6 +8,7 @@ import os import shutil import stat +import subprocess import tempfile import time from datetime import datetime @@ -46,8 +47,17 @@ "build" ]["args"]["ODOO_VERSION"] ) -DOCKER_COMPOSE_CMD = f"{shutil.which('docker')} compose" or shutil.which( - "docker-compose" +# The following lines of code determine the docker dompose command to be used. +# The logic behind this is that if it's a version compatible with cocker compose, +# it will use this; otherwise, it will fallback to using docker-compose instead. +docker_compose_v2 = ( + subprocess.run([shutil.which("docker"), "compose"], capture_output=True).returncode + == 0 +) +DOCKER_COMPOSE_CMD = ( + f"{shutil.which('docker')} compose" + if docker_compose_v2 + else shutil.which("docker-compose") ) _logger = getLogger(__name__)