Skip to content

Commit

Permalink
Make Kokoro job pull Dockerimage from Dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-kwong committed Dec 20, 2017
1 parent 8ac050f commit 6003a61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
19 changes: 11 additions & 8 deletions kokoro/linux/build_and_run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" != "" ]
Expand Down
6 changes: 3 additions & 3 deletions kokoro/linux/pull_request_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

WORKSPACE_BASE=`pwd`
MY_DIR="$(dirname "$0")"
TEST_SCRIPT=$MY_DIR/../tests.sh
TEST_SCRIPT=$MY_DIR/../../tests.sh
BUILD_DIR=/tmp/protobuf

set -e # exit immediately on error
Expand All @@ -16,7 +16,7 @@ set -x # display all commands
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
git clone /var/local/jenkins/protobuf
git clone /var/local/kokoro/protobuf
cd protobuf

# Set up the directory where our test output is going to go.
Expand Down Expand Up @@ -54,7 +54,7 @@ parallel --results $LOG_OUTPUT_DIR --joblog $OUTPUT_DIR/joblog $TEST_SCRIPT :::

cat $OUTPUT_DIR/joblog

# The directory that is copied from Docker back into the Jenkins workspace.
# The directory that is copied from Docker back into the Kokoro workspace.
COPY_FROM_DOCKER=/var/local/git/protobuf/testoutput
mkdir -p $COPY_FROM_DOCKER
TESTOUTPUT_XML_FILE=$COPY_FROM_DOCKER/testresults.xml
Expand Down

0 comments on commit 6003a61

Please sign in to comment.