From e8fadc0036ec7329906d2bc6eb4be5d29ed0199d Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 16 Jan 2025 11:48:26 +0000 Subject: [PATCH 1/5] breaking: Upgrade min Compose version to 2.23.2 In this version, there's a new `--pull` argument for `docker compose run` which we will start leveraging, especially with `sentry-admin` command. --- .github/workflows/test.yml | 2 +- action.yaml | 2 +- install/_min-requirements.sh | 2 +- install/dc-detect-version.sh | 2 +- sentry-admin.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e471c84baa..f799a0d355b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,7 +53,7 @@ jobs: sudo rm -f "/usr/local/bin/docker-compose" sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose" sudo mkdir -p "/usr/local/lib/docker/cli-plugins" - sudo curl -L https://github.com/docker/compose/releases/download/v2.26.0/docker-compose-`uname -s`-`uname -m` -o "/usr/local/lib/docker/cli-plugins/docker-compose" + sudo curl -L https://github.com/docker/compose/releases/download/v2.32.3/docker-compose-`uname -s`-`uname -m` -o "/usr/local/lib/docker/cli-plugins/docker-compose" sudo chmod +x "/usr/local/lib/docker/cli-plugins/docker-compose" - name: Compute Docker Volume Cache Key diff --git a/action.yaml b/action.yaml index ec5897f0a27..6c174f21b0b 100644 --- a/action.yaml +++ b/action.yaml @@ -41,7 +41,7 @@ runs: - name: Get Compose env: COMPOSE_PATH: /usr/local/lib/docker/cli-plugins - COMPOSE_VERSION: "v2.26.0" + COMPOSE_VERSION: "v2.32.3" shell: bash run: | # Always remove `docker compose` support as that's the newer version diff --git a/install/_min-requirements.sh b/install/_min-requirements.sh index 2180c6a9a97..c518508e2f3 100644 --- a/install/_min-requirements.sh +++ b/install/_min-requirements.sh @@ -1,6 +1,6 @@ # Don't forget to update the README and other docs when you change these! MIN_DOCKER_VERSION='19.03.6' -MIN_COMPOSE_VERSION='2.19.0' +MIN_COMPOSE_VERSION='2.32.2' # 16 GB minimum host RAM, but there'll be some overhead outside of what # can be allotted to docker diff --git a/install/dc-detect-version.sh b/install/dc-detect-version.sh index 64e814e1ecd..ccee1b5eebe 100644 --- a/install/dc-detect-version.sh +++ b/install/dc-detect-version.sh @@ -16,7 +16,7 @@ else dc="$dc_base --ansi never" fi proxy_args="--build-arg http_proxy=${http_proxy:-} --build-arg https_proxy=${https_proxy:-} --build-arg no_proxy=${no_proxy:-}" -dcr="$dc run --rm" +dcr="$dc run --pull=never --rm" dcb="$dc build $proxy_args" dbuild="docker build $proxy_args" diff --git a/sentry-admin.sh b/sentry-admin.sh index 3db5f2ed044..36a5086f2cf 100755 --- a/sentry-admin.sh +++ b/sentry-admin.sh @@ -22,7 +22,7 @@ on the host filesystem. Commands that write files should write them to the '/sen # Actual invocation that runs the command in the container. invocation() { - $dcr --quiet-pull -v "$VOLUME_MAPPING" -T -e SENTRY_LOG_LEVEL=CRITICAL web "$@" 2>&1 + $dcr -v "$VOLUME_MAPPING" -T -e SENTRY_LOG_LEVEL=CRITICAL web "$@" 2>&1 } # Function to modify lines starting with `Usage: sentry` to say `Usage: ./sentry-admin.sh` instead. From 679e0c59cb295a588de4aef47d51ec87498b6de0 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 16 Jan 2025 11:59:49 +0000 Subject: [PATCH 2/5] Create get-compose-action for unification --- .github/workflows/test.yml | 11 ++++------- action.yaml | 17 ++--------------- get-compose-action/action.yaml | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 get-compose-action/action.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f799a0d355b..0f08315d3ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,9 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Get Compose + uses: ./get-compose-action + - name: Unit Tests run: ./unit-test.sh @@ -48,13 +51,7 @@ jobs: ref: ${{ env.LATEST_TAG }} - name: Get Compose - run: | - # Docker Compose v1 is installed here, remove it - sudo rm -f "/usr/local/bin/docker-compose" - sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose" - sudo mkdir -p "/usr/local/lib/docker/cli-plugins" - sudo curl -L https://github.com/docker/compose/releases/download/v2.32.3/docker-compose-`uname -s`-`uname -m` -o "/usr/local/lib/docker/cli-plugins/docker-compose" - sudo chmod +x "/usr/local/lib/docker/cli-plugins/docker-compose" + uses: ./get-compose-action - name: Compute Docker Volume Cache Key id: cache_key diff --git a/action.yaml b/action.yaml index 6c174f21b0b..1da58c92227 100644 --- a/action.yaml +++ b/action.yaml @@ -39,26 +39,13 @@ runs: fi - name: Get Compose - env: - COMPOSE_PATH: /usr/local/lib/docker/cli-plugins - COMPOSE_VERSION: "v2.32.3" - shell: bash - run: | - # 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" - # Docker Compose v1 is installed here, remove it - sudo rm -f "/usr/local/bin/docker-compose" - sudo rm -f "${{ env.COMPOSE_PATH }}/docker-compose" - sudo mkdir -p "${{ env.COMPOSE_PATH }}" - sudo curl -L https://github.com/docker/compose/releases/download/${{ env.COMPOSE_VERSION }}/docker-compose-`uname -s`-`uname -m` -o "${{ env.COMPOSE_PATH }}/docker-compose" - sudo chmod +x "${{ env.COMPOSE_PATH }}/docker-compose" + uses: ${{ github.action_path }}get-compose-action - name: Compute Docker Volume Cache Key id: cache_key shell: bash run: | - source ${{ github.action_path }}/.env + source ${{ github.action_path }}.env # See https://explainshell.com/explain?cmd=ls%20-Rv1rpq # for that long `ls` command SENTRY_MIGRATIONS_MD5=$(docker run --rm --entrypoint bash $SENTRY_IMAGE -c 'ls -Rv1rpq src/sentry/migrations/' | md5sum | cut -d ' ' -f 1) diff --git a/get-compose-action/action.yaml b/get-compose-action/action.yaml new file mode 100644 index 00000000000..243f1037ced --- /dev/null +++ b/get-compose-action/action.yaml @@ -0,0 +1,18 @@ +name: "Get Docker Compose" +inputs: + version: + required: false + default: 2.32.3 + description: "Docker Compose version" + +runs: + using: "composite" + steps: + - name: Get Compose + run: | + # Docker Compose v1 is installed here, remove it + sudo rm -f "/usr/local/bin/docker-compose" + sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose" + sudo mkdir -p "/usr/local/lib/docker/cli-plugins" + sudo curl -L https://github.com/docker/compose/releases/download/v${{ inputs.version }}/docker-compose-`uname -s`-`uname -m` -o "/usr/local/lib/docker/cli-plugins/docker-compose" + sudo chmod +x "/usr/local/lib/docker/cli-plugins/docker-compose" From e5c3aeea24eaa7fa53d16f6240a9a466c680d8a9 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 16 Jan 2025 12:04:00 +0000 Subject: [PATCH 3/5] fixes --- .github/workflows/test.yml | 7 ++++--- action.yaml | 2 +- get-compose-action/action.yaml | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0f08315d3ce..3b5e39d94da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,14 +45,15 @@ jobs: LATEST_TAG=$(curl -s https://api.github.com/repos/getsentry/self-hosted/releases/latest | jq -r '.tag_name') echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + - name: Get Compose + # TODO: Replace this with `@master` after landing + uses: getsentry/self-hosted/get-compose-action@byk/ref/upgrade-compose + - name: Checkout latest release uses: actions/checkout@v4 with: ref: ${{ env.LATEST_TAG }} - - name: Get Compose - uses: ./get-compose-action - - name: Compute Docker Volume Cache Key id: cache_key run: | diff --git a/action.yaml b/action.yaml index 1da58c92227..72aaf3add4b 100644 --- a/action.yaml +++ b/action.yaml @@ -39,7 +39,7 @@ runs: fi - name: Get Compose - uses: ${{ github.action_path }}get-compose-action + uses: ./get-compose-action - name: Compute Docker Volume Cache Key id: cache_key diff --git a/get-compose-action/action.yaml b/get-compose-action/action.yaml index 243f1037ced..17d5993e70d 100644 --- a/get-compose-action/action.yaml +++ b/get-compose-action/action.yaml @@ -9,6 +9,7 @@ runs: using: "composite" steps: - name: Get Compose + shell: bash run: | # Docker Compose v1 is installed here, remove it sudo rm -f "/usr/local/bin/docker-compose" From 43ac62156336b08c18ca902f5fccd4289c1d6b7a Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 16 Jan 2025 12:08:09 +0000 Subject: [PATCH 4/5] Fix broken test --- _unit-test/js-sdk-assets-test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/_unit-test/js-sdk-assets-test.sh b/_unit-test/js-sdk-assets-test.sh index 7177f559ba9..bd898acf6a7 100755 --- a/_unit-test/js-sdk-assets-test.sh +++ b/_unit-test/js-sdk-assets-test.sh @@ -3,14 +3,15 @@ source _unit-test/_test_setup.sh source install/dc-detect-version.sh $dcb --force-rm web +$dc pull nginx export SETUP_JS_SDK_ASSETS=1 source install/setup-js-sdk-assets.sh -sdk_files=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx ls -lah /var/www/js-sdk/) -sdk_tree=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx tree /var/www/js-sdk/ | tail -n 1) -non_empty_file_count=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx find /var/www/js-sdk/ -type f -size +1k | wc -l) +sdk_files=$($dcr --no-deps -v "sentry-nginx-www:/var/www" nginx ls -lah /var/www/js-sdk/) +sdk_tree=$($dcr --no-deps -v "sentry-nginx-www:/var/www" nginx tree /var/www/js-sdk/ | tail -n 1) +non_empty_file_count=$($dcr --no-deps -v "sentry-nginx-www:/var/www" nginx find /var/www/js-sdk/ -type f -size +1k | wc -l) # `sdk_files` should contains 5 lines, '4.*', '5.*', '6.*', `7.*` and `8.*` echo $sdk_files From 87a919b03d7a22e7ffc12ea3935e36ea3c9b1288 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 16 Jan 2025 21:27:54 +0000 Subject: [PATCH 5/5] fix bad merge --- .github/workflows/test.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c60a3d8028b..af1e624dc2f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,15 +54,6 @@ jobs: with: ref: ${{ env.LATEST_TAG }} - - name: Compute Docker Volume Cache Key - id: cache_key - run: | - source .env - SENTRY_MIGRATIONS_MD5=$(docker run --rm --entrypoint bash $SENTRY_IMAGE -c 'ls -Rv1rpq src/sentry/migrations/' | md5sum | cut -d ' ' -f 1) - echo "SENTRY_MIGRATIONS_MD5=$SENTRY_MIGRATIONS_MD5" >> $GITHUB_OUTPUT - SNUBA_MIGRATIONS_MD5=$(docker run --rm --entrypoint bash $SNUBA_IMAGE -c 'ls -Rv1rpq snuba/snuba_migrations/**/*.py' | md5sum | cut -d ' ' -f 1) - echo "SNUBA_MIGRATIONS_MD5=$SNUBA_MIGRATIONS_MD5" >> $GITHUB_OUTPUT - - name: Restore DB Volumes Cache id: restore_cache uses: BYK/docker-volume-cache-action/restore@be89365902126f508dcae387a32ec3712df6b1cd