|
| 1 | +# Copyright 2018 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=18.04 |
| 16 | +FROM ubuntu:${DISTRO_VERSION} |
| 17 | +MAINTAINER "Carlos O'Ryan <coryan@google.com>" |
| 18 | + |
| 19 | +RUN apt update && \ |
| 20 | + apt install -y \ |
| 21 | + abi-compliance-checker \ |
| 22 | + abi-dumper \ |
| 23 | + automake \ |
| 24 | + build-essential \ |
| 25 | + ccache \ |
| 26 | + clang \ |
| 27 | + clang-format \ |
| 28 | + cmake \ |
| 29 | + curl \ |
| 30 | + doxygen \ |
| 31 | + gawk \ |
| 32 | + git \ |
| 33 | + gcc \ |
| 34 | + g++ \ |
| 35 | + cmake \ |
| 36 | + libcurl4-openssl-dev \ |
| 37 | + libssl-dev \ |
| 38 | + libtool \ |
| 39 | + lsb-release \ |
| 40 | + make \ |
| 41 | + pkg-config \ |
| 42 | + python-pip \ |
| 43 | + tar \ |
| 44 | + wget \ |
| 45 | + zlib1g-dev |
| 46 | + |
| 47 | +# By default, Ubuntu 18.04 does not install the alternatives for clang-format |
| 48 | +# and clang-tidy, so we need to manually install those. |
| 49 | +RUN if grep -q 18.04 /etc/lsb-release; then \ |
| 50 | + apt update && apt install -y clang-tidy clang-format clang-tools; \ |
| 51 | + update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-6.0 100; \ |
| 52 | + update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-6.0 100; \ |
| 53 | + update-alternatives --install /usr/bin/scan-build scan-build /usr/bin/scan-build-6.0 100; \ |
| 54 | + fi |
| 55 | + |
| 56 | +# Install the the buildifier tool, which does not compile with the default |
| 57 | +# golang compiler for Ubuntu 16.04 and Ubuntu 18.04. |
| 58 | +RUN wget -q -O /usr/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/0.17.2/buildifier |
| 59 | +RUN chmod 755 /usr/bin/buildifier |
| 60 | + |
| 61 | +# Install cmake_format to automatically format the CMake list files. |
| 62 | +# https://github.com/cheshirekow/cmake_format |
| 63 | +# Pin this to an specific version because the formatting changes when the |
| 64 | +# "latest" version is updated, and we do not want the builds to break just |
| 65 | +# because some third party changed something. |
| 66 | +RUN pip install --upgrade pip |
| 67 | +RUN pip install numpy cmake_format==0.4.0 |
| 68 | + |
| 69 | +# Install Python packages used in the integration tests. |
| 70 | +RUN pip install flask httpbin gevent gunicorn crc32c |
| 71 | + |
| 72 | +# Install the Cloud Bigtable emulator and the Cloud Bigtable command-line |
| 73 | +# client. They are used in the integration tests. |
| 74 | +WORKDIR /var/tmp/install/cbt-components |
| 75 | +RUN wget -q https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-201.0.0-linux-x86_64.tar.gz |
| 76 | +RUN tar x -C /usr/local -f google-cloud-sdk-201.0.0-linux-x86_64.tar.gz |
| 77 | +RUN /usr/local/google-cloud-sdk/bin/gcloud --quiet components install cbt bigtable |
| 78 | +RUN /usr/local/google-cloud-sdk/bin/gcloud --quiet components update || \ |
| 79 | + echo "Ignoring update failure for Google Cloud SDK" |
| 80 | + |
| 81 | +# Parallelize the builds if possible. The default is chosen to work well on |
| 82 | +# Travis, but developers may want to override this value when building on their |
| 83 | +# workstations. |
| 84 | +ARG NCPU=2 |
| 85 | + |
| 86 | +# Install Crc32c library. |
| 87 | +WORKDIR /var/tmp/build |
| 88 | +RUN wget -q https://github.com/google/crc32c/archive/1.0.6.tar.gz |
| 89 | +RUN tar -xf 1.0.6.tar.gz |
| 90 | +WORKDIR /var/tmp/build/crc32c-1.0.6 |
| 91 | +RUN cmake \ |
| 92 | + -DCMAKE_BUILD_TYPE=Release \ |
| 93 | + -DBUILD_SHARED_LIBS=yes \ |
| 94 | + -DCRC32C_BUILD_TESTS=OFF \ |
| 95 | + -DCRC32C_BUILD_BENCHMARKS=OFF \ |
| 96 | + -DCRC32C_USE_GLOG=OFF \ |
| 97 | + -H. -B.build/crc32c |
| 98 | +RUN cmake --build .build/crc32c --target install -- -j ${NCPU} |
| 99 | +RUN ldconfig |
| 100 | + |
| 101 | +# Install protobuf using CMake. Some distributions include protobuf, but gRPC |
| 102 | +# requires 3.4.x or newer, and many of those distribution use older versions. |
| 103 | +# We need to install both the debug and Release version because: |
| 104 | +# - When using pkg-config, only the release version works, the pkg-config |
| 105 | +# file is hard-coded to search for `libprotobuf.so` (or `.a`) |
| 106 | +# - When using CMake, only the version compiled with the same CMAKE_BUILD_TYPE |
| 107 | +# as the dependent (gRPC or google-cloud-cpp) works. |
| 108 | +WORKDIR /var/tmp/build |
| 109 | +RUN wget -q https://github.com/google/protobuf/archive/v3.6.1.tar.gz |
| 110 | +RUN tar -xf v3.6.1.tar.gz |
| 111 | +WORKDIR /var/tmp/build/protobuf-3.6.1/cmake |
| 112 | +RUN for build_type in "Debug" "Release"; do \ |
| 113 | + cmake \ |
| 114 | + -DCMAKE_BUILD_TYPE="${build_type}" \ |
| 115 | + -DBUILD_SHARED_LIBS=yes \ |
| 116 | + -Dprotobuf_BUILD_TESTS=OFF \ |
| 117 | + -H. -B.build-${build_type}; \ |
| 118 | + cmake --build .build-${build_type} --target install -- -j ${NCPU}; \ |
| 119 | + done |
| 120 | +RUN ldconfig |
| 121 | + |
| 122 | +# Many distributions include c-ares, but they do not include the CMake support |
| 123 | +# files for the library, so manually install it. c-ares requires two install |
| 124 | +# steps because (1) the CMake-based build does not install pkg-config files, |
| 125 | +# and (2) the Makefile-based build does not install CMake config files. |
| 126 | +WORKDIR /var/tmp/build |
| 127 | +RUN apt-get remove -y libc-ares-dev libc-ares2 |
| 128 | +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_14_0.tar.gz |
| 129 | +RUN tar -xf cares-1_14_0.tar.gz |
| 130 | +WORKDIR /var/tmp/build/c-ares-cares-1_14_0 |
| 131 | +RUN cmake \ |
| 132 | + -DCMAKE_BUILD_TYPE="Release" \ |
| 133 | + -DBUILD_SHARED_LIBS=yes \ |
| 134 | + -H. -B.build |
| 135 | +RUN cmake --build .build --target install -- -j ${NCPU} |
| 136 | +RUN ./buildconf |
| 137 | +RUN ./configure |
| 138 | +RUN install -m 644 -D -t /usr/local/lib/pkgconfig libcares.pc |
| 139 | +RUN ldconfig |
| 140 | + |
| 141 | +# Install gRPC. Note that we use the system's zlib and ssl libraries. |
| 142 | +# For similar reasons to c-ares (see above), we need two install steps. |
| 143 | +WORKDIR /var/tmp/build |
| 144 | +RUN wget -q https://github.com/grpc/grpc/archive/v1.16.1.tar.gz |
| 145 | +RUN tar -xf v1.16.1.tar.gz |
| 146 | +RUN ls -l |
| 147 | +WORKDIR /var/tmp/build/grpc-1.16.1 |
| 148 | +RUN ls -l |
| 149 | +RUN cmake \ |
| 150 | + -DCMAKE_BUILD_TYPE="Release" \ |
| 151 | + -DBUILD_SHARED_LIBS=yes \ |
| 152 | + -DgRPC_BUILD_TESTS=OFF \ |
| 153 | + -DgRPC_ZLIB_PROVIDER=package \ |
| 154 | + -DgRPC_SSL_PROVIDER=package \ |
| 155 | + -DgRPC_CARES_PROVIDER=package \ |
| 156 | + -DgRPC_PROTOBUF_PROVIDER=package \ |
| 157 | + -H. -B.build/grpc |
| 158 | +RUN cmake --build .build/grpc --target install -- -j ${NCPU} |
| 159 | +RUN make install-pkg-config_c install-pkg-config_cxx install-certs |
| 160 | +RUN ldconfig |
| 161 | + |
| 162 | +# Install googletest. |
| 163 | +WORKDIR /var/tmp/build |
| 164 | +RUN wget -q https://github.com/google/googletest/archive/release-1.8.1.tar.gz |
| 165 | +RUN tar -xf release-1.8.1.tar.gz |
| 166 | +WORKDIR /var/tmp/build/googletest-release-1.8.1 |
| 167 | +RUN cmake \ |
| 168 | + -DCMAKE_BUILD_TYPE="Release" \ |
| 169 | + -DBUILD_SHARED_LIBS=yes \ |
| 170 | + -H. -B.build/googletest |
| 171 | +RUN cmake --build .build/googletest --target install -- -j ${NCPU} |
| 172 | +RUN ldconfig |
| 173 | + |
| 174 | +RUN find /usr/local -type d | xargs chmod 777 |
0 commit comments