Skip to content

Commit

Permalink
add concurrent_bazel.sh runner
Browse files Browse the repository at this point in the history
  • Loading branch information
jtattermusch committed Oct 2, 2023
1 parent fea22f5 commit 4704555
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tools/docker_runners/examples/concurrent_bazel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# Copyright 2021 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This wrapper allows running concurrent instances of bazel build/test by running
# bazel under a docker container.
# This is especially useful for running bazel RBE builds, since inside
# the container, bazel won't have access to local build cache.

# Usage:
# tools/docker_runners/examples/concurrent_bazel.sh ANY_NORMAL_BAZEL_FLAGS_HERE

set -ex

# change to grpc repo root
cd "$(dirname "$0")/../../.."

# use the default docker image used for bazel builds
export DOCKERFILE_DIR=tools/dockerfile/test/bazel

# Bazel RBE uses application default credentials from localhost to authenticate with RBE servers. Use a trick to make the credentails accessible from inside the docker container."
APPLICATION_DEFAULT_CREDENTIALS_DIR="$HOME/.config/gcloud"
export DOCKER_EXTRA_ARGS="-v=${APPLICATION_DEFAULT_CREDENTIALS_DIR}:/application_default_credentials:ro -e=GOOGLE_APPLICATION_CREDENTIALS=/application_default_credentials/application_default_credentials.json"

# Run bazel inside a docker container (local git workspace will be mounted to the container)
tools/docker_runners/run_in_docker.sh bazel "$@"

0 comments on commit 4704555

Please sign in to comment.