Skip to content

Commit 33bb071

Browse files
chore: migrate to docker compose plugin (V2/V5+)
Replace docker-compose standalone with docker compose plugin. Remove version detection logic as V1 is now obsolete and V2/V5+ plugin is the standard. Changes: - Remove evaluate_docker_compose() function from bin/utils - Use 'docker compose' directly instead of detecting V2 via version check - Supports both Docker Compose V2 and V5+
1 parent 067caae commit 33bb071

2 files changed

Lines changed: 2 additions & 27 deletions

File tree

bin/docker-compose

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
. "$(dirname "$0")/utils"
44

5-
DOCKER_COMPOSE=$(evaluate_docker_compose)
65
WORKDIR=$(dirname $(readlink_f $0))/../
76

87
cd $WORKDIR
98

10-
exec $DOCKER_COMPOSE "$@"
9+
exec docker compose "$@"

bin/utils

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
11
#!/bin/sh
22

3-
# Evaluate the appropriate Docker Compose command based on availability and V2 compatibility.
4-
#
5-
# If a compatible command is found, it is set to $COMPOSE_COMMAND. If no compatible command
6-
# is found, the function exits with status 1.
7-
evaluate_docker_compose() {
8-
local COMPOSE_COMMAND
9-
10-
if docker compose version --short 2> /dev/null | grep -q "^2\."; then
11-
COMPOSE_COMMAND="docker compose"
12-
elif docker-compose version --short 2> /dev/null | grep -q "^2\."; then
13-
COMPOSE_COMMAND="docker-compose"
14-
fi
15-
16-
if [ -z "$COMPOSE_COMMAND" ]; then
17-
echo >&2 "ERROR: Cannot find Docker Compose compatible with V2 spec"
18-
exit 1
19-
fi
20-
21-
echo "$COMPOSE_COMMAND"
22-
}
23-
243
readlink_f() {
254
(if uname | grep -q 'Darwin'; then
265
# Use greadlink if available, otherwise it behaves like "readlink -f" option
@@ -46,10 +25,7 @@ readlink_f() {
4625
}
4726

4827
exit_if_not_running() {
49-
local DOCKER_COMPOSE
50-
DOCKER_COMPOSE=$(evaluate_docker_compose)
51-
52-
SERVICES=$($DOCKER_COMPOSE ps -q | grep -v INFO: | xargs docker inspect -f '{{.State.Running}}' 2>/dev/null | grep -c 'true')
28+
SERVICES=$(docker compose ps -q | grep -v INFO: | xargs docker inspect -f '{{.State.Running}}' 2>/dev/null | grep -c 'true')
5329

5430
[ "$SERVICES" -le 0 ] && { echo "🚫 ERROR: ShellHub is not running. Exiting."; exit 1; }
5531
}

0 commit comments

Comments
 (0)