Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
241 lines (236 loc) · 9.69 KB
/
Copy pathdocker-compose.yml
File metadata and controls
241 lines (236 loc) · 9.69 KB
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
---
# The services of MCloud: STF, the grid and the nginx in front of them (README.md).
# The image tags and the ports come from .env, the settings of the services from variables.env:
# ./zebrunner.sh setup writes both from their *.original files.
networks:
default:
name: infra
external: true
# the logs of every service are rotated: the default json-file driver of docker keeps them all (LOG_MAX_SIZE, LOG_MAX_FILE of .env)
x-logging: &logging
driver: json-file
options:
max-size: "${LOG_MAX_SIZE:-50m}"
max-file: "${LOG_MAX_FILE:-5}"
# the STF units: one image, the settings of variables.env, started after the database migration
x-stf: &stf
image: "public.ecr.aws/zebrunner/stf:${TAG_STF}"
env_file:
- variables.env
depends_on:
stf-migrate:
condition: service_completed_successfully
logging: *logging
restart: always
# the units with an HTTP port: it accepts connections (docker ps shows an unhealthy unit)
x-http-healthcheck: &http-healthcheck
test: ["CMD", "node", "-e", "require('net').connect(3000, '127.0.0.1').on('connect', () => process.exit(0)).on('error', () => process.exit(1))"]
interval: 10s
timeout: 5s
retries: 3
start_period: 60s
# the units without a port: healthy while they are connected (ESTABLISHED) to the ports of their arguments, their
# ZeroMQ brokers and RethinkDB; ZeroMQ reconnects by itself, a unit without its connections is cut off from STF
x-connections-script: &connections-script >-
const fs = require('fs'); const up = new Set();
for (const f of ['/proc/net/tcp', '/proc/net/tcp6']) { try {
for (const l of fs.readFileSync(f, 'utf8').split('\n').slice(1)) {
const c = l.trim().split(/\s+/); if (c[3] === '01') up.add(parseInt(c[2].split(':').pop(), 16)); } } catch (e) {} }
process.exit(process.argv.slice(1).every((p) => up.has(Number(p))) ? 0 : 1)
x-connections-healthcheck: &connections-healthcheck
interval: 10s
timeout: 5s
retries: 3
start_period: 60s
services:
stf-proxy:
image: "nginx:${TAG_NGINX}"
container_name: stf-proxy
volumes:
- ./configuration/stf-proxy/nginx.conf:/etc/nginx/nginx.conf:ro
- ./configuration/stf-proxy/ssl:/etc/nginx/ssl:ro
- ./configuration/stf-proxy/htpasswd:/etc/nginx/htpasswd:ro
- ./configuration/stf-proxy/grid:/usr/share/nginx/html/grid:ro
ports:
- "${STF_PORT}:80" # primary HTTP port
depends_on:
stf-app:
condition: service_healthy
healthcheck:
test: ["CMD", "bash", "-c", "echo > /dev/tcp/127.0.0.1/80"]
interval: 10s
timeout: 5s
retries: 3
start_period: 30s
logging: *logging
restart: always
# the TCP relay of the remote debug of STF (adb connect) for the nodes in a private network: ./zebrunner.sh starts it
# with the profile adb-relay when ADB_RELAY of .env is true (README.md#remote-debug-through-the-adb-relay)
adb-relay:
image: "nginx:${TAG_NGINX}"
container_name: adb-relay
profiles: [adb-relay]
# it listens on the remote debug ports of the devices on every address of the server, connects to the nodes and
# reads the devices of the nodes from stf-proxy on the port of the host: the network of the host instead of published
# ports
network_mode: host
# nginx and the sync of the devices of STF
entrypoint: ["bash", "/opt/adb-relay/adb-relay.sh"]
environment:
- ADB_RELAY=${ADB_RELAY:-false}
- ADB_RELAY_PORTS=${ADB_RELAY_PORTS:-}
- ADB_RELAY_SYNC_SECONDS=${ADB_RELAY_SYNC_SECONDS:-300}
- STF_URL=${STF_URL}
- STF_PORT=${STF_PORT}
volumes:
- ./configuration/adb-relay/nginx.conf:/etc/nginx/nginx.conf:ro
# adb-relay.sh, its awk programs and stf-token (STF_TOKEN of variables.env only, written by ./zebrunner.sh)
- ./configuration/adb-relay:/opt/adb-relay:ro
healthcheck:
# nginx writes its pid once it listens on every port of the ranges
test: ["CMD", "sh", "-c", "kill -0 $$(cat /run/nginx.pid)"]
interval: 10s
timeout: 5s
retries: 3
start_period: 30s
logging: *logging
restart: always
mcloud-grid:
image: "public.ecr.aws/zebrunner/mcloud-grid:${TAG_SELENIUM_HUB}"
container_name: mcloud-grid
env_file:
- variables.env
environment:
- STF_URL=http://stf-api:3000
# 10 min session wait timeout as 20 min is configured on NGiNX
- GRID_NEW_SESSION_WAIT_TIMEOUT=600000
- CHECK_APPIUM_STATUS=true
# the details of the grid in its JSON logs
# - MCLOUD_LOG_LEVEL=FINE
# the nodes register on AGENTS_ADDRESS:4446, the grid of the join string of ./zebrunner.sh node-invite
ports:
- "${AGENTS_ADDRESS}:4446:4444"
# the healthcheck is the one of the image (/wd/hub/status)
logging: *logging
restart: always
rethinkdb:
image: "rethinkdb:${TAG_RETHINKDB}"
container_name: rethinkdb
volumes:
- "stf-db-volume:/data"
command: rethinkdb --bind all --cache-size 8192 --no-update-check --no-http-admin
healthcheck:
test: ["CMD", "bash", "-c", "echo > /dev/tcp/127.0.0.1/28015"]
interval: 2s
timeout: 5s
retries: 30
logging: *logging
restart: always
# creates and updates the tables (e.g. the sessions of the sign-ins) before the other units start
stf-migrate:
image: "public.ecr.aws/zebrunner/stf:${TAG_STF}"
container_name: stf-migrate
env_file:
- variables.env
command: stf migrate
depends_on:
rethinkdb:
condition: service_healthy
logging: *logging
stf-app:
<<: *stf
container_name: stf-app
healthcheck: *http-healthcheck
command: stf app --port 3000 --auth-url ${STF_URL}/${AUTH_URL} --websocket-url ${STF_URL}/
stf-auth:
<<: *stf
container_name: stf-auth
healthcheck: *http-healthcheck
# ${STF_URL}/stf/ with slash at the end produce invalid redirect! /stf/?jwt=e...
command: stf ${AUTH_SYSTEM} --port 3000 --app-url ${STF_URL}/stf
stf-processor001:
<<: *stf
container_name: stf-processor001
healthcheck:
<<: *connections-healthcheck
test: ["CMD", "node", "-e", *connections-script, "7160", "7260", "28015"]
command: stf processor proc001 --connect-app-dealer tcp://stf-triproxy-app:7160 --connect-dev-dealer tcp://stf-triproxy-dev:7260
stf-reaper:
<<: *stf
container_name: stf-reaper
healthcheck:
<<: *connections-healthcheck
test: ["CMD", "node", "-e", *connections-script, "7150", "7270", "28015"]
command: stf reaper reaper001 --connect-push tcp://stf-triproxy-dev:7270 --connect-sub tcp://stf-triproxy-app:7150 --heartbeat-timeout 30000
stf-storage-plugin-apk:
<<: *stf
container_name: stf-storage-plugin-apk
healthcheck: *http-healthcheck
command: stf storage-plugin-apk --port 3000 --storage-url ${STF_URL}/
stf-storage-plugin-image:
<<: *stf
container_name: stf-storage-plugin-image
healthcheck: *http-healthcheck
command: stf storage-plugin-image --port 3000 --storage-url ${STF_URL}/
# SECRET and STF_STORAGE_TOKEN of variables.env protect the storage routes
stf-storage-temp:
<<: *stf
container_name: stf-storage-temp
healthcheck: *http-healthcheck
volumes:
- "stf-temp-volume:/data"
command: stf storage-temp --port 3000 --save-dir /data
stf-triproxy-app:
<<: *stf
container_name: stf-triproxy-app
healthcheck:
<<: *http-healthcheck
test: ["CMD", "node", "-e", "require('net').connect(7160, '127.0.0.1').on('connect', () => process.exit(0)).on('error', () => process.exit(1))"]
command: stf triproxy app001 --bind-pub "tcp://*:7150" --bind-dealer "tcp://*:7160" --bind-pull "tcp://*:7170"
# the nodes connect to the dealer only; their ZeroMQ ports are on AGENTS_ADDRESS, the host of the join string of
# ./zebrunner.sh node-invite
ports:
- "${AGENTS_ADDRESS}:7160:7160"
stf-triproxy-dev:
<<: *stf
container_name: stf-triproxy-dev
healthcheck:
<<: *http-healthcheck
test: ["CMD", "node", "-e", "require('net').connect(7260, '127.0.0.1').on('connect', () => process.exit(0)).on('error', () => process.exit(1))"]
command: stf triproxy dev001 --bind-pub "tcp://*:7250" --bind-dealer "tcp://*:7260" --bind-pull "tcp://*:7270"
ports:
- "${AGENTS_ADDRESS}:7250:7250"
- "${AGENTS_ADDRESS}:7260:7260"
- "${AGENTS_ADDRESS}:7270:7270"
stf-websocket:
<<: *stf
container_name: stf-websocket
healthcheck: *http-healthcheck
command: >-
stf websocket --port 3000 --storage-url ${STF_URL}/
--connect-sub tcp://stf-triproxy-app:7150 --connect-push tcp://stf-triproxy-app:7170
stf-api:
<<: *stf
container_name: stf-api
healthcheck: *http-healthcheck
# --nodes-connect-*: the ZeroMQ endpoints of the answer of the enrollment, the published ports of the triproxies at
# NODES_HOST (the host of the join string); --nodes-stf-url is STF_URL of variables.env, the public URL
command: >-
stf api --port 3000
--connect-sub tcp://stf-triproxy-app:7150 --connect-push tcp://stf-triproxy-app:7170
--connect-sub-dev tcp://stf-triproxy-dev:7250 --connect-push-dev tcp://stf-triproxy-dev:7270
--nodes-connect-sub tcp://${NODES_HOST}:7250 --nodes-connect-push tcp://${NODES_HOST}:7270
--nodes-connect-app-dealer tcp://${NODES_HOST}:7160 --nodes-connect-dev-dealer tcp://${NODES_HOST}:7260
stf-api-groups-engine:
<<: *stf
container_name: stf-api-groups-engine
healthcheck:
<<: *connections-healthcheck
test: ["CMD", "node", "-e", *connections-script, "7150", "7170", "7250", "7270", "28015"]
command: >-
stf groups-engine
--connect-sub tcp://stf-triproxy-app:7150 --connect-push tcp://stf-triproxy-app:7170
--connect-sub-dev tcp://stf-triproxy-dev:7250 --connect-push-dev tcp://stf-triproxy-dev:7270
volumes:
stf-db-volume:
stf-temp-volume: