-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.base.yml
202 lines (185 loc) · 6.67 KB
/
docker-compose.base.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
version: "3.8"
services:
# Reverse proxy
traefik:
image: "traefik:v2.10.5"
restart: unless-stopped
# Static configuration of Traefik
environment:
# General configuration
- TRAEFIK_LOG_LEVEL=${PONTOS_TRAEFIK_LOG_LEVEL:-ERROR}
- TRAEFIK_ACCESSLOG=true
- TRAEFIK_API_DASHBOARD=true
- TRAEFIK_PROVIDERS_DOCKER=true
- TRAEFIK_PROVIDERS_DOCKER_CONSTRAINTS=Label(`pontos.expose`, `true`)
# Entrypoints
- TRAEFIK_ENTRYPOINTS_web_ADDRESS=:80
- TRAEFIK_ENTRYPOINTS_traefik-dashboard_ADDRESS=:8080
- TRAEFIK_ENTRYPOINTS_emqx-dashboard_ADDRESS=:8081
# Dynamic configuration for exposing Traefik's dashboard an api on separate endpoints
labels:
- "pontos.expose=true"
- "traefik.http.routers.traefik-dashboard.rule=(PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
- "traefik.http.routers.traefik-dashboard.entryPoints=traefik-dashboard"
- "traefik.http.routers.traefik-dashboard.service=api@internal"
ports:
- "${PONTOS_HUB_HTTP_PORT:-80}:80"
- "${PONTOS_TRAEFIK_DASHBOARD_PORT:-8080}:8080"
- "${PONTOS_EMQX_DASHBOARD_PORT:-8081}:8081"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# MQTT broker
emqx:
image: emqx/emqx:5.3.0
restart: unless-stopped
environment:
- EMQX_NAME=pontos-hub
- EMQX_HOST=127.0.0.1
# Do NOT allow for subscribers to upgrade QoS
- EMQX_MQTT__UPGRADE_QOS=false
# Rate limit the number of published messages per client on the ws listener
- EMQX_LISTENERS__WS__DEFAULT__MESSAGES_RATE="2000/s"
# Lets disable the force_shutdown feature to avoid kicking out publishers with a high burst rate of messages
- EMQX_FORCE_SHUTDOWN__ENABLE=false
# Avoid queuing QoS0 messages
- EMQX_MQTT__MQUEUE_STORE_QOS0=false
# Configure logging
- EMQX_LOG__CONSOLE_HANDLER__ENABLE=true
- EMQX_LOG__CONSOLE_HANDLER__LEVEL=${PONTOS_EMQX_LOG_LEVEL:-warning}
labels:
- "pontos.expose=true"
- "traefik.http.routers.emqx-ws.rule=PathPrefix(`/mqtt`)"
- "traefik.http.routers.emqx-ws.entryPoints=web"
- "traefik.http.routers.emqx-ws.service=emqx-ws-service"
- "traefik.http.services.emqx-ws-service.loadbalancer.server.port=8083"
- "traefik.tcp.routers.emqx-dashboard.rule=HostSNI(`*`)"
- "traefik.tcp.routers.emqx-dashboard.entryPoints=emqx-dashboard"
- "traefik.tcp.routers.emqx-dashboard.service=emqx-dashboard-service"
- "traefik.tcp.services.emqx-dashboard-service.loadbalancer.server.port=18083"
volumes:
- vol-emqx-data:/opt/emqx/data
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# Database
db:
image: timescale/timescaledb:2.11.0-pg15
restart: unless-stopped
environment:
POSTGRES_DB: pontos
POSTGRES_USER: pontos_user
POSTGRES_PASSWORD: ${PONTOS_DB_PASSWORD}
volumes:
# Data volume
- vol-pg-data:/var/lib/postgresql/data
# Custom entrypoint
- ./database/custom-entrypoint.sh:/usr/local/bin/custom-entrypoint.sh
# Initialization scripts (run on first start)
- ./database/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
# Initialization scripts (run on every start!)
- ./database/always-initdb.d/:/always-initdb.d/
ports:
- "5432:5432"
entrypoint: "custom-entrypoint.sh"
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# REST api
api:
image: postgrest/postgrest:v11.2.2
restart: unless-stopped
environment:
- PGRST_DB_URI=postgres://authenticator:${PONTOS_DB_PASSWORD}@db:5432/pontos
- PGRST_OPENAPI_SERVER_PROXY_URI=http://localhost/api
- PGRST_DB_SCHEMAS=api_views
- PGRST_DB_ANON_ROLE=web_user # Has read permissions!
- PGRST_DB_MAX_ROWS=1000000 # Limiting the maximum number of rows for a single query to 1M
depends_on:
- db
labels:
- "pontos.expose=true"
- "traefik.http.routers.postgrest.rule=PathPrefix(`/api`)"
- "traefik.http.routers.postgrest.entryPoints=web"
- "traefik.http.routers.postgrest.service=postgrest-service"
- "traefik.http.services.postgrest-service.loadbalancer.server.port=3000"
- "traefik.http.middlewares.postgrest-stripprefix.stripprefix.prefixes=/api"
- "traefik.http.middlewares.postgrest-ratelimit.ratelimit.average=1"
- "traefik.http.middlewares.postgrest-ratelimit.ratelimit.period=10s"
- "traefik.http.routers.postgrest.middlewares=postgrest-stripprefix@docker"
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# Swagger api docs
swagger:
image: swaggerapi/swagger-ui:v5.9.1
restart: unless-stopped
environment:
- API_URL=/api
- BASE_URL=/api/docs
depends_on:
- api
labels:
- "pontos.expose=true"
- "traefik.http.routers.swagger.rule=PathPrefix(`/api/docs`)"
- "traefik.http.routers.swagger.entryPoints=web"
- "traefik.http.routers.swagger.service=swagger-service"
- "traefik.http.services.swagger-service.loadbalancer.server.port=8080"
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
# Data ingestor
ingestor:
image: ghcr.io/mo-rise/pontos-data-ingestor:v0.2.2
restart: unless-stopped
environment:
- MQTT_BROKER_HOST=emqx
- MQTT_BROKER_PORT=1883
- MQTT_USER=__internal__
- MQTT_CLIENT_ID=
- MQTT_CLEAN_START=True
- MQTT_SUBSCRIBE_TOPIC=$$share/ingestors/PONTOS_INGRESS/+/+/+
- MQTT_SUBSCRIBE_TOPIC_QOS=0
- TOPIC_PARSER_FORMAT=PONTOS_INGRESS/{vessel_id:w}/{tag:w}/{index:d}
- PAYLOAD_MAP_FORMAT=timestamp=timestamp,value=value
- PG_CONNECTION_STRING=postgres://pontos_user:${PONTOS_DB_PASSWORD}@db:5432/pontos
- PG_TABLE_NAME=vessel_data.master
- PG_POOL_SIZE=3
- PARTITION_SIZE=5000
- PARTITION_TIMEOUT=5
depends_on:
- emqx
- db
deploy:
mode: replicated
replicas: 3
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
mqtt-editor:
image: ghcr.io/mo-rise/porla-mqtt:v0.2.1
restart: unless-stopped
depends_on:
- emqx
command: [
"mqtt --host emqx --port 1883 --user __internal__ subscribe -t '$$share/filterers/PONTOS_INGRESS/+/+/+' --line '{topic} {message}'
| sed -u '/^$/d' | sed -u 's/PONTOS_INGRESS/PONTOS_EGRESS/'
| mqtt --host emqx --port 1883 --user __internal__ publish --line '{topic} {message}'",
]
volumes:
vol-emqx-data:
vol-pg-data: