You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2020/05/31 20:04:37 UTC

[pulsar] branch master updated: Add scripts to build Alpine APK packages and Python wheels (#7101)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 7471786  Add scripts to build Alpine APK packages and Python wheels (#7101)
7471786 is described below

commit 74717866ac87da13f56ac19fc313d8a1d50ab032
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Sun May 31 13:04:21 2020 -0700

    Add scripts to build Alpine APK packages and Python wheels (#7101)
---
 pulsar-client-cpp/CMakeLists.txt                   |  2 +-
 pulsar-client-cpp/docker/alpine/Dockerfile         | 97 ++++++++++++++++++++++
 .../docker/alpine/Dockerfile-alpine-3.8            | 97 ++++++++++++++++++++++
 .../docker/alpine/build-alpine-image.sh            | 33 ++++++++
 .../alpine/build-wheel-file-within-docker.sh       | 38 +++++++++
 pulsar-client-cpp/docker/alpine/build-wheel.sh     | 34 ++++++++
 pulsar-client-cpp/lib/CMakeLists.txt               | 16 ++--
 pulsar-client-cpp/pkg/apk/.gitignore               |  4 +
 pulsar-client-cpp/pkg/apk/APKBUILD                 | 57 +++++++++++++
 pulsar-client-cpp/pkg/apk/build-apk.sh             | 42 ++++++++++
 pulsar-client-cpp/pkg/apk/docker-build-apk.sh      | 29 +++++++
 11 files changed, 443 insertions(+), 6 deletions(-)

diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt
index af7cb5b..5969583 100644
--- a/pulsar-client-cpp/CMakeLists.txt
+++ b/pulsar-client-cpp/CMakeLists.txt
@@ -169,7 +169,7 @@ if (BUILD_PYTHON_WRAPPER)
         list(GET PYTHONLIBS_VERSION_NO_LIST 1 PYTHONLIBS_VERSION_MINOR)
         set(BOOST_PYTHON_NAME_POSTFIX ${PYTHONLIBS_VERSION_MAJOR}${PYTHONLIBS_VERSION_MINOR})
         # For python3 the lib name is boost_python3
-        set(BOOST_PYTHON_NAME_LIST python3;python3-mt;python-py${BOOST_PYTHON_NAME_POSTFIX};python${BOOST_PYTHON_NAME_POSTFIX}-mt;python${BOOST_PYTHON_NAME_POSTFIX})
+        set(BOOST_PYTHON_NAME_LIST python36;python37;python38;python3;python3-mt;python-py${BOOST_PYTHON_NAME_POSTFIX};python${BOOST_PYTHON_NAME_POSTFIX}-mt;python${BOOST_PYTHON_NAME_POSTFIX})
     else ()
         # Regular boost_python
         set(BOOST_PYTHON_NAME_LIST python;python-mt;python-py27;python27-mt;python27)
diff --git a/pulsar-client-cpp/docker/alpine/Dockerfile b/pulsar-client-cpp/docker/alpine/Dockerfile
new file mode 100644
index 0000000..8e736c7
--- /dev/null
+++ b/pulsar-client-cpp/docker/alpine/Dockerfile
@@ -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.
+#
+
+
+FROM alpine:3.11
+
+RUN apk update \
+    && apk upgrade \
+    && apk add --no-cache \
+    cmake make build-base curl \
+    python3-dev \
+    libffi-dev \
+    perl linux-headers bash \
+    alpine-sdk
+
+####################################
+# These dependencies can be found in Ubuntu but they're not compiled with -fPIC,
+# so they cannot be statically linked into a shared library
+####################################
+
+# Download and compile boost
+RUN curl -O -L https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz && \
+    tar xfz boost_1_72_0.tar.gz && \
+    cd /boost_1_72_0 && \
+    ./bootstrap.sh --with-libraries=program_options,regex,system,python --with-python=/usr/bin/python3 && \
+    ./b2  cxxflags=-fPIC link=static threading=multi variant=release install && \
+    rm -rf /boost_1_72_0.tar.gz /boost_1_72_0
+
+# ZLib
+RUN curl -O -L https://zlib.net/zlib-1.2.11.tar.gz  && \
+    tar xfz zlib-1.2.11.tar.gz && \
+    cd zlib-1.2.11 && \
+    CFLAGS="-fPIC -O3" ./configure && \
+    make -j4 && make install && \
+    rm -rf /zlib-1.2.11.tar.gz /zlib-1.2.11
+
+# Compile OpenSSL
+RUN curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_0j.tar.gz && \
+   tar xfz OpenSSL_1_1_0j.tar.gz && \
+   cd openssl-OpenSSL_1_1_0j/ && \
+   ./Configure -fPIC no-shared linux-x86_64 && \
+   make -j8 && make install && \
+   rm -rf /OpenSSL_1_1_0j.tar.gz /openssl-OpenSSL_1_1_0j
+
+# Download and copile protoubf
+RUN curl -O -L  https://github.com/google/protobuf/releases/download/v3.11.3/protobuf-cpp-3.11.3.tar.gz && \
+    tar xvfz protobuf-cpp-3.11.3.tar.gz && \
+    cd protobuf-3.11.3/ && \
+    CXXFLAGS=-fPIC ./configure && \
+    make -j8 && make install && \
+    rm -rf /protobuf-cpp-3.11.3.tar.gz /protobuf-3.11.3
+
+# 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 && \
+    cd curl-7.61.0 && \
+    CFLAGS=-fPIC ./configure && \
+    make -j8 && make install && \
+    rm -rf /curl-7.61.0.tar.gz /curl-7.61.0
+
+# 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 && \
+    cd zstd-1.3.7 && \
+    CFLAGS="-fPIC -O3" make -j8 && \
+    make install && \
+    rm -rf /zstd-1.3.7 /zstd-1.3.7.tar.gz
+
+# Snappy
+RUN curl -L https://github.com/google/snappy/archive/1.1.8.tar.gz --output snappy-1.1.8.tar.gz && \
+    tar xvfz snappy-1.1.8.tar.gz && \
+    cd snappy-1.1.8 && \
+    CXXFLAGS="-fPIC -O3" cmake . && \
+    make -j8 && make install && \
+    rm -rf /snappy-1.1.8 /snappy-1.1.8.tar.gz
+
+
+RUN pip3 install wheel twine
+
+RUN adduser pulsar -D && \
+    addgroup pulsar abuild
diff --git a/pulsar-client-cpp/docker/alpine/Dockerfile-alpine-3.8 b/pulsar-client-cpp/docker/alpine/Dockerfile-alpine-3.8
new file mode 100644
index 0000000..5391dde
--- /dev/null
+++ b/pulsar-client-cpp/docker/alpine/Dockerfile-alpine-3.8
@@ -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.
+#
+
+
+FROM alpine:3.8
+
+RUN apk update \
+    && apk upgrade \
+    && apk add --no-cache \
+    cmake make build-base curl \
+    python3-dev \
+    libffi-dev \
+    perl linux-headers bash \
+    alpine-sdk
+
+####################################
+# These dependencies can be found in Ubuntu but they're not compiled with -fPIC,
+# so they cannot be statically linked into a shared library
+####################################
+
+# Download and compile boost
+RUN curl -O -L https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz && \
+    tar xfz boost_1_72_0.tar.gz && \
+    cd /boost_1_72_0 && \
+    ./bootstrap.sh --with-libraries=program_options,regex,system,python --with-python=/usr/bin/python3 && \
+    ./b2  cxxflags=" -fPIC -I/usr/include/python3.6m" link=static threading=multi variant=release install && \
+    rm -rf /boost_1_72_0.tar.gz /boost_1_72_0
+
+# ZLib
+RUN curl -O -L https://zlib.net/zlib-1.2.11.tar.gz  && \
+    tar xfz zlib-1.2.11.tar.gz && \
+    cd zlib-1.2.11 && \
+    CFLAGS="-fPIC -O3" ./configure && \
+    make -j4 && make install && \
+    rm -rf /zlib-1.2.11.tar.gz /zlib-1.2.11
+
+# Compile OpenSSL
+RUN curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_0j.tar.gz && \
+   tar xfz OpenSSL_1_1_0j.tar.gz && \
+   cd openssl-OpenSSL_1_1_0j/ && \
+   ./Configure -fPIC no-shared linux-x86_64 && \
+   make -j8 && make install && \
+   rm -rf /OpenSSL_1_1_0j.tar.gz /openssl-OpenSSL_1_1_0j
+
+# Download and copile protoubf
+RUN curl -O -L  https://github.com/google/protobuf/releases/download/v3.11.3/protobuf-cpp-3.11.3.tar.gz && \
+    tar xvfz protobuf-cpp-3.11.3.tar.gz && \
+    cd protobuf-3.11.3/ && \
+    CXXFLAGS=-fPIC ./configure && \
+    make -j8 && make install && \
+    rm -rf /protobuf-cpp-3.11.3.tar.gz /protobuf-3.11.3
+
+# 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 && \
+    cd curl-7.61.0 && \
+    CFLAGS=-fPIC ./configure && \
+    make -j8 && make install && \
+    rm -rf /curl-7.61.0.tar.gz /curl-7.61.0
+
+# Zstandard
+RUN curl -O -L https://github.com/facebook/zstd/releases/download/v1.4.4/zstd-1.4.4.tar.gz && \
+    tar xvfz zstd-1.4.4.tar.gz && \
+    cd zstd-1.4.4 && \
+    CFLAGS="-fPIC -O3" make -j8 && \
+    make install && \
+    rm -rf /zstd-1.4.4 /zstd-1.4.4.tar.gz
+
+# Snappy
+RUN curl -L https://github.com/google/snappy/archive/1.1.8.tar.gz --output snappy-1.1.8.tar.gz && \
+    tar xvfz snappy-1.1.8.tar.gz && \
+    cd snappy-1.1.8 && \
+    CXXFLAGS="-fPIC -O3" cmake . && \
+    make -j8 && make install && \
+    rm -rf /snappy-1.1.8 /snappy-1.1.8.tar.gz
+
+
+RUN pip3 install wheel twine
+
+RUN adduser pulsar -D && \
+    addgroup pulsar abuild
diff --git a/pulsar-client-cpp/docker/alpine/build-alpine-image.sh b/pulsar-client-cpp/docker/alpine/build-alpine-image.sh
new file mode 100755
index 0000000..2bde393
--- /dev/null
+++ b/pulsar-client-cpp/docker/alpine/build-alpine-image.sh
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+# Build Alpine Image with pulsar python3 and cpp client libraries
+
+set -e
+
+ROOT_DIR=$(git rev-parse --show-toplevel)
+
+IMAGE_NAME=${IMAGE_NAME:-apachepulsar/pulsar-build:alpine-3.11}
+
+echo "==== Building image $IMAGE_NAME"
+
+cd $ROOT_DIR/pulsar-client-cpp/docker/alpine
+docker build -t $IMAGE_NAME -f $ROOT_DIR/pulsar-client-cpp/docker/alpine/Dockerfile .
+
+echo "==== Successfully built image $IMAGE_NAME"
diff --git a/pulsar-client-cpp/docker/alpine/build-wheel-file-within-docker.sh b/pulsar-client-cpp/docker/alpine/build-wheel-file-within-docker.sh
new file mode 100755
index 0000000..cc8932a
--- /dev/null
+++ b/pulsar-client-cpp/docker/alpine/build-wheel-file-within-docker.sh
@@ -0,0 +1,38 @@
+#!/bin/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.
+#
+
+set -e -x
+
+ROOT_DIR=$(git rev-parse --show-toplevel)
+cd $ROOT_DIR/pulsar-client-cpp
+PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR:-/usr/include/python3.8}
+PYTHON_LIBRARY=${PYTHON_LIBRARY:-/usr/lib/python3.8}
+
+cmake .  -DBUILD_TESTS=OFF \
+          -DBUILD_PYTHON_WRAPPER=ON \
+          -DCMAKE_BUILD_TYPE=Release \
+          -DLINK_STATIC=ON  \
+          -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} \
+          -DPYTHON_LIBRARY=${PYTHON_LIBRARY}
+
+make -j2 _pulsar
+
+cd python
+python3 setup.py bdist_wheel
diff --git a/pulsar-client-cpp/docker/alpine/build-wheel.sh b/pulsar-client-cpp/docker/alpine/build-wheel.sh
new file mode 100755
index 0000000..92993b7
--- /dev/null
+++ b/pulsar-client-cpp/docker/alpine/build-wheel.sh
@@ -0,0 +1,34 @@
+#!/bin/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.
+#
+
+set -e
+
+ROOT_DIR=$(git rev-parse --show-toplevel)
+PROJECT_VERSION=$(python $ROOT_DIR/src/get-project-version.py)
+IMAGE_NAME=${IMAGE_NAME:-apachepulsar/pulsar-build:alpine-3.11}
+
+ROOT_DIR=$(git rev-parse --show-toplevel)
+cd $ROOT_DIR
+
+echo "Using image: $IMAGE_NAME"
+VOLUME_OPTION=${VOLUME_OPTION:-"-v $ROOT_DIR:/pulsar"}
+COMMAND="/pulsar/pulsar-client-cpp/docker/alpine/build-wheel-file-within-docker.sh"
+DOCKER_CMD="docker run -i ${VOLUME_OPTION} ${IMAGE_NAME}"
+$DOCKER_CMD bash -c "${COMMAND}"
diff --git a/pulsar-client-cpp/lib/CMakeLists.txt b/pulsar-client-cpp/lib/CMakeLists.txt
index 74200c0..1ca2bd4 100644
--- a/pulsar-client-cpp/lib/CMakeLists.txt
+++ b/pulsar-client-cpp/lib/CMakeLists.txt
@@ -58,7 +58,8 @@ if (WIN32)
 endif()
 
 add_library(pulsarShared SHARED ${PULSAR_SOURCES})
