Skip to content

Commit

Permalink
deploy: use "docker compose" instead of "docker-compose"
Browse files Browse the repository at this point in the history
In newer docker versions, compose is a plugin to the docker command rather than a command in its own right.
  • Loading branch information
ianroberts committed Nov 3, 2024
1 parent 4c9db59 commit 445cc8e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/image-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 15 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 445cc8e

Please sign in to comment.