forked from j5s/DongTai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_with_docker_compose.sh
executable file
·123 lines (106 loc) · 3.42 KB
/
build_with_docker_compose.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# download source code
# Check if the Docker service is turned on
check_docker(){
echo "\n\033[33m[+] check docker servie status\033[0m"
docker ps 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echo "\033[31m[-] docker service is down. please start docker service and rerun.\033[0m"
exit
else
echo "\033[32m[*]\033[0m docker service is up."
fi
}
# Specify the port of Web, OpenAPI service and check whether it is available
check_port(){
echo "\n\033[33m[+] check port status\033[0m"
read -p "[+] please input web service port, default [80]:" WEB_SERVICE_PORT
if [ -z $WEB_SERVICE_PORT ];then
WEB_SERVICE_PORT=80
fi
lsof -i:$WEB_SERVICE_PORT|grep "LISTEN" 2>/dev/null
if [ $? -ne 0 ]; then
echo "\033[32m[*]\033[0m port $WEB_SERVICE_PORT is ok."
else
echo "\033[31m[-] port $WEB_SERVICE_PORT is already in use. please change default port\033[0m"
exit
fi
read -p "[+] please input openAPI service port, default [8000]:" OPENAPI_SERVICE_PORT
if [ -z $OPENAPI_SERVICE_PORT ];then
OPENAPI_SERVICE_PORT=8000
fi
lsof -i:$OPENAPI_SERVICE_PORT | grep "LISTEN" 2>/dev/null
if [ $? -ne 0 ]; then
echo "\033[32m[*]\033[0m port $OPENAPI_SERVICE_PORT is ok."
else
echo "\033[31m[-] port $OPENAPI_SERVICE_PORT is already in use. please change default port\033[0m"
exit
fi
echo '''version: "2"
services:
dongtai-mysql:
image: registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-mysql:latest
restart: always
volumes:
- ./data:/var/lib/mysql:rw
dongtai-redis:
image: registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-redis:latest
restart: always
dongtai-webapi:
image: registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-webapi:latest
restart: always
volumes:
- $PWD/config-tutorial.ini:/opt/dongtai/webapi/conf/config.ini
depends_on:
- dongtai-mysql
- dongtai-redis
dongtai-web:
image: registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-web:latest
restart: always
ports:
- "'''$WEB_SERVICE_PORT''':80"
volumes:
- $PWD/nginx.conf:/etc/nginx/nginx.conf
depends_on:
- dongtai-webapi
dongtai-openapi:
image: registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-openapi:latest
restart: always
volumes:
- $PWD/config-tutorial.ini:/opt/dongtai/openapi/conf/config.ini
ports:
- "'''$OPENAPI_SERVICE_PORT''':8000"
depends_on:
- dongtai-mysql
- dongtai-redis
dongtai-engine:
image: registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-engine:latest
restart: always
volumes:
- $PWD/config-tutorial.ini:/opt/dongtai/engine/conf/config.ini
depends_on:
- dongtai-mysql
- dongtai-redis
dongtai-engine-task:
image: registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-engine:latest
restart: always
command: ["/opt/dongtai/engine/docker/entrypoint.sh", "task"]
volumes:
- $PWD/config-tutorial.ini:/opt/dongtai/engine/conf/config.ini
depends_on:
- dongtai-mysql
- dongtai-redis
- dongtai-engine''' > deploy/docker-compose/docker-compose.yml
}
build_dongtai_iast(){
echo "\n\033[33m[+] install DongTai IAST service, openapi service addr is $1\033[0m"
chmod u+x deploy/docker-compose/install.sh
if [ $? -ne 0 ]; then
bash deploy/docker-compose/install.sh $1
else
./deploy/docker-compose/install.sh $1
fi
echo "\n\033[32m[*] start DongTai IAST service, please wait 30s\033[0m"
}
check_docker
check_port
build_dongtai_iast