|
5 | 5 | set -euo pipefail |
6 | 6 | trap "echo 'error: Script failed: see failed command above'" ERR |
7 | 7 |
|
| 8 | +# vars |
| 9 | +# DOCKER_FQDN='docker.thehypepipe.co.uk' |
| 10 | +DOCKER_SERVER="https://$DOCKER_FQDN" |
| 11 | + |
8 | 12 | # Check if images already exist |
9 | | -message="Pushing docker images" |
10 | | -echo -e "\nSTARTED: $message..." |
| 13 | +main_message="Pushing docker image tasks" |
| 14 | +echo -e "\nSTARTED: $main_message..." |
11 | 15 |
|
12 | 16 | # List repositories |
13 | | -repos=$(curl -s "$DOCKER_FQDN/v2/_catalog" | jq ".repositories") |
| 17 | +repos=$(curl -s "$DOCKER_SERVER/v2/_catalog" | jq ".repositories") |
14 | 18 |
|
15 | 19 | if [[ "$repos" == "[]" ]]; then |
| 20 | + message="Pulling base images..." |
| 21 | + echo -e "\nSTARTED: $message..." |
16 | 22 | docker pull busybox |
17 | 23 | docker pull nginxdemos/hello |
| 24 | + echo -e "\nFINISHED: $message." |
18 | 25 |
|
19 | | - docker image tag busybox "$DOCKER_FQDN/busybox" |
20 | | - docker image tag nginxdemos/hello "$DOCKER_FQDN/hello" |
21 | | - |
22 | | - docker image ls "$DOCKER_FQDN/busybox" |
23 | | - docker image ls "$DOCKER_FQDN/hello" |
| 26 | + message="Tagging images..." |
| 27 | + docker image tag busybox "$DOCKER_SERVER/busybox" |
| 28 | + docker image tag nginxdemos/hello "$DOCKER_SERVER/hello" |
| 29 | + echo -e "\nFINISHED: $message." |
24 | 30 |
|
25 | | - docker push "$DOCKER_FQDN/busybox" |
26 | | - docker push "$DOCKER_FQDN/hello" |
| 31 | + message="Listing images..." |
| 32 | + docker image ls "$DOCKER_SERVER/busybox" |
| 33 | + docker image ls "$DOCKER_SERVER/hello" |
| 34 | + echo -e "\nFINISHED: $message." |
27 | 35 |
|
| 36 | + message="Pushing images..." |
| 37 | + docker push "$DOCKER_SERVER/busybox" |
| 38 | + docker push "$DOCKER_SERVER/hello" |
28 | 39 | echo -e "\nFINISHED: $message." |
| 40 | + |
| 41 | + echo -e "\nFINISHED: $main_message." |
29 | 42 | else |
30 | | - echo -e "\nSKIPPING: $message...they already exist in repo." |
| 43 | + echo -e "\nSKIPPING: $main_message...they already exist in repo." |
31 | 44 |
|
32 | 45 | # List tags |
33 | | - curl -s "$DOCKER_FQDN/v2/busybox/tags/list" |
34 | | - curl -s "$DOCKER_FQDN/v2/hello/tags/list" |
| 46 | + curl -s "$DOCKER_SERVER/v2/busybox/tags/list" |
| 47 | + curl -s "$DOCKER_SERVER/v2/hello/tags/list" |
35 | 48 | fi |
0 commit comments