|
13 | 13 | # See the License for the specific language governing permissions and
|
14 | 14 | # limitations under the License.
|
15 | 15 |
|
16 |
| -# Runs C# build in a docker container, but using the local workspace. |
17 |
| -# Example usage: |
18 |
| -# src/csharp/run_in_docker.sh tools/run_tests/run_tests.py -l csharp |
| 16 | +# See tools/docker_runners/examples for more usage info. |
19 | 17 |
|
20 | 18 | set -e
|
21 | 19 |
|
|
36 | 34 | exit 1
|
37 | 35 | fi
|
38 | 36 |
|
39 |
| -# Use image name based on Dockerfile location checksum |
40 |
| -# For simplicity, currently only testing docker images that have already been pushed |
41 |
| -# to dockerhub are supported (see tools/dockerfile/push_testing_images.sh) |
42 |
| -# TODO(jtattermusch): add support for building dockerimages locally. |
43 |
| -DOCKER_IMAGE=grpctesting/$(basename "$DOCKERFILE_DIR"):$(sha1sum "$DOCKERFILE_DIR/Dockerfile" | cut -f1 -d\ ) |
44 |
| - |
45 |
| -# TODO: support building dockerimage locally / pulling it from dockerhub |
46 |
| - |
47 |
| -# If TTY is available, the running container can be conveniently terminated with Ctrl+C. |
48 |
| -if [[ -t 0 ]]; then |
49 |
| - DOCKER_TTY_ARGS=("-it") |
50 |
| -else |
51 |
| - # The input device on kokoro is not a TTY, so -it does not work. |
52 |
| - DOCKER_TTY_ARGS=() |
53 |
| -fi |
54 |
| - |
55 |
| -# args required to be able to run gdb/strace under the docker container |
56 |
| -DOCKER_PRIVILEGED_ARGS=( |
57 |
| - "--privileged" |
58 |
| - "--cap-add=SYS_PTRACE" |
59 |
| - "--security-opt=seccomp=unconfined" |
60 |
| -) |
61 |
| - |
62 |
| -DOCKER_NETWORK_ARGS=( |
63 |
| - # enable IPv6 |
64 |
| - "--sysctl=net.ipv6.conf.all.disable_ipv6=0" |
65 |
| - # use host network, required for the port server to work correctly |
66 |
| - "--network=host" |
| 37 | +DOCKER_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)" |
67 | 46 | )
|
68 | 47 |
|
69 |
| -DOCKER_CLEANUP_ARGS=( |
70 |
| - # delete the container when the containers exits |
71 |
| - # (otherwise the container will not release the disk space it used) |
72 |
| - "--rm=true" |
73 |
| -) |
74 |
| - |
75 |
| -DOCKER_PROPAGATE_ENV_ARGS=( |
76 |
| - "--env-file=tools/run_tests/dockerize/docker_propagate_env.list" \ |
77 |
| -) |
78 |
| - |
79 |
| -# Uncomment to run the docker container as current user's UID and GID. |
80 |
| -# That way, the files written by the container won't be owned by root (=you won't end up with polluted workspace), |
81 |
| -# but it can have some other disadvantages. E.g.: |
82 |
| -# - you won't be able install stuff inside the container |
83 |
| -# - the home directory inside the container will be broken (you won't be able to write in it). |
84 |
| -# That may actually break some language runtimes completely (e.g. grpc python might not build) |
85 |
| -# DOCKER_NONROOT_ARGS=( |
86 |
| -# # run under current user's UID and GID |
87 |
| -# "--user=$(id -u):$(id -g)" |
88 |
| -# ) |
89 |
| - |
90 |
| -# Enable command echo just before running the final docker command to make the docker args visible. |
91 |
| -set -ex |
| 48 | +# the original DOCKER_EXTRA_ARGS + all the args defined in this script |
| 49 | +export DOCKER_EXTRA_ARGS="${DOCKER_NONROOT_ARGS[@]} ${DOCKER_EXTRA_ARGS}" |
| 50 | +# download the docker images from dockerhub instead of building them locally |
| 51 | +export DOCKERHUB_ORGANIZATION=grpctesting |
92 | 52 |
|
93 |
| -# Run command inside C# docker container. |
94 |
| -# - the local clone of grpc repository will be mounted as /workspace. |
95 |
| -exec docker run "${DOCKER_TTY_ARGS[@]}" "${DOCKER_PRIVILEGED_ARGS[@]}" "${DOCKER_NETWORK_ARGS[@]}" "${DOCKER_CLEANUP_ARGS[@]}" "${DOCKER_PROPAGATE_ENV_ARGS[@]}" ${DOCKER_EXTRA_ARGS} -v "${grpc_rootdir}":/workspace -w /workspace "${DOCKER_IMAGE}" bash -c "$*" |
| 53 | +exec tools/run_tests/dockerize/build_and_run_docker.sh "$@" |
0 commit comments