diff --git a/.github/actions/apply-docker-version/apply-docker-version.sh b/.github/actions/apply-docker-version/apply-docker-version.sh index 0078b05cb..369febd1e 100755 --- a/.github/actions/apply-docker-version/apply-docker-version.sh +++ b/.github/actions/apply-docker-version/apply-docker-version.sh @@ -57,19 +57,19 @@ update_dockerfile() { echo "Updating $dockerfile..." # Update REDIS_DOWNLOAD_URL - if grep -q "^ENV REDIS_DOWNLOAD_URL=" "$dockerfile"; then - sed -i "s|^ENV REDIS_DOWNLOAD_URL=.*|ENV REDIS_DOWNLOAD_URL=$REDIS_ARCHIVE_URL|" "$dockerfile" + if grep -q "^ARG REDIS_DOWNLOAD_URL=" "$dockerfile"; then + sed -i "s|^ARG REDIS_DOWNLOAD_URL=.*|ARG REDIS_DOWNLOAD_URL=$REDIS_ARCHIVE_URL|" "$dockerfile" else - echo "Cannot update $dockerfile, ENV REDIS_DOWNLOAD_URL not found" + echo "Cannot update $dockerfile, ARG REDIS_DOWNLOAD_URL not found" return 1 fi # Update REDIS_DOWNLOAD_SHA - if grep -q "^ENV REDIS_DOWNLOAD_SHA=" "$dockerfile"; then - sed -i "s|^ENV REDIS_DOWNLOAD_SHA=.*|ENV REDIS_DOWNLOAD_SHA=$REDIS_ARCHIVE_SHA|" "$dockerfile" + if grep -q "^ARG REDIS_DOWNLOAD_SHA=" "$dockerfile"; then + sed -i "s|^ARG REDIS_DOWNLOAD_SHA=.*|ARG REDIS_DOWNLOAD_SHA=$REDIS_ARCHIVE_SHA|" "$dockerfile" else - echo "Cannot update $dockerfile, ENV REDIS_DOWNLOAD_SHA not found" + echo "Cannot update $dockerfile, ARG REDIS_DOWNLOAD_SHA not found" return 1 fi } diff --git a/.github/actions/build-and-tag-locally/action.yml b/.github/actions/build-and-tag-locally/action.yml index 719aae4dd..e9ef02210 100644 --- a/.github/actions/build-and-tag-locally/action.yml +++ b/.github/actions/build-and-tag-locally/action.yml @@ -1,4 +1,5 @@ name: Build and Test +description: Build and test redis docker image inputs: distribution: @@ -22,6 +23,24 @@ inputs: release_tag: description: 'Release tag to build' required: false + redisearch_version: + description: 'Redisearch version to build' + required: false + redisjson_version: + description: 'Redisjson version to build' + required: false + redisbloom_version: + description: 'Redisbloom version to build' + required: false + redistimeseries_version: + description: 'Redistimeseries version to build' + required: false + custom_ref_type: + description: 'Type of custom release, branch tag or commit. Empty for release' + required: false + run_type: + description: 'Run type, either release, pr, nightly, unstable or custom' + required: true runs: using: "composite" @@ -87,7 +106,23 @@ runs: username: ${{ inputs.registry_username }} password: ${{ inputs.registry_password }} + - name: Redis release archive + shell: bash + if: inputs.run_type != 'release' && inputs.run_type != 'pr' + run: | + if [[ "${{ inputs.custom_ref_type }}" == "branch" ]]; then + echo "REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/heads/${{ inputs.release_tag }}.tar.gz" | tee -a "$GITHUB_ENV" + elif [[ "${{ inputs.custom_ref_type }}" == "tag" ]]; then + echo "REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/${{ inputs.release_tag }}.tar.gz" | tee -a "$GITHUB_ENV" + elif [[ "${{ inputs.custom_ref_type }}" == "commit" ]]; then + echo "REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/${{ inputs.release_tag }}.tar.gz" | tee -a "$GITHUB_ENV" + else + echo "Wrong custom_build type, available options are tag, branch and commit" + exit 1 + fi + - name: Build + id: build uses: docker/build-push-action@v6 with: context: ${{ inputs.distribution }} @@ -95,20 +130,66 @@ runs: load: true platforms: ${{ inputs.platform }} tags: ${{ github.sha }}:${{ steps.platform.outputs.display_name }} - cache-from: type=gha,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }} - cache-to: type=gha,mode=max,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }} + cache-from: ${{ inputs.run_type == 'release' && format('type=gha,scope={0}-{1}', inputs.distribution, steps.platform.outputs.display_name) || '' }} + cache-to: ${{ inputs.run_type == 'release' && format('type=gha,mode=max,scope={0}-{1}', inputs.distribution, steps.platform.outputs.display_name) || '' }} + build-args: | + REDISEARCH_VERSION=${{ inputs.redisearch_version }} + REDISJSON_VERSION=${{ inputs.redisjson_version }} + REDISBLOOM_VERSION=${{ inputs.redisbloom_version }} + REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }} + ${{ (inputs.run_type != 'release' && inputs.run_type != 'pr') && 'CUSTOM_BUILD=true' || '' }} + ${{ (inputs.run_type != 'release' && inputs.run_type != 'pr') && format('REDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }} - - name: Save image + - name: Capture build logs on failure shell: bash + if: failure() && steps.build.outcome == 'failure' && inputs.run_type == 'nightly' run: | - docker save -o /tmp/image-${{ steps.platform.outputs.display_name }}.tar ${{ github.sha }}:${{ steps.platform.outputs.display_name }} + mkdir -p /tmp/build-logs + + echo "Build failed for ${{ inputs.distribution }} on ${{ inputs.platform }}" + echo "Capturing detailed logs for troubleshooting..." + + # Get docker history for the built image (might not exist if build failed early) + docker history ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-history.log 2>&1 || echo "Failed to get image history" + + # Get docker inspect output (might not exist if build failed early) + docker inspect ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-inspect.json 2>&1 || echo "Failed to inspect image" - - name: Upload image + # Get docker build cache info + docker buildx du > /tmp/build-logs/buildx-du.log 2>&1 || echo "Failed to get build cache info" + + # Get system info + uname -a > /tmp/build-logs/system-info.log 2>&1 + docker info > /tmp/build-logs/docker-info.log 2>&1 + + # Create a summary file + { + echo "Build failure summary for ${{ inputs.distribution }} on ${{ inputs.platform }}" + echo "Date: $(date)" + echo "GitHub SHA: ${{ github.sha }}" + echo "Platform: ${{ steps.platform.outputs.display_name }}" + echo "Distribution: ${{ inputs.distribution }}" + } > /tmp/build-logs/failure-summary.txt + + # Try to extract error information from the build logs + echo "Analyzing build failure..." + + # Check for common error patterns + if docker buildx build --no-cache ${{ inputs.distribution }} --platform=${{ inputs.platform }} 2>&1 | tee /tmp/build-logs/build-error.log | grep -q "ERROR"; then + echo "Found ERROR in build output" + grep -A 10 -B 5 "ERROR" /tmp/build-logs/build-error.log > /tmp/build-logs/error-context.log || true + fi + + echo "Log capture complete" + + - name: Upload build failure logs + if: failure() && steps.build.outcome == 'failure' && inputs.run_type == 'nightly' uses: actions/upload-artifact@v4 with: - name: ${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}-docker-image.tar - path: /tmp/image-${{ steps.platform.outputs.display_name }}.tar - retention-days: 45 + name: build-failure-${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }} + path: /tmp/build-logs/ + retention-days: 30 + if-no-files-found: warn - name: Run container shell: bash @@ -226,16 +307,39 @@ runs: - name: Format registry tag id: format-registry-tag + if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }} shell: bash run: | - printf "tag=%s:%s%s-%s-%s" \ + if [[ "${{ inputs.run_type }}" == "release" ]]; then + tag_prefix="${{ inputs.release_tag }}" + elif [[ "${{ inputs.run_type }}" == "unstable" || "${{ inputs.run_type }}" == "nightly" ]]; then + tag_prefix="unstable" + elif [[ "${{ inputs.run_type }}" == "custom" ]]; then + tag_prefix="custom" + else + echo "Wrong run_type value, available options are release, nightly, unstable and custom" + exit 1 + fi + + printf "tag=%s:%s-%s-%s-%s" \ "${{ inputs.registry_repository }}" \ - "${{ inputs.release_tag != '' && format('{0}-', inputs.release_tag || '') }}" \ - "${{ github.sha }}" \ + "${tag_prefix}" \ + "${{ github.run_id }}" \ "${{ inputs.distribution }}" \ "${{ steps.platform.outputs.display_name }}" \ | tr '[:upper:]' '[:lower:]' >> "$GITHUB_OUTPUT" + - name: Image labels + if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }} + id: get-image-labels + uses: ./.github/actions/create-image-labels + with: + redis_version: ${{ inputs.release_tag }} + redisearch_version: ${{ inputs.redisearch_version }} + redisjson_version: ${{ inputs.redisjson_version }} + redisbloom_version: ${{ inputs.redisbloom_version }} + redistimeseries_version: ${{ inputs.redistimeseries_version }} + - name: Push image uses: docker/build-push-action@v6 if: ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }} @@ -243,8 +347,19 @@ runs: context: ${{ inputs.distribution }} push: true tags: ${{ steps.format-registry-tag.outputs.tag }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: ${{ inputs.run_type == 'release' && 'type=gha' || '' }} + cache-to: ${{ inputs.run_type == 'release' && 'type=gha,mode=max' || '' }} + build-args: | + REDISEARCH_VERSION=${{ inputs.redisearch_version }} + REDISJSON_VERSION=${{ inputs.redisjson_version }} + REDISBLOOM_VERSION=${{ inputs.redisbloom_version }} + REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }} + ${{ inputs.run_type != 'release' && 'CUSTOM_BUILD=true' || '' }} + ${{ inputs.run_type != 'release' && format('REDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }} + labels: | + ${{ steps.get-image-labels.outputs.image-labels }} + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + org.opencontainers.image.revision=${{ github.sha }} - name: Save image metadata to artifact shell: bash diff --git a/.github/actions/create-image-labels/action.yml b/.github/actions/create-image-labels/action.yml new file mode 100644 index 000000000..f61007f00 --- /dev/null +++ b/.github/actions/create-image-labels/action.yml @@ -0,0 +1,114 @@ +name: Construct docker image labels +description: Construct docker image labels for io.redis + +inputs: + redis_version: + description: 'Redis version to build' + required: true + redisjson_version: + description: 'redisjson to build' + required: false + redisbloom_version: + description: 'redisbloom to build' + required: false + redistimeseries_version: + description: 'redistimeseries to build' + required: false + redisearch_version: + description: 'redisearch to build' + required: false + +outputs: + image-labels: + description: 'JSON list of built snap files' + value: ${{ steps.get-labels.outputs.image_labels }} + +runs: + using: "composite" + steps: + - name: Checkout Redis repository + uses: actions/checkout@v4 + with: + repository: redis/redis + path: redis + ref: ${{ inputs.redis_version }} + + - name: Get modules versions + if: inputs.redisearch_version == '' || inputs.redisjson_version == '' || inputs.redistimeseries_version == '' || inputs.redisbloom_version == '' + shell: bash + run: | + get_module_version() { + local module="$1" + grep MODULE_VERSION modules/$module/Makefile | cut -d '=' -f2 | tr -d ' ' + } + cd redis + if [ -z "${{ inputs.redisearch_version }}" ]; then + echo redisearch_version=$(get_module_version redisearch) >> $GITHUB_ENV + fi + if [ -z "${{ inputs.redisjson_version }}" ]; then + echo redisjson_version=$(get_module_version redisjson) >> $GITHUB_ENV + fi + if [ -z "${{ inputs.redisbloom_version }}" ]; then + echo redisbloom_version=$(get_module_version redisbloom) >> $GITHUB_ENV + fi + if [ -z "${{ inputs.redistimeseries_version }}" ]; then + echo redistimeseries_version=$(get_module_version redistimeseries) >> $GITHUB_ENV + fi + + - name: Checkout Redisearch repository + uses: actions/checkout@v4 + with: + repository: RediSearch/RediSearch + path: redisearch + ref: ${{ inputs.redisearch_version != '' && inputs.redisearch_version || env.redisearch_version }} + + - name: Checkout Redisjson repository + uses: actions/checkout@v4 + with: + repository: redisjson/redisjson + path: redisjson + ref: ${{ inputs.redisjson_version != '' && inputs.redisjson_version || env.redisjson_version }} + + - name: Checkout RedisTimeSeries repository + uses: actions/checkout@v4 + with: + repository: RedisTimeSeries/RedisTimeSeries + path: redistimeseries + ref: ${{ inputs.redistimeseries_version != '' && inputs.redistimeseries_version || env.redistimeseries_version }} + + - name: Checkout RedisBloom repository + uses: actions/checkout@v4 + with: + repository: RedisBloom/RedisBloom + path: redisbloom + ref: ${{ inputs.redisbloom_version != '' && inputs.redisbloom_version || env.redisbloom_version }} + + - name: Get image labels + id: get-labels + shell: bash + run: | + labels="" + created_timestamp=$(date -u --rfc-3339=seconds) + labels+="org.opencontainers.image.created=$created_timestamp"$'\n' + # Modules revisions labels + modules_repos=(redisearch redisjson redistimeseries redisbloom) + for module in "${modules_repos[@]}"; do + revision=$(git -C $module rev-parse HEAD) + labels+="io.redis.$module.revision=$revision"$'\n' + done + + # Redis labels + cd redis + redis_revision=$(git rev-parse HEAD) + labels+="io.redis.revision=$redis_revision"$'\n' + VER=$(sed -n 's/^.* REDIS_VERSION "\(.*\)"$/\1/g p' < src/version.h) + if [ "$VER" = "255.255.255" ]; then + labels+="io.redis.version=unstable"$'\n' + else + labels+="io.redis.version=$VER"$'\n' + fi + labels+="io.redis.source=https://github.com/redis/redis"$'\n' + echo "labels: $labels" + echo "image_labels<> $GITHUB_OUTPUT + echo "$labels" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT diff --git a/.github/workflows/pre-merge.yml b/.github/workflows/build-n-test.yml similarity index 71% rename from .github/workflows/pre-merge.yml rename to .github/workflows/build-n-test.yml index 29a0641da..921777f2e 100644 --- a/.github/workflows/pre-merge.yml +++ b/.github/workflows/build-n-test.yml @@ -1,21 +1,41 @@ name: Build and Test on: - pull_request: - branches: - - master - - release/* workflow_call: inputs: release_tag: description: 'Release tag to build' required: true type: string + redisearch_version: + description: 'Redisearch version to build' + required: false + type: string + redisjson_version: + description: 'Redisjson version to build' + required: false + type: string + redisbloom_version: + description: 'Redisbloom version to build' + required: false + type: string + redistimeseries_version: + description: 'Redistimeseries version to build' + required: false + type: string publish_image: description: 'Publish Docker image to GHCR' required: false type: boolean default: false + custom_ref_type: + description: 'Custom type, either branch, tag or commit. Empty for releases' + required: false + type: string + run_type: + description: 'Run type, either release, pr, unstable, nightly or custom' + required: false + type: string outputs: docker_images_metadata: description: 'Array of structured Docker images metadata that were published' @@ -48,8 +68,16 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: >- + ${{ (github.ref_name == 'unstable' + || github.event_name == 'workflow_call' + || github.event_name == 'schedule') + && 'unstable' + || '' + }} - name: Ensure release branch - if: ${{ inputs.release_tag }} + if: inputs.release_tag != '' && inputs.run_type == 'release' uses: redis-developer/redis-oss-release-automation/.github/actions/ensure-release-branch@main with: release_tag: ${{ inputs.release_tag }} @@ -60,14 +88,20 @@ jobs: platform: ${{ matrix.platform }} registry_username: ${{ github.actor }} registry_password: ${{ secrets.GITHUB_TOKEN }} - publish_image: ${{ inputs.publish_image || vars.PUBLISH_IMAGE }} + publish_image: ${{ inputs.publish_image }} registry_repository: ${{ format('ghcr.io/{0}', github.repository) }} release_tag: ${{ inputs.release_tag }} + redisearch_version: ${{ inputs.redisearch_version }} + redisjson_version: ${{ inputs.redisjson_version }} + redisbloom_version: ${{ inputs.redisbloom_version }} + redistimeseries_version: ${{ inputs.redistimeseries_version }} + custom_ref_type: ${{ inputs.custom_ref_type }} + run_type: ${{ inputs.run_type }} collect-images-metadata: runs-on: ubuntu-latest needs: build-and-test - if: ${{ inputs.release_tag }} + if: ${{ inputs.release_tag && inputs.run_type == 'release' }} outputs: docker_images_metadata: ${{ steps.collect-metadata.outputs.metadata }} steps: @@ -96,7 +130,7 @@ jobs: notify-slack: runs-on: ubuntu-latest needs: collect-images-metadata - if: ${{ inputs.release_tag && needs.collect-images-metadata.outputs.docker_images_metadata != '[]' }} + if: ${{ inputs.release_tag && needs.collect-images-metadata.outputs.docker_images_metadata != '[]' && inputs.run_type == 'release' }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -115,7 +149,7 @@ jobs: notify-slack-when-failed: runs-on: ubuntu-latest needs: collect-images-metadata - if: ${{ inputs.release_tag && failure() }} + if: ${{ inputs.release_tag && failure() && inputs.run_type == 'release' }} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 000000000..302df9fd8 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,32 @@ +name: Pull Request Build and Test + +on: + pull_request: + branches: + - master + - release/* + - unstable + +jobs: + build-and-test: + uses: ./.github/workflows/build-n-test.yml + if: github.event_name == 'pull_request' && github.base_ref != 'unstable' + secrets: inherit + with: + release_tag: '' + publish_image: false + run_type: pr + + build-and-test-unstable: + uses: ./.github/workflows/build-n-test.yml + if: github.event_name == 'pull_request' && github.base_ref == 'unstable' + secrets: inherit + with: + release_tag: unstable + publish_image: false + redisearch_version: master + redisjson_version: master + redisbloom_version: master + redistimeseries_version: master + custom_ref_type: branch + run_type: unstable \ No newline at end of file diff --git a/.github/workflows/release_build_and_test.yml b/.github/workflows/release_build_and_test.yml index 36d555659..88d5ff421 100644 --- a/.github/workflows/release_build_and_test.yml +++ b/.github/workflows/release_build_and_test.yml @@ -1,5 +1,6 @@ # This workflow is a part of release automation process. # It is intended to be run with workflow_dispatch event by the automation. +# In addition to regular tag builds, it also supports publishing unstable builds. # Warning: Workflow does switch branches and this may lead to confusion when changing workflow actions. # The usual safety rule is to make changes to workflow or actions in base branch (e.g, release/8.X) @@ -13,13 +14,33 @@ on: workflow_uuid: description: 'Optional UUID to identify this workflow run' required: false + redisearch_version: + description: 'Redisearch version to build' + required: false + redisjson_version: + description: 'Redisjson version to build' + required: false + redisbloom_version: + description: 'Redisbloom version to build' + required: false + redistimeseries_version: + description: 'Redistimeseries version to build' + required: false + custom_ref_type: + description: 'Custom type, either branch, tag or commit. Empty for releases' + required: false + run_type: + description: 'Run type, either release, unstable or custom' + required: true + default: "custom" # UUID is used to help automation to identify workflow run in the list of workflow runs. -run-name: "Release Build and Test${{ github.event.inputs.workflow_uuid && format(': {0}', github.event.inputs.workflow_uuid) || '' }}" +run-name: "${{ github.event.inputs.run_type }} build and test${{ github.event.inputs.workflow_uuid && format(': {0}', github.event.inputs.workflow_uuid) || '' }}" jobs: prepare-release: runs-on: ["ubuntu-latest"] + if: github.event.inputs.run_type == 'release' steps: - name: Checkout code uses: actions/checkout@v4 @@ -52,16 +73,23 @@ jobs: release_version_branch: ${{ steps.ensure-branch.outputs.release_version_branch }} build-and-test: - uses: ./.github/workflows/pre-merge.yml + uses: ./.github/workflows/build-n-test.yml needs: prepare-release + if: always() && (needs.prepare-release.result == 'success' || needs.prepare-release.result == 'skipped') secrets: inherit with: release_tag: ${{ github.event.inputs.release_tag }} publish_image: true + redisearch_version: ${{ github.event.inputs.redisearch_version }} + redisjson_version: ${{ github.event.inputs.redisjson_version }} + redisbloom_version: ${{ github.event.inputs.redisbloom_version }} + redistimeseries_version: ${{ github.event.inputs.redistimeseries_version }} + custom_ref_type: ${{ github.event.inputs.custom_ref_type }} + run_type: ${{ github.event.inputs.run_type }} merge-back-to-release-branch: needs: [prepare-release, build-and-test] - if: success() + if: success() && github.event.inputs.run_type == 'release' && github.event.inputs.release_tag != 'unstable' runs-on: ["ubuntu-latest"] steps: - name: Checkout code diff --git a/.github/workflows/release_publish.yml b/.github/workflows/release_publish.yml index c00adee9c..bbb3cf6bd 100644 --- a/.github/workflows/release_publish.yml +++ b/.github/workflows/release_publish.yml @@ -12,17 +12,17 @@ on: description: 'Optional UUID to identify this workflow run' required: false pr_to_official_library: + description: 'Open a PR to official library repo' default: false release_tag: + description: 'Release tag to publish' default: "" required: false env: TARGET_OFFICIAL_IMAGES_REPO: docker-library/official-images - #TARGET_OFFICIAL_IMAGES_REPO: Peter-Sh/official-images FORKED_OFFICIAL_IMAGES_REPO: redis-developer/docker-library-official-images PR_USER_MENTIONS: "@adamiBs @yossigo @adobrzhansky @maxb-io @dagansandler @Peter-Sh" - #PR_USER_MENTIONS: "" # UUID is used to help automation to identify workflow run in the list of workflow runs. run-name: "Release Publish${{ github.event.inputs.workflow_uuid && format(': {0}', github.event.inputs.workflow_uuid) || '' }}" diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 5b36cd19a..2751ebfcd 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -14,8 +14,13 @@ RUN set -eux; \ # we need setpriv package as busybox provides very limited functionality setpriv \ ; -ENV REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.4.0.tar.gz -ENV REDIS_DOWNLOAD_SHA=b947d9015622669b5bee8ec954f658b3278d42dbefae23a92d9b7704bfe143f9 +ARG REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.4.0.tar.gz +ARG REDIS_DOWNLOAD_SHA=b947d9015622669b5bee8ec954f658b3278d42dbefae23a92d9b7704bfe143f9 +ARG REDISEARCH_VERSION +ARG REDISJSON_VERSION +ARG REDISBLOOM_VERSION +ARG REDISTIMESERIES_VERSION +ARG CUSTOM_BUILD=false RUN set -eux; \ \ apk add --no-cache --virtual .build-deps \ @@ -73,7 +78,9 @@ RUN set -eux; \ # install required python packages for RedisJSON module pip install -q --upgrade setuptools && pip install -q --upgrade pip && PIP_BREAK_SYSTEM_PACKAGES=1 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 -; \ + if [ $CUSTOM_BUILD = false ]; then \ + echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \ + fi; \ mkdir -p /usr/src/redis; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ @@ -107,6 +114,21 @@ RUN set -eux; \ export RUST_DYN_CRT=1; \ export BUILD_TLS=yes; \ if [ "$BUILD_WITH_MODULES" = "yes" ]; then \ + if [ $CUSTOM_BUILD = true ]; then \ + # Update modules versions + if [ -n "$REDISEARCH_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISEARCH_VERSION/" /usr/src/redis/modules/redisearch/Makefile; \ + fi; \ + if [ -n "$REDISJSON_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISJSON_VERSION/" /usr/src/redis/modules/redisjson/Makefile; \ + fi; \ + if [ -n "$REDISBLOOM_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISBLOOM_VERSION/" /usr/src/redis/modules/redisbloom/Makefile; \ + fi; \ + if [ -n "$REDISTIMESERIES_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISTIMESERIES_VERSION/" /usr/src/redis/modules/redistimeseries/Makefile; \ + fi; \ + fi; \ 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; \ diff --git a/debian/Dockerfile b/debian/Dockerfile index 1a44e99c9..99e7b8533 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -14,8 +14,13 @@ RUN set -eux; \ ; \ rm -rf /var/lib/apt/lists/* -ENV REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.4.0.tar.gz -ENV REDIS_DOWNLOAD_SHA=b947d9015622669b5bee8ec954f658b3278d42dbefae23a92d9b7704bfe143f9 +ARG REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/8.4.0.tar.gz +ARG REDIS_DOWNLOAD_SHA=b947d9015622669b5bee8ec954f658b3278d42dbefae23a92d9b7704bfe143f9 +ARG REDISEARCH_VERSION +ARG REDISJSON_VERSION +ARG REDISBLOOM_VERSION +ARG REDISTIMESERIES_VERSION +ARG CUSTOM_BUILD=false RUN set -eux; \ \ savedAptMark="$(apt-mark showmanual)"; \ @@ -56,11 +61,28 @@ RUN set -eux; \ rm -rf /var/lib/apt/lists/*; \ \ wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \ - echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \ + if [ $CUSTOM_BUILD = false ]; then \ + echo "$REDIS_DOWNLOAD_SHA *redis.tar.gz" | sha256sum -c -; \ + fi; \ mkdir -p /usr/src/redis; \ tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1; \ rm redis.tar.gz; \ \ + if [ $CUSTOM_BUILD = true ]; then \ + # Update modules versions + if [ -n "$REDISEARCH_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISEARCH_VERSION/" /usr/src/redis/modules/redisearch/Makefile; \ + fi; \ + if [ -n "$REDISJSON_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISJSON_VERSION/" /usr/src/redis/modules/redisjson/Makefile; \ + fi; \ + if [ -n "$REDISBLOOM_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISBLOOM_VERSION/" /usr/src/redis/modules/redisbloom/Makefile; \ + fi; \ + if [ -n "$REDISTIMESERIES_VERSION" ]; then \ + sed -i "s/^MODULE_VERSION = .*/MODULE_VERSION = $REDISTIMESERIES_VERSION/" /usr/src/redis/modules/redistimeseries/Makefile; \ + fi; \ + fi; \ # disable Redis protected mode [1] as it is unnecessary in context of Docker # (ports are not automatically exposed when running inside Docker, but rather explicitly by specifying -p / -P) # [1]: https://github.com/redis/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da