github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/hack/make/.ensure-frozen-images (about) 1 #!/bin/bash 2 set -e 3 4 # image lists for different archs that should match what's in the Dockerfile (minus the explicit images IDs) 5 case "$DOCKER_ENGINE_OSARCH" in 6 linux/arm) 7 images=( 8 hypriot/armhf-busybox@ea0800bb83571c585c5652b53668e76b29c7c0eef719892f9d0a48607984f9e1 9 hypriot/armhf-hello-world@508c59a4f8b23c77bbcf43296c3f580873dc7eecb1f0d680cea3067e221fd4c2 10 hypriot/armhf-unshare@3f1db65f8bbabc743fd739cf7145a56c35b2a0979ae3174e9d79b7fa4b00fca1 11 ) 12 ;; 13 linux/ppc64le) 14 images=( 15 ppc64le/busybox:latest 16 ppc64le/hello-world:frozen 17 ppc64le/unshare:latest 18 ) 19 ;; 20 linux/s390x) 21 images=( 22 s390x/busybox:latest 23 s390x/hello-world:frozen 24 s390x/unshare:latest 25 ) 26 ;; 27 *) 28 images=( 29 busybox:latest 30 hello-world:latest 31 jess/unshare:latest 32 ) 33 ;; 34 esac 35 36 if ! docker inspect "${images[@]}" &> /dev/null; then 37 hardCodedDir='/docker-frozen-images' 38 if [ -d "$hardCodedDir" ]; then 39 # Do not use a subshell for the following command. Windows CI 40 # runs bash 3.x so will not trap an error in a subshell. 41 # http://stackoverflow.com/questions/22630363/how-does-set-e-work-with-subshells 42 set -x; tar -cC "$hardCodedDir" . | docker load; set +x 43 else 44 dir="$DEST/frozen-images" 45 # extract the exact "RUN download-frozen-image-v2.sh" line from the Dockerfile itself for consistency 46 # NOTE: this will fail if either "curl" or "jq" is not installed or if the Dockerfile is not available/readable 47 awk ' 48 $1 == "RUN" && $2 == "./contrib/download-frozen-image-v2.sh" { 49 for (i = 2; i < NF; i++) 50 printf ( $i == "'"$hardCodedDir"'" ? "'"$dir"'" : $i ) " "; 51 print $NF; 52 if (/\\$/) { 53 inCont = 1; 54 next; 55 } 56 } 57 inCont { 58 print; 59 if (!/\\$/) { 60 inCont = 0; 61 } 62 } 63 ' ${DOCKER_FILE:="Dockerfile"} | sh -x 64 # Do not use a subshell for the following command. Windows CI 65 # runs bash 3.x so will not trap an error in a subshell. 66 # http://stackoverflow.com/questions/22630363/how-does-set-e-work-with-subshells 67 set -x; tar -cC "$dir" . | docker load; set +x 68 fi 69 fi 70 71 # tag images to ensure that all integrations work with the defined image names 72 # then remove original tags as these make problems with later tests (e.g., TestInspectApiImageResponse) 73 case "$DOCKER_ENGINE_OSARCH" in 74 linux/arm) 75 docker tag hypriot/armhf-busybox:latest busybox:latest 76 docker tag hypriot/armhf-hello-world:latest hello-world:frozen 77 docker tag hypriot/armhf-unshare:latest jess/unshare:latest 78 docker rmi hypriot/armhf-busybox:latest 79 docker rmi hypriot/armhf-hello-world:latest 80 docker rmi hypriot/armhf-unshare:latest 81 ;; 82 linux/ppc64le) 83 docker tag ppc64le/busybox:latest busybox:latest 84 docker tag ppc64le/hello-world:frozen hello-world:frozen 85 docker tag ppc64le/unshare:latest jess/unshare:latest 86 docker rmi ppc64le/busybox:latest 87 docker rmi ppc64le/hello-world:frozen 88 docker rmi ppc64le/unshare:latest 89 ;; 90 linux/s390x) 91 docker tag s390x/busybox:latest busybox:latest 92 docker tag s390x/hello-world:frozen hello-world:frozen 93 docker tag s390x/unshare:latest jess/unshare:latest 94 docker rmi s390x/busybox:latest 95 docker rmi s390x/hello-world:frozen 96 docker rmi s390x/unshare:latest 97 ;; 98 *) 99 docker tag hello-world:latest hello-world:frozen 100 ;; 101 esac