Skip to content

Commit

Permalink
feat: Support docker compose CLI (getsentry#1116)
Browse files Browse the repository at this point in the history
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 getsentry#962
  • Loading branch information
EricsonMacedo authored Oct 15, 2021
1 parent f2e2dc2 commit 78a5c3c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,28 @@ jobs:
integration-test:
runs-on: ubuntu-20.04
name: "integration test"
strategy:
max-parallel: 1
fail-fast: false
matrix:
include:
- compose_version: '1.28.0'
compose_path: '/usr/local/bin'
- compose_version: 'v2.0.1'
compose_path: '/usr/local/lib/docker/cli-plugins'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Pin docker-compose

- name: Get Compose
run: |
COMPOSE_PATH=/usr/local/bin/docker-compose
source ./install/_min-requirements.sh
sudo rm $COMPOSE_PATH
sudo curl -L https://github.com/docker/compose/releases/download/${MIN_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o $COMPOSE_PATH
sudo chmod +x $COMPOSE_PATH
# Always remove `docker compose` support as that's the newer version
# and comes installed by default nowadays.
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose"
sudo rm -f "${{ matrix.compose_path }}/docker-compose"
sudo mkdir -p "${{ matrix.compose_path }}"
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"
sudo chmod +x "${{ matrix.compose_path }}/docker-compose"
- name: Integration Test
run: |
Expand Down
4 changes: 2 additions & 2 deletions _integration-test/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -ex

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

Expand Down Expand Up @@ -118,7 +118,7 @@ done
echo "${_endgroup}"

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

echo "${_group}Test custom CAs work ..."
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ services:
smtp:
<<: *restart_policy
image: tianon/exim4
hostname: ${SENTRY_MAIL_HOST:-}
hostname: ${SENTRY_MAIL_HOST:-''}
volumes:
- "sentry-smtp:/var/spool/exim4"
- "sentry-smtp-log:/var/log/exim4"
Expand Down
3 changes: 2 additions & 1 deletion install/_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ else
_endgroup=""
fi

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

# A couple of the config files are referenced from other subscripts, so they
Expand Down
9 changes: 7 additions & 2 deletions install/check-minimum-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ echo "${_group}Checking minimum requirements ..."
source "$(dirname $0)/_min-requirements.sh"

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

Expand Down
2 changes: 1 addition & 1 deletion install/wrap-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else
echo ""
echo "You're all done! Run the following command to get Sentry running:"
echo ""
echo " docker-compose up -d"
echo " $dc_base up -d"
echo ""
echo "-----------------------------------------------------------------"
echo ""
Expand Down

0 comments on commit 78a5c3c

Please sign in to comment.