From 96fb9d09b7c35d1f99d06e7d3b5a01238620d2ac Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Thu, 11 Aug 2022 13:06:43 +0800 Subject: [PATCH] [fix][C++ client] Fix rpm and deb packaging ### Motivation For branch-2.11 and master branches, the rpm and deb packaging is broken. > /usr/bin/env: 'python3': No such file or directory It's caused by [PIP-155](https://github.com/apache/pulsar/pull/15376), which removes the Python2 support. In addition, the Dockerfiles of `rpm` and `deb` subdirectories of `pulsar-client-cpp/pkg` don't install Boost for Python3 well. But the rpm build disables the `BUILD_PYTHON_WRAPPER` option while the deb build doesn't. ### Modifications - Fix Dockerfiles under `pkg` and `rpm` subdirectories and speed up the `docker build` process: - Install python3 to fix the bug - Download the CMake 3.24.0 binaries directly instead of building from source - Upgrade Boost to 1.79 so that only headers are required (the boost::regex module is required for CentOS 7 because the default GCC is 4.8 that there is something wrong with std::regex) - Add `-j8` option when compiling some large dependencies that uses 8 threads to speed the compilation - Remove the `-v` option of `tar` to avoid showing too many info - Check the `BUILD_IMAGE` environment variable in `docker-build-xxx.sh` under `rpm` and `deb` subdirectories. If it's defined, build the image rather than pull the image from DockerHub before executing the build script. Because currently only a few committers have the permission to push the Docker images. - Add two workflows to build RPM and DEB packages if the files under `pulsar-client-cpp` changed. They build the docker images and run the build script for RPM and DEB packaging. - Specify the platform to `linux/amd64` so that the scripts can be used in ARM64 machines like Mac M1. --- .github/workflows/ci-cpp-deb-pkg.yaml | 97 +++++++++++++++++++ .github/workflows/ci-cpp-rpm-pkg.yaml | 97 +++++++++++++++++++ pulsar-client-cpp/pkg/deb/Dockerfile | 47 +++++---- pulsar-client-cpp/pkg/deb/build-deb.sh | 5 +- .../pkg/deb/build-docker-image.sh | 21 ---- pulsar-client-cpp/pkg/deb/docker-build-deb.sh | 12 ++- pulsar-client-cpp/pkg/rpm/Dockerfile | 44 ++++----- .../pkg/rpm/build-docker-image.sh | 21 ---- pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh | 12 ++- 9 files changed, 260 insertions(+), 96 deletions(-) create mode 100644 .github/workflows/ci-cpp-deb-pkg.yaml create mode 100644 .github/workflows/ci-cpp-rpm-pkg.yaml delete mode 100755 pulsar-client-cpp/pkg/deb/build-docker-image.sh delete mode 100755 pulsar-client-cpp/pkg/rpm/build-docker-image.sh diff --git a/.github/workflows/ci-cpp-deb-pkg.yaml b/.github/workflows/ci-cpp-deb-pkg.yaml new file mode 100644 index 0000000000000..b6c75c4c7273d --- /dev/null +++ b/.github/workflows/ci-cpp-deb-pkg.yaml @@ -0,0 +1,97 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: CI - CPP DEB packaging +on: + pull_request: + branches: + - master + paths: + - '.github/workflows/**' + - 'pulsar-client-cpp/**' + push: + branches: + - branch-* + paths: + - '.github/workflows/**' + - 'pulsar-client-cpp/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + cpp-deb-packaging: + name: + runs-on: ubuntu-latest + timeout-minutes: 120 + + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: Tune Runner VM + uses: ./.github/actions/tune-runner-vm + + - name: Detect changed files + id: changes + uses: apache/pulsar-test-infra/paths-filter@master + with: + filters: .github/changes-filter.yaml + list-files: csv + + - name: Check changed files + id: check_changes + run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}" + + - name: Cache local Maven repository + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + uses: actions/cache@v2 + with: + path: | + ~/.m2/repository/*/*/* + !~/.m2/repository/org/apache/pulsar + key: ${{ runner.os }}-m2-dependencies-core-modules-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-m2-dependencies-core-modules- + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + with: + distribution: 'temurin' + java-version: 17 + + - name: clean disk + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + run: | + sudo apt clean + docker rmi $(docker images -q) -f + df -h + + - name: Package Pulsar source + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + run: mvn -B -ntp -q clean package -pl pulsar-client-api -am -DskipTests + + - name: Build Debian packages + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + run: | + echo "Build Debian packages" + BUILD_IMAGE=1 pulsar-client-cpp/pkg/deb/docker-build-deb.sh diff --git a/.github/workflows/ci-cpp-rpm-pkg.yaml b/.github/workflows/ci-cpp-rpm-pkg.yaml new file mode 100644 index 0000000000000..b8da1eac99db3 --- /dev/null +++ b/.github/workflows/ci-cpp-rpm-pkg.yaml @@ -0,0 +1,97 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: CI - CPP RPM packaging +on: + pull_request: + branches: + - master + paths: + - '.github/workflows/**' + - 'pulsar-client-cpp/**' + push: + branches: + - branch-* + paths: + - '.github/workflows/**' + - 'pulsar-client-cpp/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + cpp-rpm-packaging: + name: + runs-on: ubuntu-latest + timeout-minutes: 120 + + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: Tune Runner VM + uses: ./.github/actions/tune-runner-vm + + - name: Detect changed files + id: changes + uses: apache/pulsar-test-infra/paths-filter@master + with: + filters: .github/changes-filter.yaml + list-files: csv + + - name: Check changed files + id: check_changes + run: echo "::set-output name=docs_only::${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}" + + - name: Cache local Maven repository + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + uses: actions/cache@v2 + with: + path: | + ~/.m2/repository/*/*/* + !~/.m2/repository/org/apache/pulsar + key: ${{ runner.os }}-m2-dependencies-core-modules-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-m2-dependencies-core-modules- + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + with: + distribution: 'temurin' + java-version: 17 + + - name: clean disk + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + run: | + sudo apt clean + docker rmi $(docker images -q) -f + df -h + + - name: Package Pulsar source + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + run: mvn -B -ntp -q clean package -pl pulsar-client-api -am -DskipTests + + - name: Build RPM packages + if: ${{ steps.check_changes.outputs.docs_only != 'true' }} + run: | + echo "Build RPM packages" + BUILD_IMAGE=1 pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh diff --git a/pulsar-client-cpp/pkg/deb/Dockerfile b/pulsar-client-cpp/pkg/deb/Dockerfile index def8bdb55d066..925f2bb7d8bc5 100644 --- a/pulsar-client-cpp/pkg/deb/Dockerfile +++ b/pulsar-client-cpp/pkg/deb/Dockerfile @@ -19,38 +19,37 @@ # Build pulsar client library in Centos with tools to -FROM debian:9 +FROM --platform=linux/amd64 debian:9 +# perl is required to install OpenSSL RUN apt-get update -y && \ - apt-get install -y curl g++ make python-dev \ - libxml2-utils git + apt-get install -y curl g++ make perl dpkg-dev python3 # Download and compile boost -RUN curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.64.0/source/boost_1_64_0.tar.gz && \ - tar xvfz boost_1_64_0.tar.gz && \ - cd /boost_1_64_0 && \ - ./bootstrap.sh --with-libraries=program_options,filesystem,regex,thread,system,python && \ +RUN curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz && \ + tar xfz boost_1_79_0.tar.gz && \ + cd boost_1_79_0 && \ + ./bootstrap.sh && \ ./b2 address-model=64 cxxflags=-fPIC link=static threading=multi variant=release install && \ - rm -rf /boost_1_64_0.tar.gz /boost_1_64_0 + rm -rf /boost_1_79_0.tar.gz /boost_1_79_0 -RUN curl -O -L https://github.com/Kitware/CMake/archive/v3.8.2.tar.gz && \ - tar xvfz v3.8.2.tar.gz && \ - cd CMake-3.8.2 && \ - ./configure && \ - make && make install && \ - rm -rf /v3.8.2.tar.gz /CMake-3.8.2 +RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0-linux-x86_64.tar.gz && \ + tar xfz cmake-3.24.0-linux-x86_64.tar.gz && \ + cp cmake-3.24.0-linux-x86_64/bin/* /usr/bin/ && \ + cp -r cmake-3.24.0-linux-x86_64/share/cmake-3.24 /usr/share/ && \ + rm -rf cmake-3.24.0-linux-x86_64 cmake-3.24.0-linux-x86_64.tar.gz # Download and copile protoubf RUN curl -O -L https://github.com/google/protobuf/releases/download/v3.20.0/protobuf-cpp-3.20.0.tar.gz && \ - tar xvfz protobuf-cpp-3.20.0.tar.gz && \ + tar xfz protobuf-cpp-3.20.0.tar.gz && \ cd protobuf-3.20.0/ && \ CXXFLAGS=-fPIC ./configure && \ - make && make install && ldconfig && \ + make -j8 && make install && ldconfig && \ rm -rf /protobuf-cpp-3.20.0.tar.gz /protobuf-3.20.0 # ZLib RUN curl -O -L https://github.com/madler/zlib/archive/v1.2.12.tar.gz && \ - tar xvfz v1.2.12.tar.gz && \ + tar xfz v1.2.12.tar.gz && \ cd zlib-1.2.12 && \ CFLAGS="-fPIC -O3" ./configure && \ make && make install && \ @@ -58,7 +57,7 @@ RUN curl -O -L https://github.com/madler/zlib/archive/v1.2.12.tar.gz && \ # Zstandard RUN curl -O -L https://github.com/facebook/zstd/releases/download/v1.3.7/zstd-1.3.7.tar.gz && \ - tar xvfz zstd-1.3.7.tar.gz && \ + tar xfz zstd-1.3.7.tar.gz && \ cd zstd-1.3.7 && \ CFLAGS="-fPIC -O3" make -j8 && \ make install && \ @@ -66,27 +65,25 @@ RUN curl -O -L https://github.com/facebook/zstd/releases/download/v1.3.7/zstd-1. # Snappy RUN curl -O -L https://github.com/google/snappy/releases/download/1.1.3/snappy-1.1.3.tar.gz && \ - tar xvfz snappy-1.1.3.tar.gz && \ + tar xfz snappy-1.1.3.tar.gz && \ cd snappy-1.1.3 && \ CXXFLAGS="-fPIC -O3" ./configure && \ make && make install && \ rm -rf /snappy-1.1.3 /snappy-1.1.3.tar.gz RUN curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_0j.tar.gz && \ - tar xvfz OpenSSL_1_1_0j.tar.gz && \ + tar xfz OpenSSL_1_1_0j.tar.gz && \ cd openssl-OpenSSL_1_1_0j/ && \ ./Configure -fPIC --prefix=/usr/local/ssl/ linux-x86_64 && \ - make && make install && \ + make -j8 && make install && \ rm -rf /OpenSSL_1_1_0j.tar.gz /openssl-OpenSSL_1_1_0j # LibCurl RUN curl -O -L https://github.com/curl/curl/releases/download/curl-7_61_0/curl-7.61.0.tar.gz && \ - tar xvfz curl-7.61.0.tar.gz && \ + tar xfz curl-7.61.0.tar.gz && \ cd curl-7.61.0 && \ CFLAGS=-fPIC ./configure --with-ssl=/usr/local/ssl/ && \ - make && make install && \ + make -j8 && make install && \ rm -rf /curl-7.61.0.tar.gz /curl-7.61.0 -RUN apt-get install -y dpkg-dev - ENV OPENSSL_ROOT_DIR /usr/local/ssl/ diff --git a/pulsar-client-cpp/pkg/deb/build-deb.sh b/pulsar-client-cpp/pkg/deb/build-deb.sh index 3f2dc5113eb7f..b7409de535a5d 100755 --- a/pulsar-client-cpp/pkg/deb/build-deb.sh +++ b/pulsar-client-cpp/pkg/deb/build-deb.sh @@ -37,8 +37,11 @@ cd BUILD tar xfz $SRC_ROOT_DIR/target/apache-pulsar-$POM_VERSION-src.tar.gz pushd $CPP_DIR +# link libraries for protoc +export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + chmod +x $(find . -name "*.sh") -cmake . -DBUILD_TESTS=OFF -DLINK_STATIC=ON +cmake . -DBUILD_TESTS=OFF -DBUILD_PYTHON_WRAPPER=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON make pulsarShared pulsarSharedNossl pulsarStatic pulsarStaticWithDeps -j 3 popd diff --git a/pulsar-client-cpp/pkg/deb/build-docker-image.sh b/pulsar-client-cpp/pkg/deb/build-docker-image.sh deleted file mode 100755 index 4173912cf78c2..0000000000000 --- a/pulsar-client-cpp/pkg/deb/build-docker-image.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -docker build -t apachepulsar/pulsar-build:debian-9 . diff --git a/pulsar-client-cpp/pkg/deb/docker-build-deb.sh b/pulsar-client-cpp/pkg/deb/docker-build-deb.sh index 55289cc069b20..bc7f42234b343 100755 --- a/pulsar-client-cpp/pkg/deb/docker-build-deb.sh +++ b/pulsar-client-cpp/pkg/deb/docker-build-deb.sh @@ -18,11 +18,17 @@ # under the License. # -set -e +set -ex ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../.. &> /dev/null && pwd )" +IMAGE_NAME=apachepulsar/pulsar-build:debian-9-2.11 -docker pull apachepulsar/pulsar-build:debian-9 +if [[ -z $BUILD_IMAGE ]]; then + # pull the image from DockerHub by default + docker pull $IMAGE_NAME +else + docker build --platform linux/amd64 -t $IMAGE_NAME $ROOT_DIR/pulsar-client-cpp/pkg/deb +fi -docker run -i -v $ROOT_DIR:/pulsar apachepulsar/pulsar-build:debian-9 \ +docker run --platform linux/amd64 -v $ROOT_DIR:/pulsar $IMAGE_NAME \ /pulsar/pulsar-client-cpp/pkg/deb/build-deb.sh diff --git a/pulsar-client-cpp/pkg/rpm/Dockerfile b/pulsar-client-cpp/pkg/rpm/Dockerfile index b3cf4323182c4..8d1693e053df5 100644 --- a/pulsar-client-cpp/pkg/rpm/Dockerfile +++ b/pulsar-client-cpp/pkg/rpm/Dockerfile @@ -19,38 +19,38 @@ # Build pulsar client library in Centos with tools to build static RPM -FROM centos:7 +FROM --platform=linux/amd64 centos:7 RUN yum update -y && \ - yum install -y gcc-c++ make cmake git rpm-build \ - python-devel createrepo libstdc++-static.x86_64 + yum install -y gcc-c++ make rpm-build which \ + createrepo libstdc++-static.x86_64 python3 # Download and compile boost -RUN curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.64.0/source/boost_1_64_0.tar.gz && \ - tar xvfz boost_1_64_0.tar.gz && \ - cd /boost_1_64_0 && \ - ./bootstrap.sh --with-libraries=program_options,filesystem,regex,thread,system,python && \ +# GCC 4.8.2 implementation of std::regex is buggy, so we install boost::regex here +RUN curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz && \ + tar xfz boost_1_79_0.tar.gz && \ + cd boost_1_79_0 && \ + ./bootstrap.sh --with-libraries=regex && \ ./b2 address-model=64 cxxflags=-fPIC link=static threading=multi variant=release install && \ - rm -rf /boost_1_64_0.tar.gz /boost_1_64_0 + rm -rf /boost_1_79_0.tar.gz /boost_1_79_0 -RUN curl -O -L https://github.com/Kitware/CMake/archive/v3.8.2.tar.gz && \ - tar xvfz v3.8.2.tar.gz && \ - cd CMake-3.8.2 && \ - ./configure && \ - make && make install && \ - rm -rf /v3.8.2.tar.gz /CMake-3.8.2 +RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0-linux-x86_64.tar.gz && \ + tar xfz cmake-3.24.0-linux-x86_64.tar.gz && \ + cp cmake-3.24.0-linux-x86_64/bin/* /usr/bin/ && \ + cp -r cmake-3.24.0-linux-x86_64/share/cmake-3.24 /usr/share/ && \ + rm -rf cmake-3.24.0-linux-x86_64 cmake-3.24.0-linux-x86_64.tar.gz # Download and copile protoubf RUN curl -O -L https://github.com/google/protobuf/releases/download/v3.20.0/protobuf-cpp-3.20.0.tar.gz && \ - tar xvfz protobuf-cpp-3.20.0.tar.gz && \ + tar xfz protobuf-cpp-3.20.0.tar.gz && \ cd protobuf-3.20.0/ && \ CXXFLAGS=-fPIC ./configure && \ - make && make install && ldconfig && \ + make -j8 && make install && ldconfig && \ rm -rf /protobuf-cpp-3.20.0.tar.gz /protobuf-3.20.0 # ZLib RUN curl -O -L https://github.com/madler/zlib/archive/v1.2.12.tar.gz && \ - tar xvfz v1.2.12.tar.gz && \ + tar xfz v1.2.12.tar.gz && \ cd zlib-1.2.12 && \ CFLAGS="-fPIC -O3" ./configure && \ make && make install && \ @@ -58,7 +58,7 @@ RUN curl -O -L https://github.com/madler/zlib/archive/v1.2.12.tar.gz && \ # Zstandard RUN curl -O -L https://github.com/facebook/zstd/releases/download/v1.3.7/zstd-1.3.7.tar.gz && \ - tar xvfz zstd-1.3.7.tar.gz && \ + tar xfz zstd-1.3.7.tar.gz && \ cd zstd-1.3.7 && \ CFLAGS="-fPIC -O3" make -j8 && \ make install && \ @@ -66,22 +66,22 @@ RUN curl -O -L https://github.com/facebook/zstd/releases/download/v1.3.7/zstd-1. # Snappy RUN curl -O -L https://github.com/google/snappy/releases/download/1.1.3/snappy-1.1.3.tar.gz && \ - tar xvfz snappy-1.1.3.tar.gz && \ + tar xfz snappy-1.1.3.tar.gz && \ cd snappy-1.1.3 && \ CXXFLAGS="-fPIC -O3" ./configure && \ make && make install && \ rm -rf /snappy-1.1.3 /snappy-1.1.3.tar.gz RUN curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_0j.tar.gz && \ - tar xvfz OpenSSL_1_1_0j.tar.gz && \ + tar xfz OpenSSL_1_1_0j.tar.gz && \ cd openssl-OpenSSL_1_1_0j/ && \ ./Configure -fPIC --prefix=/usr/local/ssl/ linux-x86_64 && \ - make && make install && \ + make -j8 && make install && \ rm -rf /OpenSSL_1_1_0j.tar.gz /openssl-OpenSSL_1_1_0j # LibCurl RUN curl -O -L https://github.com/curl/curl/releases/download/curl-7_61_0/curl-7.61.0.tar.gz && \ - tar xvfz curl-7.61.0.tar.gz && \ + tar xfz curl-7.61.0.tar.gz && \ cd curl-7.61.0 && \ CFLAGS=-fPIC ./configure --with-ssl=/usr/local/ssl/ && \ make && make install && \ diff --git a/pulsar-client-cpp/pkg/rpm/build-docker-image.sh b/pulsar-client-cpp/pkg/rpm/build-docker-image.sh deleted file mode 100755 index faf7ff50bbbab..0000000000000 --- a/pulsar-client-cpp/pkg/rpm/build-docker-image.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -docker build -t apachepulsar/pulsar-build:centos-7 . diff --git a/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh b/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh index e72114d7840b7..4ba02afc3dceb 100755 --- a/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh +++ b/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh @@ -18,11 +18,17 @@ # under the License. # -set -e +set -ex ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../.. &> /dev/null && pwd )" +IMAGE_NAME=apachepulsar/pulsar-build:centos-7-2.11 -docker pull apachepulsar/pulsar-build:centos-7 +if [[ -z $BUILD_IMAGE ]]; then + # pull the image from DockerHub by default + docker pull $IMAGE_NAME +else + docker build --platform linux/amd64 -t $IMAGE_NAME $ROOT_DIR/pulsar-client-cpp/pkg/rpm +fi -docker run -it -v $ROOT_DIR:/pulsar apachepulsar/pulsar-build:centos-7 \ +docker run --platform linux/amd64 -v $ROOT_DIR:/pulsar $IMAGE_NAME \ /pulsar/pulsar-client-cpp/pkg/rpm/build-rpm.sh