Skip to content

Commit 78a5c3c

Browse files
feat: Support docker compose CLI (#1116)
Check if docker compose v2, CLI, is available and get semantic version from it, or fallback to get semantic version out of docker-compose v1 when checking minimum requirements during install.sh script Fixes #962
1 parent f2e2dc2 commit 78a5c3c

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,28 @@ jobs:
2626
integration-test:
2727
runs-on: ubuntu-20.04
2828
name: "integration test"
29+
strategy:
30+
max-parallel: 1
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- compose_version: '1.28.0'
35+
compose_path: '/usr/local/bin'
36+
- compose_version: 'v2.0.1'
37+
compose_path: '/usr/local/lib/docker/cli-plugins'
2938
steps:
3039
- name: Checkout
3140
uses: actions/checkout@v2
32-
33-
- name: Pin docker-compose
41+
42+
- name: Get Compose
3443
run: |
35-
COMPOSE_PATH=/usr/local/bin/docker-compose
36-
source ./install/_min-requirements.sh
37-
sudo rm $COMPOSE_PATH
38-
sudo curl -L https://github.com/docker/compose/releases/download/${MIN_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o $COMPOSE_PATH
39-
sudo chmod +x $COMPOSE_PATH
44+
# Always remove `docker compose` support as that's the newer version
45+
# and comes installed by default nowadays.
46+
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose"
47+
sudo rm -f "${{ matrix.compose_path }}/docker-compose"
48+
sudo mkdir -p "${{ matrix.compose_path }}"
49+
sudo curl -L https://github.com/docker/compose/releases/download/${{ matrix.compose_version }}/docker-compose-`uname -s`-`uname -m` -o "${{ matrix.compose_path }}/docker-compose"
50+
sudo chmod +x "${{ matrix.compose_path }}/docker-compose"
4051
4152
- name: Integration Test
4253
run: |

_integration-test/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -e
2+
set -ex
33

44
source "$(dirname $0)/../install/_lib.sh"
55

@@ -118,7 +118,7 @@ done
118118
echo "${_endgroup}"
119119

120120
echo "${_group}Ensure cleanup crons are working ..."
121-
$dc ps | grep -q -- "-cleanup_.\+[[:space:]]\+Up[[:space:]]\+"
121+
$dc ps | grep -q -E "\-cleanup\s+running\s+|\-cleanup_.+\s+Up\s+"
122122
echo "${_endgroup}"
123123

124124
echo "${_group}Test custom CAs work ..."

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ services:
9393
smtp:
9494
<<: *restart_policy
9595
image: tianon/exim4
96-
hostname: ${SENTRY_MAIL_HOST:-}
96+
hostname: ${SENTRY_MAIL_HOST:-''}
9797
volumes:
9898
- "sentry-smtp:/var/spool/exim4"
9999
- "sentry-smtp-log:/var/log/exim4"

install/_lib.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ else
2525
_endgroup=""
2626
fi
2727

28-
dc="docker-compose --ansi never"
28+
dc_base="$(docker compose version >/dev/null && echo 'docker compose' || echo 'docker-compose')"
29+
dc="$dc_base --ansi never"
2930
dcr="$dc run --rm"
3031

3132
# A couple of the config files are referenced from other subscripts, so they

install/check-minimum-requirements.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ echo "${_group}Checking minimum requirements ..."
33
source "$(dirname $0)/_min-requirements.sh"
44

55
DOCKER_VERSION=$(docker version --format '{{.Server.Version}}')
6-
# Do NOT use $dc instead of `docker-compose` below as older versions don't support certain options and fail
7-
COMPOSE_VERSION=$(docker-compose --version | sed 's/docker-compose version \(.\{1,\}\),.*/\1/')
6+
# Get semantic version of Docker Compose v2
7+
if docker compose version >/dev/null; then
8+
COMPOSE_VERSION=$(docker compose version --short | sed 's/v\{0,1\}\(.\{1,\}\)/\1/')
9+
else
10+
# Do NOT use $dc instead of `docker-compose` below as older versions don't support certain options and fail
11+
COMPOSE_VERSION=$(docker-compose --version | sed 's/docker-compose version \(.\{1,\}\),.*/\1/')
12+
fi
813
RAM_AVAILABLE_IN_DOCKER=$(docker run --rm busybox free -m 2>/dev/null | awk '/Mem/ {print $2}');
914
CPU_AVAILABLE_IN_DOCKER=$(docker run --rm busybox nproc --all);
1015

install/wrap-up.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ else
1818
echo ""
1919
echo "You're all done! Run the following command to get Sentry running:"
2020
echo ""
21-
echo " docker-compose up -d"
21+
echo " $dc_base up -d"
2222
echo ""
2323
echo "-----------------------------------------------------------------"
2424
echo ""

0 commit comments

Comments
 (0)