-set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME ${LIB_NAME_SHARED} VERSION ${LIBRARY_VERSION})
+set_property(TARGET pulsarShared PROPERTY OUTPUT_NAME ${LIB_NAME_SHARED})
+set_property(TARGET pulsarShared PROPERTY VERSION ${LIBRARY_VERSION})
 target_link_libraries(pulsarShared ${COMMON_LIBS} ${CMAKE_DL_LIBS})
 
 
@@ -75,11 +76,13 @@ if (NOT ${RECORD_OPENSSL_CRYPTO_LIBRARY} MATCHES ".+\\.a$")
 endif ()
 
 add_library(pulsarSharedNossl SHARED ${PULSAR_SOURCES})
-set_target_properties(pulsarSharedNossl PROPERTIES OUTPUT_NAME ${LIB_NAME_SHARED}nossl VERSION ${LIBRARY_VERSION})
+set_property(TARGET pulsarSharedNossl PROPERTY OUTPUT_NAME ${LIB_NAME_SHARED}nossl)
+set_property(TARGET pulsarSharedNossl PROPERTY VERSION ${LIBRARY_VERSION})
 target_link_libraries(pulsarSharedNossl ${COMMON_LIBS_NOSSL} ${CMAKE_DL_LIBS})
 
 add_library(pulsarStatic STATIC ${PULSAR_SOURCES})
