diff options
author | Matt Kwong <mattkwong@google.com> | 2017-12-19 17:09:54 -0800 |
---|---|---|
committer | Matt Kwong <mattkwong@google.com> | 2017-12-20 14:56:13 -0800 |
commit | 6003a61255fe508924878ef0ce8207996e7b5d3c (patch) | |
tree | aa024c251ff956b970f6e60b7409758b1a50782c /kokoro/linux/build_and_run_docker.sh | |
parent | 8ac050fadd7d08eae525a5a227a1e87ea15d57fc (diff) |
Make Kokoro job pull Dockerimage from Dockerhub
Diffstat (limited to 'kokoro/linux/build_and_run_docker.sh')
-rwxr-xr-x | kokoro/linux/build_and_run_docker.sh | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/kokoro/linux/build_and_run_docker.sh b/kokoro/linux/build_and_run_docker.sh index 50e1e8c6..4eaa0282 100755 --- a/kokoro/linux/build_and_run_docker.sh +++ b/kokoro/linux/build_and_run_docker.sh @@ -11,15 +11,16 @@ set -ex -cd $(dirname $0)/.. +cd $(dirname $0)/../.. git_root=$(pwd) cd - -# Use image name based on Dockerfile location checksum -DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) +# Use image name based on Dockerfile sha1 +DOCKERHUB_ORGANIZATION=grpctesting/protobuf +DOCKER_IMAGE_NAME=${DOCKERHUB_ORGANIZATION}_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) -# Make sure docker image has been built. Should be instantaneous if so. -docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR +# Pull dockerimage from Dockerhub +docker pull $DOCKER_IMAGE_NAME # Ensure existence of ccache directory CCACHE_DIR=/tmp/protobuf-ccache @@ -28,19 +29,21 @@ mkdir -p $CCACHE_DIR # Choose random name for docker container CONTAINER_NAME="build_and_run_docker_$(uuidgen)" +echo $git_root + # Run command inside docker docker run \ "$@" \ -e CCACHE_DIR=$CCACHE_DIR \ - -e EXTERNAL_GIT_ROOT="/var/local/jenkins/protobuf" \ + -e EXTERNAL_GIT_ROOT="/var/local/kokoro/protobuf" \ -e TEST_SET="$TEST_SET" \ -e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \ - -v "$git_root:/var/local/jenkins/protobuf:ro" \ + -v "$git_root:/var/local/kokoro/protobuf:ro" \ -v $CCACHE_DIR:$CCACHE_DIR \ -w /var/local/git/protobuf \ --name=$CONTAINER_NAME \ $DOCKER_IMAGE_NAME \ - bash -l "/var/local/jenkins/protobuf/$DOCKER_RUN_SCRIPT" || FAILED="true" + bash -l "/var/local/kokoro/protobuf/$DOCKER_RUN_SCRIPT" || FAILED="true" # Copy output artifacts if [ "$OUTPUT_DIR" != "" ] |