-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdocker-compose.yml
346 lines (317 loc) · 8.77 KB
/
docker-compose.yml
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# Services that run on the single, centralized bmon server instance.
#
# Environment is injected from the .env file, which is generated by
# `./infra/bmon_infra/config.py`.
version: '3.5'
x-service-config: &service
environment: &env
BMON_DEBUG:
BMON_HOSTS_FILE:
BMON_HOSTNAME:
DB_HOST:
DB_PASSWORD:
BITCOIN_RPC_HOST:
BITCOIN_RPC_PASSWORD:
BITCOIN_RPC_PORT:
BITCOIN_RPC_USER:
BITCOIN_GITSHA:
BITCOIN_GITREF:
BITCOIN_VERSION:
BITCOIN_FLAGS:
BITCOIN_PRUNE:
BITCOIN_DBCACHE:
BITCOIND_VERSION_PATH:
PUSHOVER_USER:
PUSHOVER_TOKEN:
BMON_REDIS_SERVER_URL:
BMON_REDIS_HOST:
SENTRY_DSN:
PYTHONUNBUFFERED: 1
x-redis-config: &redis-config
image: docker.io/library/redis
user: "${USER_ID}"
ports:
- 6379:6379
volumes:
- ${ENV_ROOT}/redis/data:/data
# Configure redis for persistence with AOF;
# See https://redis.io/docs/manual/persistence/
command: redis-server ${BMON_REDIS_OPTIONS---appendonly yes --loglevel warning}
services:
# bmon server containers
# -----------------------------------------------
db:
profiles: ["server"]
user: "${USER_ID}"
image: docker.io/library/postgres:14-bullseye
environment:
POSTGRES_DB: bmon
POSTGRES_USER: bmon
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- ${ENV_ROOT}/postgres/data:/var/lib/postgresql/data
- /etc/passwd:/etc/passwd:ro
- ./etc/postgres.conf:/etc/postgresql/postgresql.conf
ports:
- 5432:5432
command: postgres -c 'config_file=/etc/postgresql/postgresql.conf'
redis:
profiles: ["server"]
<<: *redis-config
grafana:
profiles: ["server"]
image: docker.io/grafana/grafana-enterprise:9.4.3
user: "${USER_ID}"
volumes:
- ${ENV_ROOT}/grafana/etc:/etc/grafana
- ${ENV_ROOT}/grafana/var:/var/lib/grafana
links:
- prom
- alertman
# - loki
ports:
- 3000:3000
prom:
profiles: ["server"]
image: docker.io/prom/prometheus:latest
user: "${USER_ID}"
volumes:
- ${ENV_ROOT}/prom/etc:/etc/prometheus
- ${ENV_ROOT}/prom/data:/prometheus
links:
- alertman
ports:
- 9090:9090
alertman:
profiles: ["server"]
image: docker.io/prom/alertmanager:latest
user: "${USER_ID}:1000"
volumes:
- ${ENV_ROOT}/alertman/config.yml:/etc/alertmanager/config.yml
- ${ENV_ROOT}/alertman/data:/alertmanager
command: --config.file=/etc/alertmanager/config.yml --storage.path=/alertmanager
ports:
- 9093:9093
web: &web_config
profiles: ["server"]
user: "${USER_ID}"
build:
context: .
dockerfile: ./docker/py.Dockerfile
image: docker.io/jamesob/bmon:latest
environment:
<<: *env
RUN_DB_MIGRATIONS: 1
WAIT_FOR: "${DB_HOST}:5432"
ports:
- 8080:8080
volumes:
- ./:/src
links:
- db
command: ./manage.py runserver 0.0.0.0:8080
shell:
image: docker.io/jamesob/bmon:latest
profiles: ["ops"]
environment:
<<: *env
WAIT_FOR: "${DB_HOST}:5432"
IPYTHONDIR: /var/lib/ipython
volumes:
- ./:/src
- ${ENV_ROOT}/ipython:/var/lib/ipython
command: ./manage.py shell
server-task-worker:
profiles: ["server"]
user: "${USER_ID}"
image: docker.io/jamesob/bmon:latest
environment:
<<: *env
WAIT_FOR: "${DB_HOST}:5432,${BMON_REDIS_HOST}:6379"
volumes:
- ./:/src
links:
- db
- redis
command: huey_consumer.py bmon.server_tasks.server_q -w 3
server-mempool-task-worker:
profiles: ["server"]
user: "${USER_ID}"
image: docker.io/jamesob/bmon:latest
environment:
<<: *env
WAIT_FOR: "${DB_HOST}:5432,${BMON_REDIS_HOST}:6379"
volumes:
- ./:/src
links:
- db
- redis
command: huey_consumer.py bmon.server_tasks.mempool_q -w 3 -q
server-monitor:
profiles: ["server"]
user: "${USER_ID}"
image: docker.io/jamesob/bmon:latest
environment:
<<: *env
WAIT_FOR: "${BMON_REDIS_HOST}:6379,${DB_HOST}:5432"
BMON_REDIS_URL:
volumes:
- ./:/src
command: bmon-server-monitor
ports:
- 9334:9334
bitcoind-exporter:
profiles: ["bitcoind"]
image: jamesob/bitcoin-prometheus-exporter:latest
environment:
<<: *env
BITCOIN_RPC_HOST:
links:
- bitcoind
ports:
- 9332:9332
# bitcoind node containers
# -----------------------------------------------
bitcoind:
profiles: ["bitcoind"]
image: ${BITCOIN_DOCKER_TAG}
user: "${USER_ID}"
volumes:
- ${ENV_ROOT}/bitcoin/data:/bitcoin/data
command: bitcoind -datadir=/bitcoin/data ${BITCOIN_FLAGS}
ports:
- ${BMON_BITCOIND_PORT:-8332}:8332
- ${BMON_BITCOIND_RPC_PORT:-8333}:8333
redis-bitcoind:
profiles: ["prod-bitcoind"]
<<: *redis-config
bitcoind-task-worker: &bitcoind-worker
profiles: ["bitcoind"]
user: "${USER_ID}"
image: docker.io/jamesob/bmon:latest
# We have to repeat the build section here because the `web` container won't
# build on bitcoind hosts, so we have to have at least one container configured
# to.
build:
context: .
dockerfile: ./docker/py.Dockerfile
environment:
<<: *env
BMON_REDIS_LOCAL_URL:
WAIT_FOR: "${BMON_REDIS_HOST}:6379,${BMON_REDIS_LOCAL_HOST}:6379"
CHAINCODE_GCP_CRED_PATH:
volumes:
- ./:/src
- ${ENV_ROOT}/bmon/mempool-activity-cache:/mempool-activity-cache
- ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro
# Can't have this as a dependency because of local dev.
# links:
# - redis-bitcoind
command: huey_consumer.py bmon.bitcoind_tasks.events_q -w 2
bitcoind-mempool-worker:
<<: *bitcoind-worker
volumes:
- ./:/src
- ${ENV_ROOT}/bmon/mempool-activity-cache:/mempool-activity-cache
- ${ENV_ROOT}/bmon/credentials/chaincode-gcp.json:${CHAINCODE_GCP_CRED_PATH}
- ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro
# Consume mempool activity in its own worker since it's so high volume.
# Tell huey to -q to avoid lots of noise.
command: huey_consumer.py bmon.bitcoind_tasks.mempool_q -w 2 -q
bitcoind-watcher:
profiles: ["bitcoind"]
user: "${USER_ID}"
image: docker.io/jamesob/bmon:latest
environment:
<<: *env
BMON_REDIS_LOCAL_URL:
BMON_BITCOIND_LOG_PATH: /bitcoin-data/debug.log
WAIT_FOR: "${BMON_REDIS_HOST}:6379,${DB_HOST}:5432"
volumes:
- ./:/src
- ${BITCOIN_DATA_PATH}:/bitcoin-data:ro
- ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro
links:
- bitcoind
- bitcoind-task-worker
command: bmon-watch-bitcoind-logs
bitcoind-monitor:
profiles: ["bitcoind"]
user: "${USER_ID}"
image: docker.io/jamesob/bmon:latest
environment:
<<: *env
WAIT_FOR: "${BMON_REDIS_LOCAL_HOST}:6379,${DB_HOST}:5432"
BMON_REDIS_LOCAL_URL:
BMON_BITCOIND_LOG_PATH: /bitcoin-data/debug.log
volumes:
- ./:/src
- ${ENV_ROOT}/bmon/mempool-activity-cache:/mempool-activity-cache
- ${BITCOIN_DATA_PATH}:/bitcoin-data
- ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro
command: bmon-bitcoind-monitor
ports:
- 9333:9333
node-exporter:
# only monitor this stuff in prod since its mountpoint needs are zealous.
profiles: ["prod"]
image: prom/node-exporter:latest
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
ports:
- 9100:9100
# dev containers
# -----------------------------------------------
test:
profiles: ["dev"]
user: "${USER_ID}"
image: docker.io/jamesob/bmon:test-latest
build:
context: .
dockerfile: ./docker/py.Dockerfile
args:
PYTHON_PKG: .[tests]
environment:
<<: *env
DJANGO_SETTINGS_MODULE: bmon.settings_test
WAIT_FOR: "${BMON_REDIS_HOST}:6379,${DB_HOST}:5432"
ports:
- 8080:8080
volumes:
- ./:/src
links:
- db
- bitcoind
- redis
command: ./manage.py runserver 0.0.0.0:8080
js:
profiles: ["dev"]
image: js
user: "${USER_ID}"
build:
context: ./frontend
environment:
<<: *env
volumes:
- ./frontend:/src
- js_node_modules:/node_modules
- ./frontend-build:/build
command: yarn run build
bitcoind-02:
profiles: ["dev"]
image: ${BITCOIN_DOCKER_TAG}
user: "${USER_ID}"
volumes:
- ${ENV_ROOT}/bitcoin-02/data:/bitcoin/data
- ${ENV_ROOT}/bitcoin-02/data/bitcoin.conf:/bitcoin/bitcoin.conf
command: bitcoind -datadir=/bitcoin/data ${BITCOIN_FLAGS}
volumes:
js_node_modules: