Only check for updates once every vm-boot. Speeds up provisioning. fixes #22
authorJan Vales <jan@jvales.net>
Mon, 12 Nov 2018 21:22:11 +0000 (22:22 +0100)
committerJan Vales <jan@jvales.net>
Mon, 12 Nov 2018 21:22:11 +0000 (22:22 +0100)
provision.sh

index 90c70999077d7fc0619484d8490a8a9110134011..eeb2084993258fa520de8dffb7bc2c0a5c984b28 100755 (executable)
@@ -5,14 +5,21 @@ cd /vagrant
 ###############################
 # Get Docker + Docker-Compose #
 ###############################
-apt-get update
-apt-get install -y -q apt-transport-https vim
+# Check for updates only once per boot.
+dpkg-query -W docker-ce docker-compose &>/dev/null || rm -f /tmp/apt_run_this_boot
 
-wget -q "https://download.docker.com/linux/debian/gpg" -O - | apt-key add
-echo "deb https://download.docker.com/linux/debian stretch stable" > /etc/apt/sources.list.d/docker_com.list
+if [ ! -f /tmp/apt_run_this_boot ]; then
+    apt-get update
+    apt-get install -y -q apt-transport-https vim
 
-apt-get update
-apt-get install -y -q docker-ce docker-compose
+    wget -q "https://download.docker.com/linux/debian/gpg" -O - | apt-key add
+    echo "deb https://download.docker.com/linux/debian stretch stable" > /etc/apt/sources.list.d/docker_com.list
+
+    apt-get update
+    apt-get install -y -q docker-ce docker-compose
+
+    date -Isec > /tmp/apt_run_this_boot
+fi
 
 #############################
 # remove running containers #