-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
281 lines (265 loc) · 8.49 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
version: '3.9'
secrets:
pgpassfile:
file: ${PGPASSFILE:-$HOME/.pgpass}
services:
# compile source code for linux builds, and build python wheels from compiled binary extensions.
# the wheel files output to ./target/wheels/ can then be installed with pip.
# e.g.
# $ docker-compose run --build build-wheels
build-wheels:
image: meridiancfi/aisdb-manylinux:latest
container_name: aisdb-manylinux
build:
context: .
dockerfile: ./docker/python_build.Dockerfile
target: aisdb-manylinux
volumes:
- ./:/aisdb_src/
# reference version based on python:slim with aisdb installed
aisdb-python:
image: meridiancfi/aisdb:latest
build:
target: aisdb-python
context: .
dockerfile: ./docker/python_build.Dockerfile
container_name: aisdb-python
rest-api:
build:
target: aisdb-python
context: .
dockerfile: ./docker/python_build.Dockerfile
environment:
AISDB_REST_DBHOST: ${AISDB_REST_DBHOST:-fc00::17}
AISDB_REST_DBPORT: ${AISDB_REST_DBPORT:-5431}
AISDB_REST_DBUSER: ${AISDB_REST_DBUSER:-postgres}
AISDB_REST_DBPASSWORD: ${AISDB_REST_DBPASSWORD:-devel}
PYTHONUNBUFFERED: TRUE
working_dir: /aisdb_src
container_name: rest-api
stop_grace_period: 1m
command:
["gunicorn", "--chdir=/aisdb_src", "aisdb.rest_api:app", "--workers=8", "--threads=1", "--bind=[::]:5000", "--timeout=1800"]
networks:
ipv6_private:
ipv6_address: "fc00::15"
depends_on:
- postgresdb
- nginx
# run python tests using aisdb-python
python-test:
build:
target: aisdb-python
context: .
dockerfile: ./docker/python_build.Dockerfile
working_dir: /aisdb_src
container_name: python-test
init: true
stop_grace_period: 30s
environment:
- RUST_BACKTRACE=1
- AISDBDATADIR=/aisdb_src/ais/
#- AISDBMARINETRAFFIC=/aisdb_src/testdata/marinetraffic_test.db
#- AISDBTESTDIR=/aisdb_src/testdata/
- PYTHONUNBUFFERED=1
volumes:
- ${AISDBDATADIR:-$HOME/ais}:/aisdb_src/ais/
- /tmp/aisdb-python-test:/tmp
#- ${AISDBTESTDIR:-./testdata}:/aisdb_src/testdata/
#- ./docs/dist_coverage:/aisdb_src/docs/dist_coverage
networks:
ipv6_private:
ipv6_address: "fc00::10"
command:
["python", "-m", "pytest", "--durations=10", "--doctest-modules", "--pyargs", "aisdb", "-k", "not marinetraffic" ]
depends_on:
- python-test-postgresdb
python-test-postgresdb:
container_name: python-test-postgresdb
image: postgres:latest
environment:
POSTGRES_PASSWORD: devel
hostname: python-test-postgresdb
networks:
ipv6_private:
ipv6_address: "fc00::17"
command:
["postgres", "-c", "port=5431", "-c", "max_wal_size=32GB", "-c", "max_stack_depth=7000", "-c", "wal_writer_flush_after=2GB", "-c", "work_mem=1GB", "-c", "autovacuum=0"]
# webapp
# connects to database server on $AISDBHOST:$AISDBPORT
# starts a nodejs webserver on port 8080
webserver:
container_name: webserver
image: meridiancfi/aisdb-web-interface:latest
build:
context: .
dockerfile: ./docker/webserver.Dockerfile
target: webserver
environment:
VITE_AISDBHOST: ${VITE_AISDBHOST:-127.0.0.1}
VITE_AISDBPORT: ${VITE_AISDBPORT:-9924}
VITE_BINGMAPTILES:
VITE_DISABLE_SSL_DB:
VITE_DISABLE_SSL_STREAM:
VITE_NO_DB_LIMIT:
VITE_TILESERVER: ${VITE_TILESERVER:-/}
networks:
ipv6_private:
ipv6_address: "fc00::3"
# nodejs docs server
docserver:
container_name: docserver
volumes:
- ./docs/dist_coverage:/docs/dist_coverage/:ro
init: true
build:
context: .
dockerfile: ./docker/python_build.Dockerfile
target: docserver
networks:
ipv6_private:
ipv6_address: "fc00::4"
# database server
db-server:
container_name: db-server
build:
context: .
dockerfile: ./docker/database_server.Dockerfile
init: true
secrets:
- pgpassfile
environment:
PGPASSFILE: /run/secrets/pgpassfile
PGUSER: ${PGUSER:-postgres}
PGHOST: ${PGHOST:-[fc00::9]}
PGPORT: ${PGPORT:-5432}
AISDBHOSTALLOW: ${AISDBHOSTALLOW:-[::]}
AISDBPORT: ${AISDBPORT:-9924}
RUST_BACKTRACE: 1
networks:
ipv6_private:
ipv6_address: "fc00::6"
depends_on:
- postgresdb
# proxy router
nginx:
image: nginx:latest
container_name: nginx
environment:
VITE_AISDBHOST: ${VITE_AISDBHOST:-127.0.0.1}
VITE_AISDBPORT: ${VITE_AISDBPORT:-9924}
VITE_BINGMAPSKEY: ${VITE_BINGMAPSKEY:-""}
VITE_TILESERVER: ${VITE_TILESERVER:-}
NGINX_CSP_FRAME_ANCESTORS: ${NGINX_CSP_FRAME_ANCESTORS:-}
ports:
- "80:80"
- "443:443"
- "9919:9919/udp"
- "9920:9920"
- "9921:9921/udp"
#- "9922:9922"
- "9923:9923/udp"
#- "9924:9924"
#- "5432:5432"
networks:
ipv6_private:
ipv6_address: "fc00::2"
volumes:
- ${HOME}/www/aisdb_cache:/var/www/cache
- ./docker/nginx.conf:/etc/nginx/templates/nginx.conf.template:ro
- ./docker/tileserver_proxy.conf:/etc/nginx/tileserver_proxy.conf:ro
# add something like the following to docker-compose.override.yml for SSL
# - ~/cert/conf:/etc/letsencrypt
init: true
command:
["/bin/sh" , "-c" , "envsubst '$${VITE_AISDBHOST} $${VITE_AISDBPORT} $${VITE_BINGMAPSKEY} $${VITE_TILESERVER} $${NGINX_CSP_FRAME_ANCESTORS}' < /etc/nginx/templates/nginx.conf.template > /etc/nginx/nginx.conf && while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g 'daemon off;' -c /etc/nginx/nginx.conf"]
# https://eff-certbot.readthedocs.io/en/stable/using.html#where-are-my-certificates
certbot:
image: certbot/certbot
container_name: certbot
# add something like the following to docker-compose.override.yml for SSL
#volumes:
# - ~/cert/conf:/etc/letsencrypt
networks:
ipv6_private:
ipv6_address: "fc00::5"
environment:
AISDBHOST: "aisdb.meridian.cs.dal.ca"
#entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot certonly --webroot -w /var/www/certbot -d $AISDBHOST -n; sleep 12h & wait $${!}; done;'"
#depends_on:
# - nginx
receiver:
container_name: receiver
init: true
#restart: always
build:
context: .
dockerfile: ./docker/receiver.Dockerfile
volumes:
- ${AISDBPATH:-./AIS.sqlitedb}:/ais_rx.db
networks:
ipv6_private:
ipv6_address: "fc00::7"
environment:
#POSTGRES_PASSWORD: $POSTGRES_PASSWORD
- PGPASS:$POSTGRES_PASSWORD
command:
["aisdb-receiver",
"--path", "/ais_rx.db",
"--postgres-connect", "postgresql://postgres:$POSTGRES_PASSWORD@[fc00::9]:5432",
#"--tcp-connect-addr='aisdb.meridian.cs.dal.ca:9920'",
#"--tcp-listen-addr='[::]:9922'",
#"--tcp-listen-addr='[::]:9920'",
"--udp-listen-addr='[::]:9921'",
"--tcp-output-addr='[::]:9922'",
"--multicast-addr-rawdata='[ff02::1]:9916'",
"--multicast-addr-parsed='[ff02::1]:9917'"
#,"--tee"
]
depends_on:
- postgresdb
# forward receiver to downstream
upstream-ais:
container_name: upstream-ais
init: true
build:
context: .
dockerfile: ./docker/dispatcher.Dockerfile
environment:
RUST_BACKTRACE: 1
networks:
ipv6_private:
ipv6_address: "fc00::8"
command:
["mproxy-reverse",
#"--tcp-output-addr", "[::]:9920",
#"--tcp-listen-addr", "[::]:9920",
"--tcp-output-addr", "[::]:9920",
"--multicast-addr", "[ff02::1]:9916"
#"--udp-output-addr", "[::]:9923"
]
# https://github.com/docker-library/docs/blob/master/postgres/README.md
postgresdb:
container_name: postgresdb
image: postgres
restart: on-failure
shm_size: 8g
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-}
networks:
ipv6_private:
ipv6_address: "fc00::9"
volumes:
- ${POSTGRES_VOLUME_DIR:-postgres_data}:/var/lib/postgresql/data
stop_grace_period: 10m
command:
["postgres", "-c", "max_wal_size=32GB", "-c", "max_stack_depth=7000", "-c", "wal_writer_flush_after=2GB", "-c", "work_mem=1GB"]
networks:
ipv6_private:
name: ipv6_private
enable_ipv6: true
ipam:
config:
- subnet: "fc00:0:0::/120"
gateway: "fc00:0:0::1"