forked from reportportal/reportportal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magic-script.sh
310 lines (281 loc) · 6.98 KB
/
magic-script.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#Required pre-installed software:
# 1) Git,
# 2) docker,
# 3) docker-compose.
#Important settings for Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docker.html#docker-cli-run-prod-mode
#branch args
branchServiceApi="ps-migrations"
branchServiceAuthorization="spb4"
branchServiceIndex="v5"
branchServiceJira="v5"
branchServiceRally="v5"
branchServiceUi="develop"
#migrations
if [ -d "$PWD/migrations" ]; then
cd ./migrations
git pull
cd ..
else
git clone https://gitlab.com/avarabyeu/migrations.git
fi
#service-api
if [ -d "$PWD/service-api" ]; then
cd ./service-api
git checkout "$branchServiceApi"
git pull
cd ..
else
git clone https://github.com/reportportal/service-api.git
cd ./service-api
git checkout "$branchServiceApi"
cd ..
fi
#service-authorization
if [ -d "$PWD/service-authorization" ]; then
cd ./service-authorization
git checkout "$branchServiceAuthorization"
git pull
cd ..
else
git clone https://github.com/reportportal/service-authorization.git
cd ./service-authorization
git checkout "$branchServiceAuthorization"
cd ..
fi
#service-index
if [ -d "$PWD/service-index" ]; then
cd ./service-index
git checkout "$branchServiceIndex"
git pull
cd ..
else
git clone https://github.com/reportportal/service-index.git
cd ./service-index
git checkout "$branchServiceIndex"
cd ..
fi
#service-analyzer
if [ -d "$PWD/service-analyzer" ]; then
cd ./service-analyzer
git pull
cd ..
else
git clone https://github.com/reportportal/service-analyzer.git
fi
#service-ui
if [ -d "$PWD/service-ui" ]; then
cd ./service-ui
git checkout "$branchServiceUi"
git pull
cd ..
else
git clone https://github.com/reportportal/service-ui.git
cd ./service-ui
git checkout "$branchServiceUi"
cd ..
fi
#service-jira
if [ -d "$PWD/service-jira" ]; then
cd ./service-jira
git checkout "$branchServiceJira"
git pull
cd ..
else
git clone https://github.com/reportportal/service-jira.git
cd ./service-jira
git checkout "$branchServiceJira"
cd ..
fi
#service-rally
if [ -d "$PWD/service-rally" ]; then
cd ./service-rally
git checkout "branchServiceRally"
git pull
cd ..
else
git clone https://github.com/reportportal/service-rally.git
cd ./service-rally
git checkout "branchServiceRally"
cd ..
fi
#create docker-compose.yml
cat <<EOF >$PWD/docker-compose.yml
version: '2'
services:
rabbitmq:
image: rabbitmq:3
ports:
- "5672:5672"
hostname: redis-host
registry:
image: consul:1.0.6
volumes:
- ./data/consul:/consul/data
ports:
- "8500:8500"
command: "agent -server -bootstrap-expect=1 -ui -client 0.0.0.0"
environment:
- 'CONSUL_LOCAL_CONFIG={"leave_on_terminate": true}'
restart: always
gateway:
image: traefik:1.6.3
ports:
- "9080:8080" # HTTP exposed
- "9081:8081" # HTTP Administration exposed
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
- --docker
- --docker.watch
- --docker.constraints=tag==v5
- --defaultEntryPoints=http
- --entryPoints=Name:http Address::8080
- --logLevel=DEBUG
#- --consulcatalog.endpoint=registry:8500
- --web
- --web.address=:8081
- --web.metrics=true
- --web.metrics.prometheus=true
restart: always
postgres:
image: postgres:10.1-alpine
environment:
POSTGRES_USER: rpuser
POSTGRES_PASSWORD: rppass
POSTGRES_DB: reportportal
volumes:
- ./data/postgres:/var/lib/postgresql/data
restart: on-failure
# If you need to access the DB locally. Could be a security risk to expose DB.
ports:
- "5432:5432"
migrations:
build:
context: ./migrations
dockerfile: Dockerfile
depends_on:
- postgres
environment:
POSTGRES_USER: rpuser
POSTGRES_PORT: 5432
POSTGRES_PASSWORD: rppass
POSTGRES_SERVER: postgres
POSTGRES_DB: reportportal
uat:
build:
context: ./service-authorization
dockerfile: ./docker/Dockerfile-develop
depends_on:
- postgres
restart: always
ports:
- "9999:9999"
environment:
#- RP_PROFILES=docker #TODO
- RP_SESSION_LIVE=86400
labels:
- "traefik.backend=uat"
- "traefik.frontend.rule=PathPrefixStrip:/uat"
- "traefik.enable=true"
- "traefik.port=9999"
- "traefik.tags=v5"
api:
build:
context: ./service-api
dockerfile: ./docker/Dockerfile-develop
depends_on:
- postgres
- rabbitmq
restart: always
ports:
- "8585:8585"
environment:
#- RP_PROFILES=docker //TODO
- JAVA_OPTS=-Xmx1g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp
labels:
- "traefik.backend=api"
- "traefik.frontend.rule=PathPrefix:/api/v1"
- "traefik.enable=true"
- "traefik.port=8585"
- "traefik.tags=v5"
index:
build:
context: ./service-index
dockerfile: Dockerfile-develop
environment:
- RP_SERVER_PORT=8080
- RP_PROXY_CONSUL=true
depends_on:
- registry
- gateway
restart: always
ui:
build:
context: ./service-ui
dockerfile: Dockerfile-full
environment:
- RP_SERVER.PORT=8080
- RP_CONSUL.TAGS=urlprefix-/ui opts strip=/ui
- RP_CONSUL.ADDRESS=registry:8500
restart: always
labels:
- "traefik.backend=ui"
- "traefik.frontend.rule=PathPrefixStrip:/ui"
- "traefik.enable=true"
- "traefik.port=8080"
- "traefik.tags=v5"
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.1
restart: always
volumes:
- ./data/elasticsearch:/usr/share/elasticsearch/data
environment:
- bootstrap.memory_lock=true
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
ports:
- 9200:9200
analyzer:
build:
context: ./service-analyzer
dockerfile: DockerfileDev
depends_on:
- registry
- gateway
- elasticsearch
restart: always
jira:
build:
context: ./service-jira
dockerfile: ./docker/Dockerfile-develop
environment:
- RP_PROFILES=docker
restart: always
rally:
build:
context: ./service-rally
dockerfile: ./docker/Dockerfile-develop
environment:
- RP_PROFILES=docker
restart: always
EOF
#stop container and remove them with images
if [ $(docker ps --filter="name=api" --format="{{.Names}}" | sed 's/\(.*\)_api_[0-9]*/\1/') ]; then
docker-compose -p reportportal down --rmi all
fi
#setting folder for elasticsearch
if [ -d "$PWD/data" ]; then
rm -rf data
fi
mkdir data
mkdir data/elasticsearch
chmod g+rwx data/elasticsearch
chgrp 1000 data/elasticsearch
#create docker images, containers and start them
docker-compose -p reportportal build
docker-compose -p reportportal up -d