From 8105eff197207bdcb2e19115ae2b83fb92daff80 Mon Sep 17 00:00:00 2001 From: rameshthoomu Date: Wed, 30 Oct 2019 06:02:01 -0400 Subject: [PATCH] FAB-16812 Update bootstrap script This patch adds a logic to pull the docker images based on the version passed to the script. As nodeenv and baseos images are not available in all the release branches, the image list is updated accordingly. Also, renamed the function names appropritely. Signed-off-by: rameshthoomu Change-Id: I64132f8f086b26ebca2200dc78ac429388883309 --- scripts/bootstrap.sh | 74 ++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 854e9d68776..bc15aeb9923 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -27,38 +27,24 @@ printHelp() { echo "would download docker images and binaries for version 1.4.4" } -# dockerFabricPull() pulls docker images from fabric and chaincode repositories +# dockerPull() pulls docker images from fabric and chaincode repositories # note, if a docker image doesn't exist for a requested release, it will simply # be skipped, since this script doesn't terminate upon errors. -dockerFabricPull() { - local FABRIC_TAG=$1 - for IMAGES in peer orderer ccenv tools baseos nodeenv javaenv; do - echo "==> FABRIC IMAGE: $IMAGES" - echo - docker pull "hyperledger/fabric-$IMAGES:$FABRIC_TAG" - docker tag "hyperledger/fabric-$IMAGES:$FABRIC_TAG" "hyperledger/fabric-$IMAGES" - done -} -dockerThirdPartyImagesPull() { - local THIRDPARTY_TAG=$1 - for IMAGES in couchdb kafka zookeeper; do - echo "==> THIRDPARTY DOCKER IMAGE: $IMAGES" - echo - docker pull "hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG" - docker tag "hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG" "hyperledger/fabric-$IMAGES" +dockerPull() { + image_tag=$1 + shift + while [[ $# -gt 0 ]] + do + image_name="$1" + echo "====> hyperledger/fabric-$image_name:$image_tag" + docker pull "hyperledger/fabric-$image_name:$image_tag" + docker tag "hyperledger/fabric-$image_name:$image_tag" "hyperledger/fabric-$image_name" + shift done } -dockerCaPull() { - local CA_TAG=$1 - echo "==> FABRIC CA IMAGE" - echo - docker pull "hyperledger/fabric-ca:$CA_TAG" - docker tag "hyperledger/fabric-ca:$CA_TAG" "hyperledger/fabric-ca" -} - -samplesInstall() { +cloneSamplesRepo() { # clone (if needed) hyperledger/fabric-samples and checkout corresponding # version to the binaries and docker images to be downloaded if [ -d first-network ]; then @@ -90,7 +76,7 @@ download() { fi } -binariesInstall() { +pullBinaries() { echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries" download "${BINARY_FILE}" "https://github.com/hyperledger/fabric/releases/download/v${VERSION}/${BINARY_FILE}" if [ $? -eq 22 ]; then @@ -110,16 +96,30 @@ binariesInstall() { fi } -dockerInstall() { +pullDockerImages() { command -v docker >& /dev/null NODOCKER=$? if [ "${NODOCKER}" == 0 ]; then + FABRIC_IMAGES=(peer orderer ccenv tools) + case "$VERSION" in + 1.*) + FABRIC_IMAGES+=(javaenv) + shift + ;; + 2.*) + FABRIC_IMAGES+=(nodeenv baseos javaenv) + shift + ;; + esac + echo "FABRIC_IMAGES:" "${FABRIC_IMAGES[@]}" echo "===> Pulling fabric Images" - dockerFabricPull "${FABRIC_TAG}" + dockerPull "${FABRIC_TAG}" "${FABRIC_IMAGES[@]}" echo "===> Pulling fabric ca Image" - dockerCaPull "${CA_TAG}" + CA_IMAGE=(ca) + dockerPull "${CA_TAG}" "${CA_IMAGE[@]}" echo "===> Pulling thirdparty docker images" - dockerThirdPartyImagesPull "${THIRDPARTY_TAG}" + THIRDPARTY_IMAGES=(zookeeper kafka couchdb) + dockerPull "${THIRDPARTY_TAG}" "${THIRDPARTY_IMAGES[@]}" echo echo "===> List out hyperledger docker images" docker images | grep hyperledger @@ -179,19 +179,19 @@ done if [ "$SAMPLES" == "true" ]; then echo - echo "Installing hyperledger/fabric-samples repo" + echo "Clone hyperledger/fabric-samples repo" echo - samplesInstall + cloneSamplesRepo fi if [ "$BINARIES" == "true" ]; then echo - echo "Installing Hyperledger Fabric binaries" + echo "Pull Hyperledger Fabric binaries" echo - binariesInstall + pullBinaries fi if [ "$DOCKER" == "true" ]; then echo - echo "Installing Hyperledger Fabric docker images" + echo "Pull Hyperledger Fabric docker images" echo - dockerInstall + pullDockerImages fi