From 249df7eeb6ef0759227a3e17bc872ef82546261c Mon Sep 17 00:00:00 2001 From: ColinChamber Date: Mon, 1 May 2023 10:15:33 +0800 Subject: [PATCH 1/4] Add redis-cli to the image --- .github/workflows/nightly.yaml | 55 ++++++++++++++++++++++++++++++++-- Dockerfile | 4 +++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index f02cfaebc69..2472a016a0d 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -24,12 +24,63 @@ on: paths: ['.github/workflows/nightly.yaml'] jobs: + build-redis-cli: + name: build redis cli for ${{ matrix.arch }} + runs-on: ubuntu-20.04 + strategy: + matrix: + arch: [amd64, arm64] + steps: + - name: Cache redis-cli + id: cache-redis-cli + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/redis-cli-${{ matrix.arch }} + key: redis-cli-${{ matrix.arch }} + + - name: Install redis-cli + if: steps.cache-redis-cli.outputs.cache-hit != 'true' + run: | + curl -O https://download.redis.io/releases/redis-6.2.7.tar.gz + tar -xzvf redis-6.2.7.tar.gz + mkdir -p $HOME/local/bin + if [ "${{ matrix.arch }}" == "arm64" ]; then + sudo apt-get install -y gcc-aarch64-linux-gnu + pushd redis-6.2.7 && make CC=aarch64-linux-gnu-gcc MALLOC=libc -j$NPROC redis-cli && mv src/redis-cli ${{ github.workspace }}/redis-cli-${{ matrix.arch }} && popd + fi + if [ "${{ matrix.arch }}" == "amd64" ]; then + pushd redis-6.2.7 && BUILD_TLS=yes make -j$NPROC redis-cli && mv src/redis-cli ${{ github.workspace }}/redis-cli-${{ matrix.arch }} && popd + fi + + - name: Upload redis-cli artifact + uses: actions/upload-artifact@v2 + with: + name: redis-cli-${{ matrix.arch }} + path: ${{ github.workspace }}/redis-cli-${{ matrix.arch }} + publish-nightly-docker-image: name: Publish nightly Docker image + needs: build-redis-cli runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - name: Make tools directory + run: | + mkdir tools + + - name: Download redis-cli-arm64 artifact + uses: actions/download-artifact@v2 + with: + name: redis-cli-arm64 + path: tools + + - name: Download redis-cli-amd64 artifact + uses: actions/download-artifact@v2 + with: + name: redis-cli-amd64 + path: tools + - name: Login Docker Hub if: (github.event_name != 'pull_request') uses: docker/login-action@v1 @@ -46,7 +97,7 @@ jobs: - name: Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - + - name: Get core numbers run: echo "NPROC=$(nproc)" >> $GITHUB_ENV diff --git a/Dockerfile b/Dockerfile index 543195f76e2..214f9373ab0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,6 +37,10 @@ WORKDIR /kvrocks COPY --from=build /kvrocks/build/kvrocks ./bin/ +ARG TARGETARCH +COPY tools/redis-cli-${TARGETARCH} /usr/bin/redis-cli +RUN chmod a+x /usr/bin/redis-cli + VOLUME /var/lib/kvrocks COPY ./LICENSE ./NOTICE ./DISCLAIMER ./ From fe628ee4c3bb50e89306a5cd56fed6dd0616109b Mon Sep 17 00:00:00 2001 From: ColinChamber Date: Tue, 2 May 2023 16:09:59 +0800 Subject: [PATCH 2/4] mock redis-cli --- .github/workflows/kvrocks.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/kvrocks.yaml b/.github/workflows/kvrocks.yaml index 54535e842bf..2089d93eb66 100644 --- a/.github/workflows/kvrocks.yaml +++ b/.github/workflows/kvrocks.yaml @@ -265,6 +265,8 @@ jobs: - uses: actions/checkout@v3 - name: Get core numbers run: echo "NPROC=$(nproc)" >> $GITHUB_ENV + - name: Mock redis-cli + run: mkdir tools && touch tools/redis-cli-amd64 - uses: docker/build-push-action@v3 with: context: . From 244984505987bf5b7aab5e87e18a210a99f94ad1 Mon Sep 17 00:00:00 2001 From: ColinChamber Date: Thu, 4 May 2023 19:27:20 +0800 Subject: [PATCH 3/4] refactor --- .github/workflows/kvrocks.yaml | 2 -- .github/workflows/nightly.yaml | 55 ++-------------------------------- Dockerfile | 14 ++++++--- 3 files changed, 12 insertions(+), 59 deletions(-) diff --git a/.github/workflows/kvrocks.yaml b/.github/workflows/kvrocks.yaml index 2089d93eb66..54535e842bf 100644 --- a/.github/workflows/kvrocks.yaml +++ b/.github/workflows/kvrocks.yaml @@ -265,8 +265,6 @@ jobs: - uses: actions/checkout@v3 - name: Get core numbers run: echo "NPROC=$(nproc)" >> $GITHUB_ENV - - name: Mock redis-cli - run: mkdir tools && touch tools/redis-cli-amd64 - uses: docker/build-push-action@v3 with: context: . diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 2472a016a0d..f02cfaebc69 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -24,63 +24,12 @@ on: paths: ['.github/workflows/nightly.yaml'] jobs: - build-redis-cli: - name: build redis cli for ${{ matrix.arch }} - runs-on: ubuntu-20.04 - strategy: - matrix: - arch: [amd64, arm64] - steps: - - name: Cache redis-cli - id: cache-redis-cli - uses: actions/cache@v3 - with: - path: | - ${{ github.workspace }}/redis-cli-${{ matrix.arch }} - key: redis-cli-${{ matrix.arch }} - - - name: Install redis-cli - if: steps.cache-redis-cli.outputs.cache-hit != 'true' - run: | - curl -O https://download.redis.io/releases/redis-6.2.7.tar.gz - tar -xzvf redis-6.2.7.tar.gz - mkdir -p $HOME/local/bin - if [ "${{ matrix.arch }}" == "arm64" ]; then - sudo apt-get install -y gcc-aarch64-linux-gnu - pushd redis-6.2.7 && make CC=aarch64-linux-gnu-gcc MALLOC=libc -j$NPROC redis-cli && mv src/redis-cli ${{ github.workspace }}/redis-cli-${{ matrix.arch }} && popd - fi - if [ "${{ matrix.arch }}" == "amd64" ]; then - pushd redis-6.2.7 && BUILD_TLS=yes make -j$NPROC redis-cli && mv src/redis-cli ${{ github.workspace }}/redis-cli-${{ matrix.arch }} && popd - fi - - - name: Upload redis-cli artifact - uses: actions/upload-artifact@v2 - with: - name: redis-cli-${{ matrix.arch }} - path: ${{ github.workspace }}/redis-cli-${{ matrix.arch }} - publish-nightly-docker-image: name: Publish nightly Docker image - needs: build-redis-cli runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 - - name: Make tools directory - run: | - mkdir tools - - - name: Download redis-cli-arm64 artifact - uses: actions/download-artifact@v2 - with: - name: redis-cli-arm64 - path: tools - - - name: Download redis-cli-amd64 artifact - uses: actions/download-artifact@v2 - with: - name: redis-cli-amd64 - path: tools + - uses: actions/checkout@v3 - name: Login Docker Hub if: (github.event_name != 'pull_request') uses: docker/login-action@v1 @@ -97,7 +46,7 @@ jobs: - name: Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - + - name: Get core numbers run: echo "NPROC=$(nproc)" >> $GITHUB_ENV diff --git a/Dockerfile b/Dockerfile index 214f9373ab0..9586c59fcac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,12 +23,19 @@ ARG MORE_BUILD_ARGS ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -RUN apt update && apt install -y git gcc g++ make cmake autoconf automake libtool python3 libssl-dev +RUN apt update && apt install -y git gcc g++ make cmake autoconf automake libtool python3 libssl-dev curl WORKDIR /kvrocks COPY . . RUN ./x.py build -DENABLE_OPENSSL=ON -DPORTABLE=ON $MORE_BUILD_ARGS +RUN curl -O https://download.redis.io/releases/redis-6.2.7.tar.gz && \ + tar -xzvf redis-6.2.7.tar.gz && \ + mkdir tools && \ + cd redis-6.2.7 && \ + make redis-cli && \ + mv src/redis-cli /kvrocks/tools/redis-cli + FROM ubuntu:focal RUN apt update && apt install -y libssl-dev @@ -37,9 +44,8 @@ WORKDIR /kvrocks COPY --from=build /kvrocks/build/kvrocks ./bin/ -ARG TARGETARCH -COPY tools/redis-cli-${TARGETARCH} /usr/bin/redis-cli -RUN chmod a+x /usr/bin/redis-cli +COPY --from=build /kvrocks/tools/redis-cli ./bin/ +RUN ln -s /kvrocks/bin/redis-cli /usr/bin/redis-cli VOLUME /var/lib/kvrocks From 44dc2c2d2840b3852941db72c5b86879565b6fdc Mon Sep 17 00:00:00 2001 From: ColinChamber Date: Fri, 5 May 2023 19:48:46 +0800 Subject: [PATCH 4/4] update --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9586c59fcac..0c75d510720 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,7 +45,7 @@ WORKDIR /kvrocks COPY --from=build /kvrocks/build/kvrocks ./bin/ COPY --from=build /kvrocks/tools/redis-cli ./bin/ -RUN ln -s /kvrocks/bin/redis-cli /usr/bin/redis-cli +ENV PATH="$PATH:/kvrocks/bin" VOLUME /var/lib/kvrocks