Skip to content

Instantly share code, notes, and snippets.

@jiazhai
Created May 25, 2020 15:13
Show Gist options
  • Save jiazhai/aaf7e3d4006aea34f7860429a8bf78ff to your computer and use it in GitHub Desktop.
Save jiazhai/aaf7e3d4006aea34f7860429a8bf78ff to your computer and use it in GitHub Desktop.
Dockerfile to build pulsar cpp client based on centos6
#
# 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 pulsar client library in Centos with tools to build static RPM
FROM centos:6
RUN yum update -y && \
yum install -y wget && \
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo && \
yum install -y devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++ &&\
ln -s /opt/rh/devtoolset-2/root/usr/bin/gcc /usr/bin/gcc && \
ln -s /opt/rh/devtoolset-2/root/usr/bin/cpp /usr/bin/cpp && \
ln -s /opt/rh/devtoolset-2/root/usr/bin/c++ /usr/bin/c++ && \
ln -s /opt/rh/devtoolset-2/root/usr/bin/g++ /usr/bin/g++ && \
ln -s /opt/rh/devtoolset-2/root/usr/bin/cc /usr/bin/cc && \
export CC=/usr/bin/gcc && export CPP=/usr/bin/cpp && export CXX=/usr/bin/c++ && \
yum install -y make git rpm-build \
python-devel createrepo libstdc++-static.x86_64
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 && \
cd / && rm -rf /v3.8.2.tar.gz /CMake-3.8.2
# Download and compile boost
RUN curl -O -L https://dl.bintray.com/boostorg/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 && \
./b2 address-model=64 cxxflags=-fPIC link=static threading=multi variant=release install && \
cd / && rm -rf /boost_1_64_0.tar.gz /boost_1_64_0
# Compile JSON CPP
RUN curl -O -L https://github.com/open-source-parsers/jsoncpp/archive/1.8.0.tar.gz && \
tar xvfz 1.8.0.tar.gz && \
cd jsoncpp-1.8.0 && \
cmake . -DCMAKE_POSITION_INDEPENDENT_CODE=ON && \
make && make install && \
cd / && rm -rf /1.8.0.tar.gz /jsoncpp-1.8.0
# Download and copile protoubf
RUN curl -O -L https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz && \
tar xvfz protobuf-cpp-3.3.0.tar.gz && \
cd protobuf-3.3.0/ && \
CXXFLAGS=-fPIC ./configure && \
make && make install && ldconfig && \
cd / && rm -rf /protobuf-cpp-3.3.0.tar.gz /protobuf-3.3.0
# ZLib
RUN curl -O -L https://github.com/madler/zlib/archive/v1.2.11.tar.gz && \
tar xvfz v1.2.11.tar.gz && \
cd zlib-1.2.11 && \
CFLAGS="-fPIC -O3" ./configure && \
make && make install && \
cd / && rm -rf /v1.2.11.tar.gz /zlib-1.2.11
# 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 && \
cd / && rm -rf /zstd-1.3.7 /zstd-1.3.7.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 && \
cd openssl-OpenSSL_1_1_0j/ && \
./Configure -fPIC --prefix=/usr/local/ssl/ linux-x86_64 && \
make && make install && \
cd / && 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 && \
cd curl-7.61.0 && \
CFLAGS=-fPIC ./configure --with-ssl=/usr/local/ssl/ && \
make && make install && \
cd / && rm -rf /curl-7.61.0.tar.gz /curl-7.61.0
ENV OPENSSL_ROOT_DIR /usr/local/ssl/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment