From 6203acb65e690d21efee279615c876593b1eb1cf Mon Sep 17 00:00:00 2001 From: maxb-io <105273783+maxb-io@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:17:01 +0200 Subject: [PATCH] Add alpine support (#421) Co-authored-by: adamiBs --- .../actions/build-and-tag-locally/action.yml | 26 +++++--- .github/workflows/pre-merge.yml | 14 ++++- .gitignore | 1 - alpine/Dockerfile | 62 +++++++++++++------ debian/Dockerfile | 6 +- 5 files changed, 76 insertions(+), 33 deletions(-) delete mode 100644 .gitignore diff --git a/.github/actions/build-and-tag-locally/action.yml b/.github/actions/build-and-tag-locally/action.yml index 66015a61..70c2a052 100644 --- a/.github/actions/build-and-tag-locally/action.yml +++ b/.github/actions/build-and-tag-locally/action.yml @@ -45,6 +45,9 @@ runs: linux/arm/v5) plaform_name="arm-v5" ;; + linux/arm/v6) + plaform_name="arm-v6" + ;; linux/arm/v7) plaform_name="arm-v7" ;; @@ -57,6 +60,9 @@ runs: linux/ppc64le) plaform_name="ppc64le" ;; + linux/riscv64) + plaform_name="riscv64" + ;; linux/s390x) plaform_name="s390x" ;; @@ -100,31 +106,31 @@ runs: - name: Upload image uses: actions/upload-artifact@v4 with: - name: ${{ steps.platform.outputs.display_name }}-docker-image.tar + name: ${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}-docker-image.tar path: /tmp/image-${{ steps.platform.outputs.display_name }}.tar retention-days: 45 - name: Run container shell: bash - if: ${{ contains(fromJSON('["amd64", "arm64", "i386"]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64", "i386"]'), steps.platform.outputs.display_name) }} run: | docker run -d --name sanity-test-${{ steps.platform.outputs.display_name }} ${{ github.sha }}:${{ steps.platform.outputs.display_name }} - name: Container Logs - if: ${{ contains(fromJSON('["amd64", "arm64", "i386"]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64", "i386"]'), steps.platform.outputs.display_name) }} shell: bash run: | docker logs sanity-test-${{ steps.platform.outputs.display_name }} - name: Sanity Tests - if: ${{ contains(fromJSON('["amd64", "arm64", "i386"]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64", "i386"]'), steps.platform.outputs.display_name) }} shell: bash run: | docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli ping docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli info server - name: Verify installed modules - if: ${{ contains(fromJSON('["amd64", "arm64",]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64"]'), steps.platform.outputs.display_name) }} shell: bash run: | modules=$(docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli module list) @@ -144,7 +150,7 @@ runs: fi - name: Test RedisBloom - if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64"]'), steps.platform.outputs.display_name) }} shell: bash run: | docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli BF.ADD popular_keys "redis:hash" @@ -154,7 +160,7 @@ runs: echo "RedisBloom test passed successfully" - name: Test RediSearch - if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64"]'), steps.platform.outputs.display_name) }} shell: bash run: | docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli FT.CREATE redis_commands ON HASH PREFIX 1 cmd: SCHEMA name TEXT SORTABLE description TEXT @@ -169,7 +175,7 @@ runs: fi - name: Test RedisTimeSeries - if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64"]'), steps.platform.outputs.display_name) }} shell: bash run: | docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli TS.CREATE redis:cpu:usage RETENTION 86400 @@ -185,7 +191,7 @@ runs: fi - name: Test ReJSON - if: ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }} + if: ${{ contains(fromJSON('["amd64"]'), steps.platform.outputs.display_name) }} shell: bash run: | docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli JSON.SET redis:config $ '{"maxmemory":"2gb","maxmemory-policy":"allkeys-lru"}' @@ -200,7 +206,7 @@ runs: - name: Push image uses: docker/build-push-action@v6 - if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64","arm64"]'), steps.platform.outputs.display_name) }} + if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64"]'), steps.platform.outputs.display_name) }} with: context: ${{ inputs.distribution }} push: true diff --git a/.github/workflows/pre-merge.yml b/.github/workflows/pre-merge.yml index 53e3d051..4eefba9d 100644 --- a/.github/workflows/pre-merge.yml +++ b/.github/workflows/pre-merge.yml @@ -12,15 +12,27 @@ jobs: matrix: distribution: - debian - #- alpine + - alpine platform: - linux/amd64 - linux/i386 - linux/arm/v5 + - linux/arm/v6 - linux/arm/v7 - linux/mips64le - linux/ppc64le - linux/s390x + - linux/arm64 + - linux/riscv64 + exclude: + - distribution: alpine + platform: linux/mips64le + - distribution: alpine + platform: linux/arm/v5 + - distribution: debian + platform: linux/riscv64 + - distribution: debian + platform: linux/arm/v6 steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e43b0f98..00000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 02967ddc..60a3ee54 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -37,16 +37,15 @@ RUN set -eux; \ gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ gpgconf --kill all; \ - rm -f "$GNUPGHOME" /usr/local/bin/gosu.asc; \ + rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \ apk del --no-network .gosu-fetch; \ chmod +x /usr/local/bin/gosu; \ gosu --version; \ gosu nobody true -ENV REDIS_VERSION=8.0-m01 -ENV REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.0-m01.tar.gz -ENV REDIS_DOWNLOAD_SHA=4c77c2218747505c50c43a45d12a067a3631a26d9397929da180e183b03e862c - +ENV REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.0-m02.tar.gz +ENV REDIS_DOWNLOAD_SHA=c70d565c5403c5e8392942810e980b23478b82218f6069656ea51bc8978176c1 +ENV PIP_BREAK_SYSTEM_PACKAGES=1 RUN set -eux; \ \ apk add --no-cache --virtual .build-deps \ @@ -57,6 +56,7 @@ RUN set -eux; \ make \ musl-dev \ openssl-dev \ + g++ \ ; \ \ arch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ @@ -67,26 +67,42 @@ RUN set -eux; \ esac; \ if [ "$BUILD_WITH_MODULES" = "yes" ]; then \ apk add --no-cache --virtual .module-build-deps \ - git \ + autoconf \ + automake \ + bash \ + bsd-compat-headers \ + build-base \ + cargo \ + clang \ + clang18-libclang \ cmake \ curl \ - python3 \ + g++ \ + git \ + libffi-dev \ + libgcc \ + libtool \ + openssh \ + openssl \ + py-virtualenv \ + py3-cryptography \ py3-pip \ py3-virtualenv \ + python3 \ python3-dev \ - unzip \ rsync \ - clang \ - automake \ - autoconf \ - libtool \ - g++ \ - libgcc \ - ;\ + tar \ + unzip \ + which \ + xsimd \ + xz \ + ;\ fi; \ \ - wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \ - echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \ +# install required python packages for RedisJSON module + pip install -q --upgrade setuptools && pip install -q --upgrade pip && pip install -q addict toml jinja2 ramp-packer ;\ + wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \ + echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \ mkdir -p /usr/src/redis; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ @@ -117,6 +133,11 @@ RUN set -eux; \ grep -F "cd jemalloc && ./configure $extraJemallocConfigureFlags " /usr/src/redis/deps/Makefile; \ \ export BUILD_TLS=yes; \ + if [ "$BUILD_WITH_MODULES" = "yes" ]; then \ + make -C /usr/src/redis/modules/redisjson get_source; \ + sed -i 's/^RUST_FLAGS=$/RUST_FLAGS += -C target-feature=-crt-static/' /usr/src/redis/modules/redisjson/src/Makefile ; \ + grep -E 'RUST_FLAGS' /usr/src/redis/modules/redisjson/src/Makefile; \ + fi; \ make -C /usr/src/redis -j "$(nproc)" all; \ make -C /usr/src/redis install; \ \ @@ -141,7 +162,12 @@ RUN set -eux; \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )"; \ apk add --no-network --virtual .redis-rundeps $runDeps; \ - apk del --no-network .build-deps; \ + if [ "$BUILD_WITH_MODULES" = "yes" ]; then \ + apk del --no-network .module-build-deps; \ + fi; \ + apk del --no-network .build-deps; \ + apk --purge del apk-tools ; \ + rm -fr ~/.cache/pip* rm -f /sbin/apk && rm -rf /etc/apk && rm -rf /lib/apk && rm -rf /usr/share/apk && rm -rf /var/lib/apk && rm -rf /usr/lib/python*; \ \ redis-cli --version; \ redis-server --version; diff --git a/debian/Dockerfile b/debian/Dockerfile index 05644b0e..b9dc313c 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -50,9 +50,8 @@ RUN set -eux; \ gosu --version; \ gosu nobody true -ENV REDIS_VERSION=8.0-m01 -ENV REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.0-m01.tar.gz -ENV REDIS_DOWNLOAD_SHA=4c77c2218747505c50c43a45d12a067a3631a26d9397929da180e183b03e862c +ENV REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.0-m02.tar.gz +ENV REDIS_DOWNLOAD_SHA=c70d565c5403c5e8392942810e980b23478b82218f6069656ea51bc8978176c1 RUN set -eux; \ \ @@ -63,6 +62,7 @@ RUN set -eux; \ wget \ dpkg-dev \ gcc \ + g++ \ libc6-dev \ libssl-dev \ make \