-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop.sh
executable file
·42 lines (37 loc) · 1.33 KB
/
stop.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
export IMAGE_TAG="latest"
export COMPOSE_PROJECT_NAME="trace-fruits"
# Obtain CONTAINER_IDS and remove them
# TODO Might want to make this optional - could clear other containers
function clearContainers() {
CONTAINER_IDS=$(docker ps -a | awk '($2 ~ /dev-peer.*.mycc.*/) {print $1}')
if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" == " " ]; then
echo "---- No containers available for deletion ----"
else
docker rm -f $CONTAINER_IDS
fi
}
# Delete any images that were generated as a part of this setup
# specifically the following images are often left behind:
# TODO list generated image naming patterns
function removeUnwantedImages() {
DOCKER_IMAGE_IDS=$(docker images | awk '($1 ~ /dev-peer.*.trace_fruits_cc.*/) {print $3}')
if [ -z "$DOCKER_IMAGE_IDS" -o "$DOCKER_IMAGE_IDS" == " " ]; then
echo "---- No images available for deletion ----"
else
docker rmi -f $DOCKER_IMAGE_IDS
fi
}
docker-compose -f docker-compose-cli.yaml \
-f docker-compose-couch.yaml \
-f docker-compose-etcdraft2.yaml \
-f docker-compose-splunk.yaml \
-f docker-compose-splunk-etcdraft2.yaml \
-f docker-compose-splunk-couch.yaml \
down \
--volumes --remove-orphans
# reset .checkpoint
truncate -s 0 .checkpoints
#Cleanup the chaincode containers
clearContainers
#Cleanup images
removeUnwantedImages