-
Notifications
You must be signed in to change notification settings - Fork 13
/
down.sh
executable file
·47 lines (38 loc) · 1.26 KB
/
down.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
#!/bin/bash
source scripts/common.sh
echo "Bringing Tyk Demo deployment DOWN"
# check if deployments exist
if [[ -s .bootstrap/bootstrapped_deployments ]]; then
# display deployments to be removed
echo "Deployments to remove:"
while read deployment; do
echo " $deployment"
done < .bootstrap/bootstrapped_deployments
else
echo "No deployments to remove. Exiting."
exit
fi
# execute docker compose command
command_docker_compose="$(generate_docker_compose_command) down -v --remove-orphans"
echo "Running docker compose command: $command_docker_compose"
eval $command_docker_compose
if [ "$?" != 0 ]; then
echo "Error when running 'docker compose down' command"
exit 1
fi
# run teardown scripts, if they exist
while read deployment; do
teardownPath="deployments/$deployment/teardown.sh"
if [ -f $teardownPath ]; then
echo "Performing teardown for $deployment deployment"
eval ./deployments/$deployment/teardown.sh
if [ "$?" != 0 ]; then
echo "Error when running teardown for $deployment deployment"
fi
fi
done < .bootstrap/bootstrapped_deployments
echo "All containers were stopped and removed"
# clear the bootstraped deployments
echo -n > .bootstrap/bootstrapped_deployments
# clear context data
rm -f .context-data/* 1> /dev/null