Check docker-compose version

Signed-off-by: Simó Albert i Beltran <sim6@bona.gent>
Simó Albert i Beltran 2022-05-11 10:38:06 +02:00
parent 94babbd403
commit 6a84016f7a
No known key found for this signature in database
GPG Key ID: BF2BE2EC583EB239
1 changed files with 20 additions and 0 deletions

20
dd-ctl
View File

@ -2,6 +2,21 @@
OPERATION="$1"
# We need docker-compose >= 1.28 to catch configuration variables
REQUIRED_DOCKER_COMPOSE_VERSION="1.28"
docker_compose_version(){
docker-compose --version --short | sed 's/^docker-compose version \([^,]\+\),.*$/\1/'
}
check_docker_compose_version(){
# We cannot use sort -C because is not included in BusyBox v1.33.1 of docker:dind image
{
echo "$REQUIRED_DOCKER_COMPOSE_VERSION"
docker_compose_version
} | sort -c -V 2> /dev/null
}
help() {
cat <<-EOF
Example: ./dd.ctl [operation] [arguments]
@ -51,6 +66,11 @@ if [ "$OPERATION" != "prerequisites" ]; then
echo "You need to copy digitaldemocratic.conf.sample to digitaldemocratic.conf and adapt"
exit 1
fi
if ! check_docker_compose_version
then
echo "ERROR: Please use docker-compose greather than or equal to $REQUIRED_DOCKER_COMPOSE_VERSION." >&2
exit 1
fi
fi
BRANCH="${2:-master}"