push_testing_images.sh 1.0 KB

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