xref: /aosp_15_r20/external/grpc-grpc/tools/dockerfile/test/rbe_ubuntu2004/Dockerfile (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1# Copyright 2023 The gRPC Authors
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
15FROM ubuntu:20.04
16
17# Workaround the "tzdata hangs apt-get install during docker image build" issue for ubuntu20.04
18# by setting timezone to "Etc/UTC" in advance.
19RUN echo "Etc/UTC" > /etc/timezone
20
21RUN apt-get update && apt-get install -y build-essential curl git time wget zip && apt-get clean
22
23#====================
24# run_tests.py python dependencies
25
26# Basic python dependencies to be able to run tools/run_tests python scripts
27# These dependencies are not sufficient to build gRPC Python, gRPC Python
28# deps are defined elsewhere (e.g. python_deps.include)
29RUN apt-get update && apt-get install -y \
30  python3 \
31  python3-pip \
32  python3-setuptools \
33  python3-yaml \
34  && apt-get clean
35
36# use pinned version of pip to avoid sudden breakages
37RUN python3 -m pip install --upgrade pip==19.3.1
38
39# TODO(jtattermusch): currently six is needed for tools/run_tests scripts
40# but since our python2 usage is deprecated, we should get rid of it.
41RUN python3 -m pip install six==1.16.0
42
43# Google Cloud Platform API libraries
44# These are needed for uploading test results to BigQuery (e.g. by tools/run_tests scripts)
45RUN python3 -m pip install --upgrade google-auth==1.23.0 google-api-python-client==1.12.8 oauth2client==4.1.0
46
47
48
49# Some bazel tests expect "python" binary to exist
50RUN ln -s /usr/bin/python3 /usr/bin/python
51
52# Install Google's LLVM build for Ubuntu 20.04
53# Heavily inspired by https://github.com/GoogleCloudPlatform/container-definitions/tree/master/ubuntu1804_rbe
54# See go/llvm-docker
55# Note that we are using the google's pre-built tools for multiple reasons:
56# * this is what the "official" rbe-ubuntu18-04 image is using: See https://github.com/GoogleCloudPlatform/layer-definitions/tree/master/layers/ubuntu1804/clang
57# * for sanitizers to work, we need MSAN and TSAN enabled versions of libc++
58# Check https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/latest.txt
59# for the value of LLVM_LATEST.
60ARG LLVM_LATEST="f2b94bd7eaa83d853dc7568fac87b1f8bf4ddec6"
61RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/clang_r${LLVM_LATEST}.tar.gz -O /tmp/clang.tar.gz \
62  && tar -xzf /tmp/clang.tar.gz -C /usr/local && rm /tmp/clang.tar.gz
63RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx_r${LLVM_LATEST}.tar.gz -O /tmp/libcxx.tar.gz \
64  && tar -xzf /tmp/libcxx.tar.gz -C /usr/local && rm /tmp/libcxx.tar.gz
65RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx-msan_r${LLVM_LATEST}.tar.gz -O /tmp/libcxx-msan.tar.gz \
66  && mkdir -p /usr/local/libcxx-msan && tar -xzf /tmp/libcxx-msan.tar.gz -C /usr/local/libcxx-msan && rm /tmp/libcxx-msan.tar.gz
67RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx-tsan_r${LLVM_LATEST}.tar.gz -O /tmp/libcxx-tsan.tar.gz \
68  && mkdir -p /usr/local/libcxx-tsan && tar -xzf /tmp/libcxx-tsan.tar.gz -C /usr/local/libcxx-tsan && rm /tmp/libcxx-tsan.tar.gz
69RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/lld_r${LLVM_LATEST}.tar.gz -O /tmp/lld.tar.gz \
70  && tar -xzf /tmp/lld.tar.gz -C /usr/local && rm /tmp/lld.tar.gz
71
72ENV ASAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
73ENV CC=/usr/local/bin/clang
74ENV GCOV=/dev/null
75ENV LD_LIBRARY_PATH=/usr/local/lib/x86_64-unknown-linux-gnu
76ENV MSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
77ENV TSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
78ENV UBSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
79
80# TODO(jtattermusch): Remove python2 once some tests stop failing without it.
81RUN apt-get update && apt-get install -y python2 && apt-get clean
82
83# Define the default command.
84CMD ["bash"]
85