-set_target_properties(pulsarStatic PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION})
+set_property(TARGET pulsarStatic PROPERTY OUTPUT_NAME ${LIB_NAME})
+set_property(TARGET pulsarStatic PROPERTY VERSION ${LIBRARY_VERSION})
 target_compile_definitions(pulsarStatic PRIVATE PULSAR_STATIC)
 
 if (MSVC)
@@ -92,7 +95,7 @@ endif()
 # required dependencies except ssl
 if (LINK_STATIC)
     if (MSVC)
-        
+
         # This function is to remove either "debug" or "optimized" library names
         # out of the COMMON_LIBS list and return the sanitized list of libraries
         function(remove_libtype LIBLIST LIBTYPE OUTLIST)
@@ -112,7 +115,10 @@ if (LINK_STATIC)
         target_include_directories(pulsarStaticWithDeps PRIVATE ${dlfcn-win32_INCLUDE_DIRS})
         remove_libtype("${COMMON_LIBS}" "optimized" DEBUG_STATIC_LIBS)
         remove_libtype("${COMMON_LIBS}" "debug" STATIC_LIBS)
-        set_target_properties(pulsarStaticWithDeps PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG ${DEBUG_STATIC_LIBS} STATIC_LIBRARY_FLAGS_RELEASE ${STATIC_LIBS} OUTPUT_NAME ${LIB_NAME}WithDeps VERSION ${LIBRARY_VERSION})
+        set_property(TARGET pulsarStaticWithDeps PROPERTY STATIC_LIBRARY_FLAGS_DEBUG ${DEBUG_STATIC_LIBS})
+        set_property(TARGET pulsarStaticWithDeps PROPERTY STATIC_LIBRARY_FLAGS_RELEASE ${STATIC_LIBS})
+        set_property(TARGET pulsarStaticWithDeps PROPERTY OUTPUT_NAME ${LIB_NAME}WithDeps)
+        set_property(TARGET pulsarStaticWithDeps PROPERTY VERSION ${LIBRARY_VERSION})
         install(TARGETS pulsarStaticWithDeps DESTINATION lib)
     else()
         # Build a list of the requird .a libs (except ssl) to merge
