|
| 1 | +# Copyright 2022 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 | +# https://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 | +FROM rockylinux/rockylinux:9 |
| 16 | +ARG NCPU=4 |
| 17 | + |
| 18 | +## [BEGIN packaging.md] |
| 19 | + |
| 20 | +# Install the minimal development tools, libcurl, OpenSSL, and the c-ares |
| 21 | +# library (required by gRPC): |
| 22 | + |
| 23 | +# ```bash |
| 24 | +RUN dnf makecache && \ |
| 25 | + dnf update -y && \ |
| 26 | + dnf install -y epel-release && \ |
| 27 | + dnf makecache && \ |
| 28 | + dnf install -y ccache cmake curl findutils gcc-c++ git make openssl-devel \ |
| 29 | + patch re2-devel zlib-devel libcurl-devel c-ares-devel tar wget which |
| 30 | +# ``` |
| 31 | + |
| 32 | +# Rocky Linux's version of `pkg-config` (https://github.com/pkgconf/pkgconf) is |
| 33 | +# slow when handling `.pc` files with lots of `Requires:` deps, which happens |
| 34 | +# with Abseil. If you plan to use `pkg-config` with any of the installed |
| 35 | +# artifacts, you may want to use a recent version of the standard `pkg-config` |
| 36 | +# binary. If not, `dnf install pkgconfig` should work. |
| 37 | + |
| 38 | +# ```bash |
| 39 | +WORKDIR /var/tmp/build/pkg-config-cpp |
| 40 | +RUN curl -sSL https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz | \ |
| 41 | + tar -xzf - --strip-components=1 && \ |
| 42 | + ./configure --with-internal-glib && \ |
| 43 | + make -j ${NCPU:-4} && \ |
| 44 | + make install && \ |
| 45 | + ldconfig |
| 46 | +# ``` |
| 47 | + |
| 48 | +# The following steps will install libraries and tools in `/usr/local`. By |
| 49 | +# default, Rocky Linux 9 does not search for shared libraries in these |
| 50 | +# directories, there are multiple ways to solve this problem, the following |
| 51 | +# steps are one solution: |
| 52 | + |
| 53 | +# ```bash |
| 54 | +RUN (echo "/usr/local/lib" ; echo "/usr/local/lib64") | \ |
| 55 | + tee /etc/ld.so.conf.d/usrlocal.conf |
| 56 | +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig |
| 57 | +ENV PATH=/usr/local/bin:${PATH} |
| 58 | +# ``` |
| 59 | + |
| 60 | +# #### Abseil |
| 61 | + |
| 62 | +# Rocky Linux 9 includes a package for Abseil, unfortunately, this package is |
| 63 | +# incomplete, as it lacks the CMake support files for it. We need to compile |
| 64 | +# Abseiil from source. |
| 65 | + |
| 66 | +# :warning: By default, Abseil's ABI changes depending on whether it is used |
| 67 | +# with C++ >= 17 enabled or not. Installing Abseil with the default |
| 68 | +# configuration is error-prone, unless you can guarantee that all the code using |
| 69 | +# Abseil (gRPC, google-cloud-cpp, your own code, etc.) is compiled with the same |
| 70 | +# C++ version. We recommend that you switch the default configuration to pin |
| 71 | +# Abseil's ABI to the version used at compile time. In Rocky Linux 9 the |
| 72 | +# compiler defaults to C++17. Therefore, we change `absl/base/options.h` to |
| 73 | +# **always** use `std::any`, `std::string_view`, and `std::variant`. See |
| 74 | +# [abseil/abseil-cpp#696] for more information. |
| 75 | + |
| 76 | +# ```bash |
| 77 | +WORKDIR /var/tmp/build/abseil-cpp |
| 78 | +RUN curl -sSL https://github.com/abseil/abseil-cpp/archive/20220623.1.tar.gz | \ |
| 79 | + tar -xzf - --strip-components=1 && \ |
| 80 | + sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 1/' "absl/base/options.h" && \ |
| 81 | + cmake \ |
| 82 | + -DCMAKE_BUILD_TYPE=Release \ |
| 83 | + -DABSL_BUILD_TESTING=OFF \ |
| 84 | + -DBUILD_SHARED_LIBS=yes \ |
| 85 | + -S . -B cmake-out && \ |
| 86 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 87 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 88 | + ldconfig |
| 89 | +# ``` |
| 90 | + |
| 91 | +# #### Protobuf |
| 92 | + |
| 93 | +# Rocky Linux ships with Protobuf 3.14.x. Some of the libraries in |
| 94 | +# `google-cloud-cpp` require Protobuf >= 3.15.8. For simplicity, we will just |
| 95 | +# install Protobuf (and any downstream packages) from source. |
| 96 | + |
| 97 | +# ```bash |
| 98 | +WORKDIR /var/tmp/build/protobuf |
| 99 | +RUN curl -sSL https://github.com/protocolbuffers/protobuf/archive/v21.9.tar.gz | \ |
| 100 | + tar -xzf - --strip-components=1 && \ |
| 101 | + cmake \ |
| 102 | + -DCMAKE_BUILD_TYPE=Release \ |
| 103 | + -DBUILD_SHARED_LIBS=yes \ |
| 104 | + -Dprotobuf_BUILD_TESTS=OFF \ |
| 105 | + -Dprotobuf_ABSL_PROVIDER=package \ |
| 106 | + -S . -B cmake-out && \ |
| 107 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 108 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 109 | + ldconfig |
| 110 | +# ``` |
| 111 | + |
| 112 | +# #### gRPC |
| 113 | + |
| 114 | +# We also need a version of gRPC that is recent enough to support the Google |
| 115 | +# Cloud Platform proto files. Note that gRPC overrides the default C++ standard |
| 116 | +# version to C++14, we need to configure it to use the platform's default. We |
| 117 | +# manually install it using: |
| 118 | + |
| 119 | +# ```bash |
| 120 | +WORKDIR /var/tmp/build/grpc |
| 121 | +RUN curl -sSL https://github.com/grpc/grpc/archive/v1.49.1.tar.gz | \ |
| 122 | + tar -xzf - --strip-components=1 && \ |
| 123 | + cmake \ |
| 124 | + -DCMAKE_CXX_STANDARD=17 \ |
| 125 | + -DCMAKE_BUILD_TYPE=Release \ |
| 126 | + -DBUILD_SHARED_LIBS=yes \ |
| 127 | + -DgRPC_INSTALL=ON \ |
| 128 | + -DgRPC_BUILD_TESTS=OFF \ |
| 129 | + -DgRPC_ABSL_PROVIDER=package \ |
| 130 | + -DgRPC_CARES_PROVIDER=package \ |
| 131 | + -DgRPC_PROTOBUF_PROVIDER=package \ |
| 132 | + -DgRPC_RE2_PROVIDER=package \ |
| 133 | + -DgRPC_SSL_PROVIDER=package \ |
| 134 | + -DgRPC_ZLIB_PROVIDER=package \ |
| 135 | + -S . -B cmake-out && \ |
| 136 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 137 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 138 | + ldconfig |
| 139 | +# ``` |
| 140 | + |
| 141 | +# #### crc32c |
| 142 | + |
| 143 | +# The project depends on the Crc32c library, we need to compile this from |
| 144 | +# source: |
| 145 | + |
| 146 | +# ```bash |
| 147 | +WORKDIR /var/tmp/build/crc32c |
| 148 | +RUN curl -sSL https://github.com/google/crc32c/archive/1.1.2.tar.gz | \ |
| 149 | + tar -xzf - --strip-components=1 && \ |
| 150 | + cmake \ |
| 151 | + -DCMAKE_BUILD_TYPE=Release \ |
| 152 | + -DBUILD_SHARED_LIBS=yes \ |
| 153 | + -DCRC32C_BUILD_TESTS=OFF \ |
| 154 | + -DCRC32C_BUILD_BENCHMARKS=OFF \ |
| 155 | + -DCRC32C_USE_GLOG=OFF \ |
| 156 | + -S . -B cmake-out && \ |
| 157 | + cmake --build cmake-out -- -j ${NCPU:-4} && \ |
| 158 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 159 | + ldconfig |
| 160 | +# ``` |
| 161 | + |
| 162 | +# #### nlohmann_json library |
| 163 | + |
| 164 | +# The project depends on the nlohmann_json library. We use CMake to |
| 165 | +# install it as this installs the necessary CMake configuration files. |
| 166 | +# Note that this is a header-only library, and often installed manually. |
| 167 | +# This leaves your environment without support for CMake pkg-config. |
| 168 | + |
| 169 | +# ```bash |
| 170 | +WORKDIR /var/tmp/build/json |
| 171 | +RUN curl -sSL https://github.com/nlohmann/json/archive/v3.11.2.tar.gz | \ |
| 172 | + tar -xzf - --strip-components=1 && \ |
| 173 | + cmake \ |
| 174 | + -DCMAKE_BUILD_TYPE=Release \ |
| 175 | + -DBUILD_SHARED_LIBS=yes \ |
| 176 | + -DBUILD_TESTING=OFF \ |
| 177 | + -DJSON_BuildTests=OFF \ |
| 178 | + -S . -B cmake-out && \ |
| 179 | + cmake --build cmake-out --target install -- -j ${NCPU:-4} && \ |
| 180 | + ldconfig |
| 181 | +# ``` |
| 182 | + |
| 183 | +## [DONE packaging.md] |
| 184 | + |
| 185 | +# Some of the above libraries may have installed in /usr/local, so make sure |
| 186 | +# those library directories will be found. |
| 187 | +RUN ldconfig /usr/local/lib* |
0 commit comments