-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompose.yaml
More file actions
352 lines (338 loc) · 10.1 KB
/
compose.yaml
File metadata and controls
352 lines (338 loc) · 10.1 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
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
347
348
349
350
351
352
networks:
polymesh:
services:
postgres:
image: postgres:16.1-alpine
networks:
- polymesh
volumes:
- psql-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 10s
timeout: 5s
retries: 5
configs:
- source: psql_extensions
target: /docker-entrypoint-initdb.d/btree_extension.sql
subquery-node:
image: ${POLYMESH_SUBQUERY_IMAGE}
depends_on:
postgres:
condition: service_healthy
polymesh-node:
condition: service_healthy
networks:
- polymesh
restart: on-failure
environment:
DB_USER: postgres
DB_PASS: postgres
DB_DATABASE: postgres
DB_HOST: postgres
DB_PORT: 5432
START_BLOCK: 1
NETWORK_ENDPOINT: ${POLYMESH_CHAIN_WS:-ws://polymesh-node:9944}
NETWORK_HTTP_ENDPOINT: http://polymesh-node:9933
NETWORK_CHAIN_ID: ${CHAIN_ID:-}
NODE_ENV: local
command:
- --batch-size=500
- -f=/app
- --local
healthcheck:
test: ['CMD', 'curl', '--fail', 'http://subquery-node:3000/ready']
interval: 20s
timeout: 5s
retries: 20
start_period: 80s
subquery-graphql:
image: ${POLYMESH_SUBQUERY_GRAPHQL_IMAGE}
depends_on:
subquery-node:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- polymesh
ports:
- ${POLYMESH_SUBQUERY_GRAPHQL_PORT:-3000}:3000
restart: on-failure
environment:
DB_DATABASE: postgres
DB_HOST: postgres
DB_PORT: 5432
DB_USER: postgres
DB_PASS: postgres
PORT: 3000
SUBQL_QUERY_INDEXER: http://subquery-node:3000
SUBQL_QUERY_NAME: public
SUBQL_QUERY_OUTPUT_FMT: json
SUBQL_QUERY_PLAYGROUND: true
SUBQL_QUERY_LOG_LEVEL: debug
healthcheck:
test:
[
'CMD',
'curl',
'--fail',
'subquery-graphql:3000/.well-known/apollo/server-health',
]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
polymesh-node:
image: ${POLYMESH_CHAIN_IMAGE}
networks:
- polymesh
ports:
- ${POLYMESH_CHAIN_WS_PORT:-9944}:9944
- ${POLYMESH_CHAIN_RPC_PORT:-9933}:9933
- ${POLYMESH_CHAIN_P2P_PORT:-30333}:30333
volumes:
- chain-data:/var/lib/polymesh
command:
- --base-path=/var/lib/polymesh
- --unsafe-ws-external
- --unsafe-rpc-external
- --wasm-execution=compiled
- --no-prometheus
- --no-telemetry
- --pruning=archive
- --no-mdns
- --validator
- --rpc-cors=all
- --rpc-methods=unsafe
- --force-authoring
- --port=30333
- --alice
- --chain=dev
configs:
- source: polymesh-healthcheck-libp2p
target: /usr/local/bin/polymesh-healthcheck-libp2p.sh
healthcheck:
test: ['CMD', '/usr/local/bin/polymesh-healthcheck-libp2p.sh']
interval: 10s
timeout: 5s
retries: 10
start_period: 60s
# Polymesh Rest API with Vault Signer
# https://github.com/PolymeshAssociation/polymesh-rest-api#signing-managers
polymesh-rest-api-vault-sm:
image: ${POLYMESH_REST_API_IMAGE}
depends_on:
polymesh-node:
condition: service_healthy
subquery-graphql:
condition: service_healthy
vault-init:
condition: service_completed_successfully
networks:
- polymesh
ports:
- ${POLYMESH_REST_API_VAULT_SM_PORT:-3005}:3000
restart: on-failure
volumes:
- vault-root-token:/vault-token:ro
entrypoint: /bin/sh -c "VAULT_TOKEN=$$(cat /vault-token/.token) node dist/main.js"
environment:
PORT: 3000
POLYMESH_NODE_URL: ${POLYMESH_CHAIN_WS:-ws://polymesh-node:9944}
POLYMESH_MIDDLEWARE_V2_URL: ${REST_MIDDLEWARE_URL:-http://subquery-graphql:3000}
AUTH_STRATEGY: 'open'
DEVELOPER_UTILS: true
VAULT_URL: 'http://vault:8200/v1/transit'
healthcheck:
test:
[
'CMD',
'wget',
'--spider',
'-q',
'http://polymesh-rest-api-vault-sm:3000/network/latest-block',
]
interval: 30s
timeout: 5s
retries: 10
start_period: 30s
polymesh-rest-api-vault-sm-init:
image: alpine:3.19
depends_on:
polymesh-rest-api-vault-sm:
condition: service_healthy
restart: 'no'
entrypoint: /opt/polymesh-rest-api/init.sh
networks:
- polymesh
environment:
PGPASSWORD: postgres
PGUSER: postgres
PGDATABASE: services_status
PGHOST: postgres
volumes:
- rest-api-accounts-init:/opt/polymesh-rest-api/status
configs:
- source: rest-api-accounts-init
target: /opt/polymesh-rest-api/init.sh
# Polymesh Rest API with Local Signers
# https://github.com/PolymeshAssociation/polymesh-rest-api#signing-managers
polymesh-rest-api-local-sm:
image: ${POLYMESH_REST_API_IMAGE}
depends_on:
polymesh-node:
condition: service_healthy
subquery-graphql:
condition: service_healthy
networks:
- polymesh
ports:
- ${POLYMESH_REST_API_LOCAL_SM_PORT:-3004}:3000
restart: on-failure
environment:
PORT: 3000
POLYMESH_NODE_URL: ${POLYMESH_CHAIN_WS:-ws://polymesh-node:9944}
POLYMESH_MIDDLEWARE_V2_URL: ${REST_MIDDLEWARE_URL:-http://subquery-graphql:3000}
LOCAL_SIGNERS: 'alice,bob,charlie'
LOCAL_MNEMONICS: '//Alice,//Bob,//Charlie'
AUTH_STRATEGY: 'open'
DEVELOPER_UTILS: true
healthcheck:
test:
[
'CMD',
'wget',
'--spider',
'-q',
'http://polymesh-rest-api-local-sm:3000/network/latest-block',
]
interval: 30s
timeout: 5s
retries: 10
start_period: 30s
vault:
image: hashicorp/vault:${VAULT_VERSION:-latest}
networks:
- polymesh
restart: unless-stopped
ports:
- ${VAULT_PORT:-8200}:8200
volumes:
- vault-volume:/vault/file:rw
- vault-log-volume:/vault/logs:rw
cap_add:
- IPC_LOCK # Prevents secrets from swapping to disk
configs:
- source: vault-config
target: /vault/config/vault.json
entrypoint: vault server -config=/vault/config/vault.json
# This will make sure vault is initialized and unsealed on the first run and unsealed on subsequent runs
vault-init:
image: hashicorp/vault:${VAULT_VERSION:-latest}
networks:
- polymesh
restart: 'no'
depends_on:
vault:
condition: service_started
volumes:
- vault-root-token:/vault-token:rw
# This will prevent the container from creating additional volumes
tmpfs:
- /vault/file
- /vault/logs
environment:
VAULT_ADDR: 'http://vault:8200'
PGPASSWORD: postgres
PGUSER: postgres
PGDATABASE: services_status
PGHOST: postgres
configs:
- source: vault-init
target: /opt/vault/init.sh
- source: vault-init-dependencies
target: /opt/vault/init-dependencies.sh
entrypoint: /opt/vault/init-dependencies.sh
environment-ready:
image: alpine:latest
volumes:
- rest-api-accounts-init:/status:ro
command: >
sh -c '
start_time=$$(date +%s)
if [ -f /status/.setup-complete ]; then
echo "************************************************************************************"
echo "*** Environment previously initialized and is ready! *******************************"
echo "************************************************************************************"
exit 0
else
echo "************************************************************************************"
echo "Environment starting... Waiting for initialization script to complete. *************"
echo "Usually it takes less than 3 minutes to complete first time. *************"
echo "************************************************************************************"
sleep 10
while [ ! -f /status/.setup-complete ]; do
current_time=$$(date +%s)
elapsed_time=$$((current_time - start_time))
echo "Still waiting for initialization... (Elapsed: $$elapsed_time s)"
sleep 10
done
end_time=$$(date +%s)
total_duration=$$((end_time - start_time))
echo "************************************************************************************"
echo "*** Polymesh Environment Ready! (Total initialization time: $$total_duration s) ***"
echo "************************************************************************************"
exit 0
fi
'
restart: 'no'
networks:
- polymesh
configs:
psql_extensions:
external: false
file: ./scripts/psql_extensions.sql
polymesh-healthcheck-libp2p:
external: false
file: ./scripts/polymesh-healthcheck-libp2p.sh
vault-config:
external: false
file: ./scripts/vault-config.json
vault-init:
external: false
file: ./scripts/vault-init.sh
vault-init-dependencies:
external: false
file: ./scripts/vault-init-dependencies.sh
rest-api-accounts-init:
external: false
file: ./scripts/rest-api-accounts-init.sh
volumes:
psql-data:
labels:
- 'network.polymesh.project=polymesh'
- 'network.polymesh.description=Indexer PostgreSQL data'
chain-data:
labels:
- 'network.polymesh.project=polymesh'
- 'network.polymesh.description=Polymesh chain data'
vault-volume:
labels:
- 'network.polymesh.project=polymesh'
- 'network.polymesh.description=Hashicorp Vault data'
vault-log-volume:
labels:
- 'network.polymesh.project=polymesh'
- 'network.polymesh.description=Hashicorp Vault logs'
vault-root-token:
labels:
- 'network.polymesh.project=polymesh'
- 'network.polymesh.description=Hashicorp Vault root token'
rest-api-accounts-init:
labels:
- 'network.polymesh.project=polymesh'
- 'network.polymesh.description=REST API signer init'