From 33a5edce058dda27742fb35f6fc9e03d6a31cf1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20=C4=8Cekrli=C4=87?= Date: Mon, 2 Sep 2024 20:55:19 +0200 Subject: [PATCH] Fix: Use `docker compose` instead of `docker-compose`, if available. --- integration-tests.sh | 9 +++++++-- sample/docker-compose/start.sh | 8 +++++++- unit-tests.sh | 8 +++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/integration-tests.sh b/integration-tests.sh index 0ded841..d7b180a 100755 --- a/integration-tests.sh +++ b/integration-tests.sh @@ -11,6 +11,11 @@ if command -v gfind > /dev/null 2>&1; then FIND="$(which gfind)" fi +DOCKER_COMPOSE="docker-compose" +if docker --help | grep -q -F 'compose*'; then + DOCKER_COMPOSE="docker compose" +fi + run_test() { local exit_code echo @@ -20,10 +25,10 @@ run_test() { ( cd "$1" set +e - docker-compose up --build --abort-on-container-exit --exit-code-from tests + $DOCKER_COMPOSE up --build --abort-on-container-exit --exit-code-from tests exit_code="$?" - docker-compose down -v + $DOCKER_COMPOSE down -v if [[ "$exit_code" != 0 ]]; then exit "$exit_code" fi diff --git a/sample/docker-compose/start.sh b/sample/docker-compose/start.sh index 91af7ea..11d3754 100755 --- a/sample/docker-compose/start.sh +++ b/sample/docker-compose/start.sh @@ -1,3 +1,9 @@ #!/bin/sh cd $(dirname $0) -docker-compose up \ No newline at end of file + +DOCKER_COMPOSE="docker-compose" +if docker --help | grep -q -F 'compose*'; then + DOCKER_COMPOSE="docker compose" +fi + +$DOCKER_COMPOSE up \ No newline at end of file diff --git a/unit-tests.sh b/unit-tests.sh index d3e1eb7..6bd3902 100755 --- a/unit-tests.sh +++ b/unit-tests.sh @@ -1,3 +1,9 @@ #!/bin/sh cd unit-tests -docker-compose up --build --abort-on-container-exit --exit-code-from tests + +DOCKER_COMPOSE="docker-compose" +if docker --help | grep -q -F 'compose*'; then + DOCKER_COMPOSE="docker compose" +fi + +$DOCKER_COMPOSE up --build --abort-on-container-exit --exit-code-from tests