Skip to content

Commit d885dd3

Browse files
authored
Use docker-compose if version is gte docker compose (#3595)
Fixes #3587 This PR tries to use docker-compose if its version is greater than docker compose.
1 parent 9b6c1cf commit d885dd3

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

install/_lib.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ function ensure_file_from_example {
5353
fi
5454
}
5555

56+
# Check the version of $1 is greater than or equal to $2 using sort. Note: versions must be stripped of "v"
57+
function vergte() {
58+
printf "%s\n%s" $1 $2 | sort --version-sort --check=quiet --reverse
59+
echo $?
60+
}
61+
5662
SENTRY_CONFIG_PY=sentry/sentry.conf.py
5763
SENTRY_CONFIG_YML=sentry/config.yml
5864

install/check-minimum-requirements.sh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ echo "${_group}Checking minimum requirements ..."
22

33
source install/_min-requirements.sh
44

5-
# Check the version of $1 is greater than or equal to $2 using sort. Note: versions must be stripped of "v"
6-
function vergte() {
7-
printf "%s\n%s" $1 $2 | sort --version-sort --check=quiet --reverse
8-
echo $?
9-
}
10-
115
DOCKER_VERSION=$(docker version --format '{{.Server.Version}}' || echo '')
126
if [[ -z "$DOCKER_VERSION" ]]; then
137
echo "FAIL: Unable to get docker version, is the docker daemon running?"
@@ -20,12 +14,6 @@ if [[ "$(vergte ${DOCKER_VERSION//v/} $MIN_DOCKER_VERSION)" -eq 1 ]]; then
2014
fi
2115
echo "Found Docker version $DOCKER_VERSION"
2216

23-
COMPOSE_VERSION=$($dc_base version --short || echo '')
24-
if [[ -z "$COMPOSE_VERSION" ]]; then
25-
echo "FAIL: Docker compose is required to run self-hosted"
26-
exit 1
27-
fi
28-
2917
if [[ "$(vergte ${COMPOSE_VERSION//v/} $MIN_COMPOSE_VERSION)" -eq 1 ]]; then
3018
echo "FAIL: Expected minimum $dc_base version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION"
3119
exit 1

install/dc-detect-version.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ echo "${_group}Initializing Docker Compose ..."
1010

1111
# To support users that are symlinking to docker-compose
1212
dc_base="$(docker compose version &>/dev/null && echo 'docker compose' || echo 'docker-compose')"
13+
dc_base_standalone="$(docker-compose version &>/dev/null && echo 'docker-compose' || echo '')"
14+
15+
COMPOSE_VERSION=$($dc_base version --short || echo '')
16+
STANDALONE_COMPOSE_VERSION=$($dc_base_standalone version --short &>/dev/null || echo '')
17+
18+
if [[ -z "$COMPOSE_VERSION" && -z "$STANDALONE_COMPOSE_VERSION" ]]; then
19+
echo "FAIL: Docker Compose is required to run self-hosted"
20+
exit 1
21+
fi
22+
23+
if [[ ! -z "${STANDALONE_COMPOSE_VERSION}" ]]; then
24+
if [[ "$(vergte ${COMPOSE_VERSION//v/} ${STANDALONE_COMPOSE_VERSION//v/})" -eq 1 ]]; then
25+
COMPOSE_VERSION="${STANDALONE_COMPOSE_VERSION}"
26+
dc_base="$dc_base_standalone"
27+
fi
28+
fi
29+
1330
if [[ "$(basename $0)" = "install.sh" ]]; then
1431
dc="$dc_base --ansi never --env-file ${_ENV}"
1532
else

0 commit comments

Comments
 (0)