-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·100 lines (89 loc) · 1.95 KB
/
build.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
COMMAND="$1"
SUBCOMMAND="$2"
export DEV_IMAGE=dev/tracer-ui
export PROD_IMAGE=catenasys/tracer-ui
export PROD_CONTAINER=tracer-ui
export MOCK_API_IMAGE=mock/api
export ISOLATION_ID="dev"
function devmock(){
if [ ! -z ${ISOLATION_ID} ]; then
docker-compose -f ./docker-compose-build.yaml build dev
docker-compose -f ./scenario/mock-local.yaml up
else
echo "Set ISOLATION_ID"
exit 1
fi
}
function devclean(){
if [ ! -z ${ISOLATION_ID} ]; then
docker rm -f $(docker ps -aq)
docker rmi -f $(docker images --filter "dangling=true" -q)
docker rmi -f ${DEV_IMAGE}:${ISOLATION_ID}
docker rmi -f ${MOCK_API_IMAGE}
else
echo "Set ISOLATION_ID"
exit 1
fi
}
function dev(){
local subcommand="$1"
case $subcommand in
"mock")
devmock
;;
"clean")
devclean
;;
*)
echo "$COMMAND [mock | clean]"
;;
esac
}
function prodbuild(){
if [ ! -z ${ISOLATION_ID} ]; then
docker-compose -f ./docker-compose-build.yaml build prod
else
echo "Set ISOLATION_ID"
exit 1
fi
}
function prodmock(){
docker-compose -f ./scenario/daml-local.yaml up
}
function prodclean(){
docker rmi -f $(docker images --filter "dangling=true" -q)
docker rmi -f ${PROD_IMAGE}:${ISOLATION_ID}
}
function prod(){
local subcommand="$1"
case $subcommand in
"build")
prodbuild
;;
"mock")
prodmock
;;
"clean")
prodclean
;;
*)
echo "$COMMAND [build | mock | clean]"
;;
esac
}
case $COMMAND in
"dev")
dev $SUBCOMMAND
;;
"prod")
prod $SUBCOMMAND
;;
"clean")
devclean
prodclean
;;
*)
echo "$0 dev [mock|clean] | prod [build|clean] | clean"
;;
esac