diff --git a/pulsar-client-cpp/pkg/apk/.gitignore b/pulsar-client-cpp/pkg/apk/.gitignore
new file mode 100644
index 0000000..7012f3a
--- /dev/null
+++ b/pulsar-client-cpp/pkg/apk/.gitignore
@@ -0,0 +1,4 @@
+pkg
+perf
+examples
+lib
diff --git a/pulsar-client-cpp/pkg/apk/APKBUILD b/pulsar-client-cpp/pkg/apk/APKBUILD
new file mode 100644
index 0000000..10bdd72
--- /dev/null
+++ b/pulsar-client-cpp/pkg/apk/APKBUILD
@@ -0,0 +1,57 @@
+#
+# 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.
+#
+
+# Maintainer: "Apache Pulsar <de...@pulsar.apache.org>"
+
+pkgname="apache-pulsar-client"
+pkgver="$POM_VERSION"
+pkgrel=0
+pkgdesc="Apache Pulsar - distributed pub-sub messaging system"
+url="https://pulsar.apache.org"
+arch="all"
+license="https://www.apache.org/licenses/LICENSE-2.0.txt"
+depends=""
+makedepends="cmake"
+install=""
+subpackages="$pkgname-dev"
+source=""
+builddir="$srcdir/"
+
+build() {
+  set -x -e
+	if [ "$CBUILD" != "$CHOST" ]; then
+		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
+	fi
+	cmake \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_INSTALL_LIBDIR=lib \
+		-DBUILD_SHARED_LIBS=True \
+		-DCMAKE_BUILD_TYPE=Release \
+		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
+		-DCMAKE_C_FLAGS="$CFLAGS" \
+		-DBUILD_TESTS=OFF \
+    -DBUILD_PYTHON_WRAPPER=OFF \
+    -DLINK_STATIC=ON  \
+		${CMAKE_CROSSOPTS} ${SRC_ROOT_DIR}/pulsar-client-cpp
+	make
+}
+
+package() {
+	make DESTDIR="$pkgdir" install
+}
diff --git a/pulsar-client-cpp/pkg/apk/build-apk.sh b/pulsar-client-cpp/pkg/apk/build-apk.sh
new file mode 100755
index 0000000..3ef5cb9
--- /dev/null
+++ b/pulsar-client-cpp/pkg/apk/build-apk.sh
@@ -0,0 +1,42 @@
+#!/bin/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.
+#
+
+set -e -x
+
+export SRC_ROOT_DIR=$(git rev-parse --show-toplevel)
+cd $SRC_ROOT_DIR/pulsar-client-cpp/pkg/apk
+
+VERSION=`python3 $SRC_ROOT_DIR/src/get-project-version.py`
+# Sanitize the version string
+export POM_VERSION=`echo $VERSION | sed -E 's/-[a-z]+-/./' | sed -E 's/.[A-Z]+././'`
+
+echo "POM_VERSION: $POM_VERSION"
+
+abuild-keygen -a -i -n
+chmod 755 ~
+chmod 755 ~/.abuild
+chmod 644 ~/.abuild/*
+
+mkdir -p /root/packages
+chmod 777 /root/packages
+
+sudo -E -u pulsar abuild -r
+
+mv /root/packages/pkg .
diff --git a/pulsar-client-cpp/pkg/apk/docker-build-apk.sh b/pulsar-client-cpp/pkg/apk/docker-build-apk.sh
new file mode 100755
index 0000000..815364c
--- /dev/null
+++ b/pulsar-client-cpp/pkg/apk/docker-build-apk.sh
@@ -0,0 +1,29 @@
+#!/bin/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.
+#
+
+set -e
+
+ROOT_DIR=$(git rev-parse --show-toplevel)
+IMAGE=apachepulsar/pulsar-build:alpine-3.11
+
+docker pull $IMAGE
+
+docker run -i -v $ROOT_DIR:/pulsar $IMAGE \
+        /pulsar/pulsar-client-cpp/pkg/apk/build-apk.sh