This repository has been archived by the owner on May 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbootstrap_app.sh
executable file
·65 lines (56 loc) · 1.64 KB
/
bootstrap_app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
function stopContainers(){
echo
# Stop chaincode containers and images as well
docker rm -f $(docker ps -aq --filter name=dev-peer) > /dev/null 2>&1
docker rmi $(docker images | awk '$1 ~ /dev-peer/ { print $3 }') > /dev/null 2>&1
echo
}
function restartNetwork() {
echo
#teardown the network and clean the containers and intermediate images
echo "============== Stopping docker containers =============="
docker-compose -f ./artifacts/docker-compose.yaml down
stopContainers
echo "============== Docker containers have been stopped =============="
echo
#Cleanup the stores
rm -rf ./fabric-client-kv-org*
#Start the network
docker-compose -f ./artifacts/docker-compose.yaml up -d
echo
}
function installNodeModules() {
echo
if [ -d node_modules ]; then
echo "============== node modules installed already ============="
else
echo "============== Installing node modules ============="
npm install
fi
echo
}
function downloaFabricImages(){
FABRIC_TAG=1.2.0
FABRIC_IMAGES=$(docker images | grep 1.2.0 | wc -l)
if [ "$FABRIC_IMAGES" != "5" ]; then
echo "============== Downloading Fabric Images =============="
for image in peer orderer ca ccenv tools; do
docker pull hyperledger/fabric-$image:$FABRIC_TAG
docker tag hyperledger/fabric-$image:$FABRIC_TAG hyperledger/fabric-$image
done
fi
}
# Download v1.2 docker images
downloaFabricImages
#Restart the network each time you start application
restartNetwork
#Install 1.2 node modules
installNodeModules
# start the node app on port 4000
PORT=4000 node app