diff --git a/sbin/tag_and_push_docker_image.sh b/sbin/tag_and_push_docker_image.sh new file mode 100755 index 0000000000000000000000000000000000000000..ad94ae4b2ca6418e0d89347d4b37b47ef1a16a5a --- /dev/null +++ b/sbin/tag_and_push_docker_image.sh @@ -0,0 +1,40 @@ +#! /usr/bin/env bash -e + +# Tag and push which image version? +DOCKER_TAG=latest + +# Change to git tag or git hash if no tag +VERSION=$(date +"%Y-%M-%d") + +SKA_REPO="nexus.engageska-portugal.pt/ska-docker" +LOFAR_REPO="git.astron.nl:5000/lofar2.0/tango" + +# Compile a list of the SKA images +SKA_IMAGES=$(for i in $(docker images | egrep ${DOCKER_TAG} | egrep ${SKA_REPO} | cut -d' ' -f1); do printf "%s " ${i}; done) + +# Compile a list of LOFAR2.0 images +LOFAR_IMAGES=$(for i in $(docker images | egrep ${DOCKER_TAG} | egrep -v "${SKA_REPO}|${LOFAR_REPO}" | cut -d' ' -f1); do printf "%s " ${i}; done) + +function tag_and_push() +{ + ( + docker tag ${1} ${2} + docker push ${2} + ) & +} + +# Rename the SKA images for the LOFAR2.0 repo +# and push them to the LOFAR2.0 repo +for IMAGE in ${SKA_IMAGES}; do + PUSH_IMAGE=${IMAGE//${SKA_REPO}/${LOFAR_REPO}}:${VERSION} + tag_and_push ${IMAGE} ${PUSH_IMAGE} +done + +# Rename the LOFAR2.0 images for the LOFAR2.0 repo +# and push them to the LOFAR2.0 repo +for IMAGE in ${LOFAR_IMAGES}; do + PUSH_IMAGES=${LOFAR_REPO}/${IMAGE}:${VERSIN} + tag_and_push ${IMAGE} ${PUSH_IMAGE} +done + +wait