Browse Source

[Update] Prefetch images, big thanks to everyone in #2637!

andryyy 6 years ago
parent
commit
5b730bf89f
1 changed files with 15 additions and 0 deletions
  1. 15 0
      update.sh

+ 15 - 0
update.sh

@@ -9,6 +9,9 @@ fi
 # Exit on error and pipefail
 set -o pipefail
 
+# Setting high dc timeout
+export COMPOSE_HTTP_TIMEOUT=300
+
 # Add /opt/bin to PATH
 PATH=$PATH:/opt/bin
 
@@ -292,6 +295,18 @@ if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
   exit 0
 fi
 
+echo -e "\e[32mPrefetching images...\e[0m"
+while read image; do
+  RET_C=0
+  until docker pull ${image}; do
+    RET_C=$((RET_C + 1))
+    echo -e "\e[33m\nError pulling $image, retrying...\e[0m"
+    [ ${RET_C} -gt 3 ] && { echo -e "\e[31m\nToo many failed retries, exiting\e[0m"; exit 1; }
+    sleep 1
+  done
+done < <(git show origin/${BRANCH}:docker-compose.yml | grep "image:" | awk '{ gsub("image:","", $3); print $2 }')
+
+
 echo -e "Stopping mailcow... "
 sleep 2
 docker-compose down