From 2240ec377d9f5aa987a52ae378a61b03660f6658 Mon Sep 17 00:00:00 2001 From: Ian Roberts Date: Sun, 3 Nov 2024 01:00:07 +0000 Subject: [PATCH] deploy: use "docker compose" instead of "docker-compose" In newer docker versions, compose is a plugin to the docker command rather than a command in its own right. --- .github/workflows/image-tests.yml | 8 ++++---- deploy.sh | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/image-tests.yml b/.github/workflows/image-tests.yml index 1239d5ab..bdb258fe 100644 --- a/.github/workflows/image-tests.yml +++ b/.github/workflows/image-tests.yml @@ -50,16 +50,16 @@ jobs: source .env # Launch the database container - docker-compose up -d db + docker compose up -d db # Hacky method of waiting for postgres to be up and running sleep 10 # Allow Django to create databases for the testing - docker-compose exec -T db psql -v ON_ERROR_STOP=1 --username postgres -c 'ALTER USER '"$DB_USERNAME"' CREATEDB;' + docker compose exec -T db psql -v ON_ERROR_STOP=1 --username postgres -c 'ALTER USER '"$DB_USERNAME"' CREATEDB;' # Run the backend tests - docker-compose run --rm --entrypoint npm backend run test:pytest + docker compose run --rm --entrypoint npm backend run test:pytest # Run the frontend tests - docker-compose run --rm --entrypoint npm backend run test:frontend + docker compose run --rm --entrypoint npm backend run test:frontend diff --git a/deploy.sh b/deploy.sh index c72704df..b9cacb95 100755 --- a/deploy.sh +++ b/deploy.sh @@ -29,4 +29,18 @@ case $DEPLOY_ENV in ;; esac -docker-compose up -d +# Find a working docker compose +declare -a COMPOSE +if "$DOCKER" compose >/dev/null 2>&1 ; then + # We have compose v2 + COMPOSE[0]="$DOCKER" + COMPOSE[1]="compose" +elif which docker-compose > /dev/null 2>&1 ; then + # We have compose v1 + COMPOSE[0]="docker-compose" +else + echo "Could not find 'docker compose' or 'docker-compose'" + exit 1 +fi + +exec "${COMPOSE[@]}" up -d