Browse Source

build docker images script can fetch cached image from docker hub

Mokhtar Naamani 4 years ago
parent
commit
c3033bf79e
1 changed files with 21 additions and 9 deletions
  1. 21 9
      build-docker-images.sh

+ 21 - 9
build-docker-images.sh

@@ -8,18 +8,30 @@ then
   exit 0
 fi
 
+# Build or fetch cached joystream/node docker image
+if [[ "$SKIP_JOYSTREAM_NODE" = 1 || "$SKIP_JOYSTREAM_NODE" = "true" ]]; then
+  echo "Skipping build of joystream/node docker image."
+else
+  # Fetch a cached joystream/node image if one is found matching code shasum instead of building
+  CODE_HASH=`scripts/runtime-code-shasum.sh`
+  IMAGE=joystream/node:${CODE_HASH}
+  echo "Trying to fetch cashed ${IMAGE} image"
+  docker pull ${IMAGE} || :
+
+  if ! docker inspect ${IMAGE} > /dev/null;
+  then
+    echo "Fetch failed, building image locally"
+    docker-compose build joystream-node
+  else
+    echo "Tagging cached image as 'latest'"
+    docker image tag ${IMAGE} joystream/node:latest
+  fi
+fi
+
 # Build joystream/apps docker image
 echo "Building 'joystream/apps' docker image..."
 docker-compose build colossus
 
 # Build the pioneer docker image
 echo "Building pioneer docker image"
-docker-compose build pioneer
-
-if [[ "$SKIP_JOYSTREAM_NODE" = 1 || "$SKIP_JOYSTREAM_NODE" = "true" ]]; then
-  echo "Skipping build of joystream/node docker image."
-else
-  # TODO: Try to fetch a cached joystream/node image
-  # if one is found matching code shasum instead of building
-  docker-compose build joystream-node
-fi
+docker-compose build pioneer