xref: /aosp_15_r20/external/grpc-grpc/tools/dockerfile/test/bazel/Dockerfile (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1*cc02d7e2SAndroid Build Coastguard Worker# Copyright 2015 gRPC authors.
2*cc02d7e2SAndroid Build Coastguard Worker#
3*cc02d7e2SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*cc02d7e2SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*cc02d7e2SAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*cc02d7e2SAndroid Build Coastguard Worker#
7*cc02d7e2SAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
8*cc02d7e2SAndroid Build Coastguard Worker#
9*cc02d7e2SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*cc02d7e2SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*cc02d7e2SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*cc02d7e2SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*cc02d7e2SAndroid Build Coastguard Worker# limitations under the License.
14*cc02d7e2SAndroid Build Coastguard Worker
15*cc02d7e2SAndroid Build Coastguard Worker# Pinned version of the base image is used to avoid regressions caused
16*cc02d7e2SAndroid Build Coastguard Worker# by rebuilding of this docker image. To see available versions, you can run
17*cc02d7e2SAndroid Build Coastguard Worker# "gcloud container images list-tags gcr.io/oss-fuzz-base/base-builder"
18*cc02d7e2SAndroid Build Coastguard Worker# This base image is built on Mar 12, 2024
19*cc02d7e2SAndroid Build Coastguard WorkerFROM gcr.io/oss-fuzz-base/base-builder@sha256:c3581153788bc49f3634fec3cd36a5d6dfd26632c4afc157fb6faf8ce3af732e
20*cc02d7e2SAndroid Build Coastguard Worker
21*cc02d7e2SAndroid Build Coastguard Worker# -------------------------- WARNING --------------------------------------
22*cc02d7e2SAndroid Build Coastguard Worker# If you are making changes to this file, consider changing
23*cc02d7e2SAndroid Build Coastguard Worker# https://github.com/google/oss-fuzz/blob/master/projects/grpc/Dockerfile
24*cc02d7e2SAndroid Build Coastguard Worker# accordingly.
25*cc02d7e2SAndroid Build Coastguard Worker# -------------------------------------------------------------------------
26*cc02d7e2SAndroid Build Coastguard Worker
27*cc02d7e2SAndroid Build Coastguard Worker# Install basic packages
28*cc02d7e2SAndroid Build Coastguard WorkerRUN apt-get update && apt-get -y install \
29*cc02d7e2SAndroid Build Coastguard Worker  autoconf \
30*cc02d7e2SAndroid Build Coastguard Worker  build-essential \
31*cc02d7e2SAndroid Build Coastguard Worker  curl \
32*cc02d7e2SAndroid Build Coastguard Worker  libtool \
33*cc02d7e2SAndroid Build Coastguard Worker  make \
34*cc02d7e2SAndroid Build Coastguard Worker  vim \
35*cc02d7e2SAndroid Build Coastguard Worker  wget
36*cc02d7e2SAndroid Build Coastguard Worker
37*cc02d7e2SAndroid Build Coastguard Worker#========================
38*cc02d7e2SAndroid Build Coastguard Worker# Bazel installation
39*cc02d7e2SAndroid Build Coastguard Worker
40*cc02d7e2SAndroid Build Coastguard Worker# Must be in sync with tools/bazel
41*cc02d7e2SAndroid Build Coastguard WorkerENV BAZEL_VERSION 7.1.0
42*cc02d7e2SAndroid Build Coastguard Worker
43*cc02d7e2SAndroid Build Coastguard Worker# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
44*cc02d7e2SAndroid Build Coastguard WorkerENV DISABLE_BAZEL_WRAPPER 1
45*cc02d7e2SAndroid Build Coastguard Worker
46*cc02d7e2SAndroid Build Coastguard Worker# Download the correct bazel version and make sure it's on path.
47*cc02d7e2SAndroid Build Coastguard WorkerRUN BAZEL_ARCH_SUFFIX="$(uname -m | sed s/aarch64/arm64/)" \
48*cc02d7e2SAndroid Build Coastguard Worker  && curl -sSL --fail -o /usr/local/bin/bazel "https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-linux-$BAZEL_ARCH_SUFFIX" \
49*cc02d7e2SAndroid Build Coastguard Worker  && chmod a+x /usr/local/bin/bazel
50*cc02d7e2SAndroid Build Coastguard Worker
51*cc02d7e2SAndroid Build Coastguard Worker# Normally we would run "bazel --version" here to make sure bazel
52*cc02d7e2SAndroid Build Coastguard Worker# was correctly installed, but we can't do that because
53*cc02d7e2SAndroid Build Coastguard Worker# of # https://github.com/bazelbuild/bazel/issues/11379.
54*cc02d7e2SAndroid Build Coastguard Worker# We want to keep the arm64 version of the image buildable
55*cc02d7e2SAndroid Build Coastguard Worker# on x64 with use of qemu-user-static & binfmt emulation,
56*cc02d7e2SAndroid Build Coastguard Worker# but the self-extraction is broken for bazel currently.
57*cc02d7e2SAndroid Build Coastguard Worker# The binary will work correctly when run on real arm64
58*cc02d7e2SAndroid Build Coastguard Worker# hardware, when qemu-user-static isn't getting into the way.
59*cc02d7e2SAndroid Build Coastguard Worker
60*cc02d7e2SAndroid Build Coastguard Worker#=================
61*cc02d7e2SAndroid Build Coastguard Worker# Setup git to access working directory across docker boundary.
62*cc02d7e2SAndroid Build Coastguard Worker# This avoids the "fatal: detected dubious ownership in repository XYZ"
63*cc02d7e2SAndroid Build Coastguard Worker# git error.
64*cc02d7e2SAndroid Build Coastguard Worker
65*cc02d7e2SAndroid Build Coastguard WorkerRUN git config --global --add safe.directory '*'
66*cc02d7e2SAndroid Build Coastguard WorkerRUN git config --global protocol.file.allow always
67*cc02d7e2SAndroid Build Coastguard Worker
68*cc02d7e2SAndroid Build Coastguard Worker#=================
69*cc02d7e2SAndroid Build Coastguard Worker# Setup git to access working directory across docker boundary.
70*cc02d7e2SAndroid Build Coastguard Worker# This avoids the "fatal: detected dubious ownership in repository XYZ"
71*cc02d7e2SAndroid Build Coastguard Worker# git error. Using "--system" makes the setting work
72*cc02d7e2SAndroid Build Coastguard Worker# for all users or even current user is not properly defined
73*cc02d7e2SAndroid Build Coastguard Worker# (which can happen e.g. inside execution environment
74*cc02d7e2SAndroid Build Coastguard Worker# of a bazel action)
75*cc02d7e2SAndroid Build Coastguard Worker
76*cc02d7e2SAndroid Build Coastguard WorkerRUN git config --system --add safe.directory '*'
77*cc02d7e2SAndroid Build Coastguard WorkerRUN git config --system protocol.file.allow always
78*cc02d7e2SAndroid Build Coastguard Worker
79*cc02d7e2SAndroid Build Coastguard Worker
80*cc02d7e2SAndroid Build Coastguard WorkerRUN apt-get install -y gdb
81*cc02d7e2SAndroid Build Coastguard Worker
82*cc02d7e2SAndroid Build Coastguard WorkerRUN mkdir -p /var/local/jenkins
83*cc02d7e2SAndroid Build Coastguard Worker
84*cc02d7e2SAndroid Build Coastguard Worker# Define the default command.
85*cc02d7e2SAndroid Build Coastguard WorkerCMD ["bash"]
86