1#!/bin/bash 2 3set -ex 4 5cd $(dirname $0)/../../.. 6git_root=$(pwd) 7cd kokoro/linux/dockerfile 8 9DOCKERHUB_ORGANIZATION=protobuftesting 10 11for DOCKERFILE_DIR in test/* 12do 13 # Generate image name based on Dockerfile checksum. That works well as long 14 # as can count on dockerfiles being written in a way that changing the logical 15 # contents of the docker image always changes the SHA (e.g. using "ADD file" 16 # cmd in the dockerfile in not ok as contents of the added file will not be 17 # reflected in the SHA). 18 DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) 19 20 echo $DOCKER_IMAGE_NAME 21 # skip the image if it already exists in the repo 22 curl --silent -f -lSL https://registry.hub.docker.com/v2/repositories/${DOCKERHUB_ORGANIZATION}/${DOCKER_IMAGE_NAME}/tags/latest > /dev/null \ 23 && continue 24 25 docker build -t ${DOCKERHUB_ORGANIZATION}/${DOCKER_IMAGE_NAME} ${DOCKERFILE_DIR} 26 27 # "docker login" needs to be run in advance 28 docker push ${DOCKERHUB_ORGANIZATION}/${DOCKER_IMAGE_NAME} 29done 30