thumbor: Update to post v6.0
[dockerfile.git] / push.sh
1 #!/bin/bash
2 #
3 # Push all local repositories to a local registry
4 #
5 # Usage: ./push.sh docker-registry.example.com:5000
6
7 REGISTRY="${1}"
8
9 if [[ -z "${REGISTRY}" ]]
10 then
11         echo "usage: ${0} REGISTRY" >&2
12         exit 1
13 fi
14
15 DOCKER_IO=$(command -v docker.io)
16 DOCKER="${DOCKER:-${DOCKER_IO:-docker}}"
17
18 while read REPOSITORY TAG HASH OTHER
19 do
20         case "${REPOSITORY}" in
21         *none*|REPOSITORY)
22                 continue  # not named or header line
23                 ;;
24         "${REGISTRY}"/*)
25                 continue  # already registered
26                 ;;
27         esac
28         echo "${DOCKER}" tag -f "${HASH}" "${REGISTRY}/${REPOSITORY}:${TAG}" &&
29         "${DOCKER}" tag -f "${HASH}" "${REGISTRY}/${REPOSITORY}:${TAG}" &&
30         echo "${DOCKER}" push "${REGISTRY}/${REPOSITORY}"
31         "${DOCKER}" push "${REGISTRY}/${REPOSITORY}"
32 done < <("${DOCKER}" images)