1#!/bin/bash 2# Copyright 2021 The gRPC Authors 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# See tools/docker_runners/examples for more usage info. 17 18set -e 19 20# Environment variable used as inputs: 21# DOCKERFILE_DIR - Directory in which Dockerfile file is located. 22# DOCKER_EXTRA_ARGS - Extra arguments to pass to the "docker run" command. 23 24readonly grpc_rootdir="$(dirname "$(readlink -f "$0")")/../.." 25cd ${grpc_rootdir} 26 27if [ "${DOCKERFILE_DIR}" == "" ] 28then 29 echo "You need to specify the docker image to use by setting DOCKERFILE_DIR env variable." 30 echo "See docker image definitions under tools/dockerfile." 31 echo "" 32 echo "You likely want to set DOCKERFILE_DIR to one of these values:" 33 find tools/dockerfile/test -name Dockerfile | xargs -n1 dirname 34 exit 1 35fi 36 37DOCKER_NONROOT_ARGS=( 38 # run under current user's UID and GID 39 # Uncomment to run the docker container as current user's UID and GID. 40 # That way, the files written by the container won't be owned by root (=you won't end up with polluted workspace), 41 # but it can have some other disadvantages. E.g.: 42 # - you won't be able install stuff inside the container 43 # - the home directory inside the container will be broken (you won't be able to write in it). 44 # That may actually break some language runtimes completely (e.g. grpc python might not build) 45 # "--user=$(id -u):$(id -g)" 46) 47 48# the original DOCKER_EXTRA_ARGS + all the args defined in this script 49export DOCKER_EXTRA_ARGS="${DOCKER_NONROOT_ARGS[@]} ${DOCKER_EXTRA_ARGS}" 50 51exec tools/run_tests/dockerize/build_and_run_docker.sh "$@" 52