Skip to content

Commit 8105eff

Browse files
committed
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 <rameshbabu.thoomu@gmail.com> Change-Id: I64132f8f086b26ebca2200dc78ac429388883309
1 parent fc53b9d commit 8105eff

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

scripts/bootstrap.sh

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,24 @@ printHelp() {
2727
echo "would download docker images and binaries for version 1.4.4"
2828
}
2929

30-
# dockerFabricPull() pulls docker images from fabric and chaincode repositories
30+
# dockerPull() pulls docker images from fabric and chaincode repositories
3131
# note, if a docker image doesn't exist for a requested release, it will simply
3232
# be skipped, since this script doesn't terminate upon errors.
33-
dockerFabricPull() {
34-
local FABRIC_TAG=$1
35-
for IMAGES in peer orderer ccenv tools baseos nodeenv javaenv; do
36-
echo "==> FABRIC IMAGE: $IMAGES"
37-
echo
38-
docker pull "hyperledger/fabric-$IMAGES:$FABRIC_TAG"
39-
docker tag "hyperledger/fabric-$IMAGES:$FABRIC_TAG" "hyperledger/fabric-$IMAGES"
40-
done
41-
}
4233

43-
dockerThirdPartyImagesPull() {
44-
local THIRDPARTY_TAG=$1
45-
for IMAGES in couchdb kafka zookeeper; do
46-
echo "==> THIRDPARTY DOCKER IMAGE: $IMAGES"
47-
echo
48-
docker pull "hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG"
49-
docker tag "hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG" "hyperledger/fabric-$IMAGES"
34+
dockerPull() {
35+
image_tag=$1
36+
shift
37+
while [[ $# -gt 0 ]]
38+
do
39+
image_name="$1"
40+
echo "====> hyperledger/fabric-$image_name:$image_tag"
41+
docker pull "hyperledger/fabric-$image_name:$image_tag"
42+
docker tag "hyperledger/fabric-$image_name:$image_tag" "hyperledger/fabric-$image_name"
43+
shift
5044
done
5145
}
5246

53-
dockerCaPull() {
54-
local CA_TAG=$1
55-
echo "==> FABRIC CA IMAGE"
56-
echo
57-
docker pull "hyperledger/fabric-ca:$CA_TAG"
58-
docker tag "hyperledger/fabric-ca:$CA_TAG" "hyperledger/fabric-ca"
59-
}
60-
61-
samplesInstall() {
47+
cloneSamplesRepo() {
6248
# clone (if needed) hyperledger/fabric-samples and checkout corresponding
6349
# version to the binaries and docker images to be downloaded
6450
if [ -d first-network ]; then
@@ -90,7 +76,7 @@ download() {
9076
fi
9177
}
9278

93-
binariesInstall() {
79+
pullBinaries() {
9480
echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries"
9581
download "${BINARY_FILE}" "https://github.com/hyperledger/fabric/releases/download/v${VERSION}/${BINARY_FILE}"
9682
if [ $? -eq 22 ]; then
@@ -110,16 +96,30 @@ binariesInstall() {
11096
fi
11197
}
11298

113-
dockerInstall() {
99+
pullDockerImages() {
114100
command -v docker >& /dev/null
115101
NODOCKER=$?
116102
if [ "${NODOCKER}" == 0 ]; then
103+
FABRIC_IMAGES=(peer orderer ccenv tools)
104+
case "$VERSION" in
105+
1.*)
106+
FABRIC_IMAGES+=(javaenv)
107+
shift
108+
;;
109+
2.*)
110+
FABRIC_IMAGES+=(nodeenv baseos javaenv)
111+
shift
112+
;;
113+
esac
114+
echo "FABRIC_IMAGES:" "${FABRIC_IMAGES[@]}"
117115
echo "===> Pulling fabric Images"
118-
dockerFabricPull "${FABRIC_TAG}"
116+
dockerPull "${FABRIC_TAG}" "${FABRIC_IMAGES[@]}"
119117
echo "===> Pulling fabric ca Image"
120-
dockerCaPull "${CA_TAG}"
118+
CA_IMAGE=(ca)
119+
dockerPull "${CA_TAG}" "${CA_IMAGE[@]}"
121120
echo "===> Pulling thirdparty docker images"
122-
dockerThirdPartyImagesPull "${THIRDPARTY_TAG}"
121+
THIRDPARTY_IMAGES=(zookeeper kafka couchdb)
122+
dockerPull "${THIRDPARTY_TAG}" "${THIRDPARTY_IMAGES[@]}"
123123
echo
124124
echo "===> List out hyperledger docker images"
125125
docker images | grep hyperledger
@@ -179,19 +179,19 @@ done
179179

180180
if [ "$SAMPLES" == "true" ]; then
181181
echo
182-
echo "Installing hyperledger/fabric-samples repo"
182+
echo "Clone hyperledger/fabric-samples repo"
183183
echo
184-
samplesInstall
184+
cloneSamplesRepo
185185
fi
186186
if [ "$BINARIES" == "true" ]; then
187187
echo
188-
echo "Installing Hyperledger Fabric binaries"
188+
echo "Pull Hyperledger Fabric binaries"
189189
echo
190-
binariesInstall
190+
pullBinaries
191191
fi
192192
if [ "$DOCKER" == "true" ]; then
193193
echo
194-
echo "Installing Hyperledger Fabric docker images"
194+
echo "Pull Hyperledger Fabric docker images"
195195
echo
196-
dockerInstall
196+
pullDockerImages
197197
fi

0 commit comments

Comments
 (0)