aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests/dockerize/build_and_run_docker.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/run_tests/dockerize/build_and_run_docker.sh')
-rwxr-xr-xtools/run_tests/dockerize/build_and_run_docker.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/run_tests/dockerize/build_and_run_docker.sh b/tools/run_tests/dockerize/build_and_run_docker.sh
index 323c2f78af..b8f0a55025 100755
--- a/tools/run_tests/dockerize/build_and_run_docker.sh
+++ b/tools/run_tests/dockerize/build_and_run_docker.sh
@@ -18,7 +18,7 @@
set -ex
-cd $(dirname $0)/../../..
+cd "$(dirname "$0")/../../.."
git_root=$(pwd)
cd -
@@ -31,36 +31,38 @@ cd -
# $@ - Extra args to pass to docker run
# Use image name based on Dockerfile location checksum
-DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
+DOCKER_IMAGE_NAME=$(basename "$DOCKERFILE_DIR")_$(sha1sum "$DOCKERFILE_DIR/Dockerfile" | cut -f1 -d\ )
# Pull the base image to force an update
if [ "$DOCKER_BASE_IMAGE" != "" ]
then
- time docker pull $DOCKER_BASE_IMAGE
+ time docker pull "$DOCKER_BASE_IMAGE"
fi
if [ "$DOCKERHUB_ORGANIZATION" != "" ]
then
DOCKER_IMAGE_NAME=$DOCKERHUB_ORGANIZATION/$DOCKER_IMAGE_NAME
- time docker pull $DOCKER_IMAGE_NAME
+ time docker pull "$DOCKER_IMAGE_NAME"
else
# Make sure docker image has been built. Should be instantaneous if so.
- docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
+ docker build -t "$DOCKER_IMAGE_NAME" "$DOCKERFILE_DIR"
fi
# Choose random name for docker container
CONTAINER_NAME="build_and_run_docker_$(uuidgen)"
# Run command inside docker
+# TODO: use a proper array instead of $EXTRA_DOCKER_ARGS
+# shellcheck disable=SC2086
docker run \
"$@" \
-e EXTERNAL_GIT_ROOT="/var/local/jenkins/grpc" \
-e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \
-v "$git_root:/var/local/jenkins/grpc:ro" \
-w /var/local/git/grpc \
- --name=$CONTAINER_NAME \
+ --name="$CONTAINER_NAME" \
$EXTRA_DOCKER_ARGS \
- $DOCKER_IMAGE_NAME \
+ "$DOCKER_IMAGE_NAME" \
/bin/bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || FAILED="true"
# Copy output artifacts
@@ -70,7 +72,7 @@ then
fi
# remove the container, possibly killing it first
-docker rm -f $CONTAINER_NAME || true
+docker rm -f "$CONTAINER_NAME" || true
if [ "$FAILED" != "" ]
then