|
| 1 | +# Copyright 2021 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +ARG DISTRO_VERSION=8 |
| 16 | +FROM centos:${DISTRO_VERSION} AS devtools |
| 17 | +ARG NCPU=4 |
| 18 | + |
| 19 | +## [START packaging.md] |
| 20 | + |
| 21 | +# Install the minimal development tools, libcurl, OpenSSL, and the c-ares |
| 22 | +# library (required by gRPC): |
| 23 | + |
| 24 | +# ```bash |
| 25 | +RUN dnf makecache && \ |
| 26 | + dnf install -y epel-release && \ |
| 27 | + dnf makecache && \ |
| 28 | + dnf install -y ccache cmake gcc-c++ git make openssl-devel pkgconfig \ |
| 29 | + re2-devel zlib-devel libcurl-devel c-ares-devel tar wget which |
| 30 | +# ``` |
| 31 | + |
| 32 | +# The following steps will install libraries and tools in `/usr/local`. By |
| 33 | +# default CentOS-8 does not search for shared libraries in these directories, |
| 34 | +# there are multiple ways to solve this problem, the following steps are one |
| 35 | +# solution: |
| 36 | + |
| 37 | +# ```bash |
| 38 | +RUN (echo "/usr/local/lib" ; echo "/usr/local/lib64") | \ |
| 39 | + tee /etc/ld.so.conf.d/usrlocal.conf |
| 40 | +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig |
| 41 | +ENV PATH=/usr/local/bin:${PATH} |
| 42 | +# ``` |
| 43 | + |
| 44 | +# #### Abseil |
| 45 | + |
| 46 | +# We need a recent version of Abseil. |
| 47 | + |
| 48 | +# ```bash |
| 49 | +WORKDIR /var/tmp/build |
| 50 | +RUN wget -q https://github.com/abseil/abseil-cpp/archive/20200923.3.tar.gz && \ |
| 51 | + tar -xf 20200923.3.tar.gz && \ |
| 52 | + cd abseil-cpp-20200923.3 && \ |
| 53 | + sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \ |
| 54 | + cmake \ |
| 55 | + -DCMAKE_BUILD_TYPE=Release \ |
| 56 | + -DBUILD_TESTING=OFF \ |
| 57 | + -DBUILD_SHARED_LIBS=yes \ |
| 58 | + -DCMAKE_CXX_STANDARD=11 \ |
| 59 | + -H. -Bcmake-out && \ |
| 60 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 61 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 62 | + ldconfig |
| 63 | +# ``` |
| 64 | + |
| 65 | +# #### Protobuf |
| 66 | + |
| 67 | +# We need to install a version of Protobuf that is recent enough to support the |
| 68 | +# Google Cloud Platform proto files: |
| 69 | + |
| 70 | +# ```bash |
| 71 | +WORKDIR /var/tmp/build |
| 72 | +RUN wget -q https://github.com/google/protobuf/archive/v3.14.0.tar.gz && \ |
| 73 | + tar -xf v3.14.0.tar.gz && \ |
| 74 | + cd protobuf-3.14.0/cmake && \ |
| 75 | + cmake \ |
| 76 | + -DCMAKE_BUILD_TYPE=Release \ |
| 77 | + -DBUILD_SHARED_LIBS=yes \ |
| 78 | + -Dprotobuf_BUILD_TESTS=OFF \ |
| 79 | + -H. -Bcmake-out && \ |
| 80 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 81 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 82 | + ldconfig |
| 83 | +# ``` |
| 84 | + |
| 85 | +# #### gRPC |
| 86 | + |
| 87 | +# We also need a version of gRPC that is recent enough to support the Google |
| 88 | +# Cloud Platform proto files. We manually install it using: |
| 89 | + |
| 90 | +# ```bash |
| 91 | +WORKDIR /var/tmp/build |
| 92 | +RUN wget -q https://github.com/grpc/grpc/archive/v1.35.0.tar.gz && \ |
| 93 | + tar -xf v1.35.0.tar.gz && \ |
| 94 | + cd grpc-1.35.0 && \ |
| 95 | + cmake \ |
| 96 | + -DCMAKE_BUILD_TYPE=Release \ |
| 97 | + -DgRPC_INSTALL=ON \ |
| 98 | + -DgRPC_BUILD_TESTS=OFF \ |
| 99 | + -DgRPC_ABSL_PROVIDER=package \ |
| 100 | + -DgRPC_CARES_PROVIDER=package \ |
| 101 | + -DgRPC_PROTOBUF_PROVIDER=package \ |
| 102 | + -DgRPC_RE2_PROVIDER=package \ |
| 103 | + -DgRPC_SSL_PROVIDER=package \ |
| 104 | + -DgRPC_ZLIB_PROVIDER=package \ |
| 105 | + -H. -Bcmake-out && \ |
| 106 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 107 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 108 | + ldconfig |
| 109 | +# ``` |
| 110 | + |
| 111 | +# #### crc32c |
| 112 | + |
| 113 | +# The project depends on the Crc32c library, we need to compile this from |
| 114 | +# source: |
| 115 | + |
| 116 | +# ```bash |
| 117 | +WORKDIR /var/tmp/build |
| 118 | +RUN wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \ |
| 119 | + tar -xf 1.1.0.tar.gz && \ |
| 120 | + cd crc32c-1.1.0 && \ |
| 121 | + cmake \ |
| 122 | + -DCMAKE_BUILD_TYPE=Release \ |
| 123 | + -DBUILD_SHARED_LIBS=yes \ |
| 124 | + -DCRC32C_BUILD_TESTS=OFF \ |
| 125 | + -DCRC32C_BUILD_BENCHMARKS=OFF \ |
| 126 | + -DCRC32C_USE_GLOG=OFF \ |
| 127 | + -H. -Bcmake-out && \ |
| 128 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 129 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 130 | + ldconfig |
| 131 | +# ``` |
| 132 | + |
| 133 | +# #### nlohmann_json library |
| 134 | + |
| 135 | +# The project depends on the nlohmann_json library. We use CMake to |
| 136 | +# install it as this installs the necessary CMake configuration files. |
| 137 | +# Note that this is a header-only library, and often installed manually. |
| 138 | +# This leaves your environment without support for CMake pkg-config. |
| 139 | + |
| 140 | +# ```bash |
| 141 | +WORKDIR /var/tmp/build |
| 142 | +RUN wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \ |
| 143 | + tar -xzf v3.9.0.tar.gz && \ |
| 144 | + cd json-3.9.0 && \ |
| 145 | + cmake \ |
| 146 | + -DCMAKE_BUILD_TYPE=Release \ |
| 147 | + -DBUILD_SHARED_LIBS=yes \ |
| 148 | + -DBUILD_TESTING=OFF \ |
| 149 | + -H. -Bcmake-out/nlohmann/json && \ |
| 150 | + cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \ |
| 151 | + ldconfig |
| 152 | +# ``` |
| 153 | + |
| 154 | +## [END packaging.md] |
0 commit comments