-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
384 lines (368 loc) Β· 12.1 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
384 lines (368 loc) Β· 12.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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# docker-compose.dev.yml β Development stack with ALL components enabled.
# Usage: docker compose -f docker-compose.dev.yml up --build
#
# Includes: API, Web (Nginx), Notification Worker, Export Worker, Automation Worker,
# PostgreSQL, Redis, Mosquitto, Grafana, Tempo + Jaeger (tracing).
# All tracing and telemetry features are enabled by default.
#
# β οΈ TimescaleDB-HA migration (ADR-007):
# This compose file was migrated to timescale/timescaledb-ha:pg17.
# If upgrading from a postgres:17-alpine deployment, you MUST wipe the volume:
# docker compose -f docker-compose.dev.yml down
# docker volume rm teslasync_dev_postgres_data
# docker compose -f docker-compose.dev.yml up -d
# Existing data is replaced; staging losses accepted per ADR-009.
services:
teslasync-api:
build:
context: .
dockerfile: Dockerfile
args:
VERSION: dev
container_name: teslasync-api-dev
restart: unless-stopped
ports:
- "8080:8080"
environment:
- TESLASYNC_PORT=8080
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=teslasync
- DATABASE_PASS=teslasync
- DATABASE_NAME=teslasync
- DATABASE_SSLMODE=disable
- DATABASE_MAX_CONNS=12
- DATABASE_MIN_CONNS=2
- DATABASE_HEALTH_CHECK_PERIOD=30s
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- REDIS_HOST=redis
- REDIS_PORT=6379
- TESLA_CLIENT_ID=${TESLA_CLIENT_ID:-dev-client-id}
- TESLA_CLIENT_SECRET=${TESLA_CLIENT_SECRET:-dev-client-secret}
- TESLA_REDIRECT_URI=http://localhost:8080/api/v1/auth/callback
- TESLA_API_BASE_URL=${TESLA_API_BASE_URL:-https://fleet-api.prd.na.vn.cloud.tesla.com}
- WORKER_POLL_INTERVAL=30s
- TESLASYNC_LOG_LEVEL=error
- FLEET_TELEMETRY_ENABLED=${FLEET_TELEMETRY_ENABLED:-false}
- FLEET_TELEMETRY_HOST=${FLEET_TELEMETRY_HOST:-}
- FLEET_TELEMETRY_PORT=4443
- FLEET_TELEMETRY_TOPIC_BASE=telemetry
- FLEET_TELEMETRY_BATCH_MS=100
- FLEET_TELEMETRY_BATCH_MAX_MESSAGES=256
- FLEET_TELEMETRY_PERSISTENCE_CONCURRENCY=2
- FLEET_TELEMETRY_PERSISTENCE_QUEUE_CAPACITY=64
- FLEET_TELEMETRY_PERSISTENCE_TIMEOUT=30s
- FLEET_TELEMETRY_STALE_TIMEOUT=15m
- FLEET_TELEMETRY_FALLBACK_POLL_INTERVAL=5m
- FLEET_TELEMETRY_SNAPSHOT_WRITE_INTERVAL=10s
- FLEET_TELEMETRY_CLEANUP_INTERVAL=2m
- FLEET_TELEMETRY_STALE_SESSION_TIMEOUT=5m
# Tracing enabled by default in dev
- OTEL_ENABLED=true
- OTEL_ENDPOINT=otel-collector:4317
- OTEL_SERVICE_NAME=teslasync-api
- OTEL_INSECURE=true
- GOOGLE_MAPS_API_KEY=${GOOGLE_MAPS_API_KEY:-}
- AZURE_MAPS_API_KEY=${AZURE_MAPS_API_KEY:-}
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
redis:
condition: service_healthy
otel-collector:
condition: service_started
healthcheck:
test: ["CMD", "/usr/local/bin/teslasync", "healthcheck"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
web:
build:
context: .
dockerfile: Dockerfile.web
container_name: teslasync-web-dev
restart: unless-stopped
ports:
- "3000:80"
depends_on:
teslasync-api:
condition: service_healthy
notification-worker:
build:
context: .
dockerfile: Dockerfile.notification
args:
VERSION: dev
container_name: teslasync-notification-worker-dev
restart: unless-stopped
environment:
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=teslasync
- DATABASE_PASS=teslasync
- DATABASE_NAME=teslasync
- DATABASE_SSLMODE=disable
- DATABASE_MAX_CONNS=2
- DATABASE_MIN_CONNS=1
- DATABASE_HEALTH_CHECK_PERIOD=30s
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- TESLASYNC_LOG_LEVEL=error
- HEALTH_PORT=8081
- OTEL_ENABLED=true
- OTEL_ENDPOINT=otel-collector:4317
- OTEL_SERVICE_NAME=teslasync-notification-worker
- OTEL_INSECURE=true
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
otel-collector:
condition: service_started
healthcheck:
test: ["CMD", "/usr/local/bin/notification-worker", "healthcheck"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
export-worker:
build:
context: .
dockerfile: Dockerfile.export-worker
args:
VERSION: dev
container_name: teslasync-export-worker-dev
restart: unless-stopped
environment:
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=teslasync
- DATABASE_PASS=teslasync
- DATABASE_NAME=teslasync
- DATABASE_SSLMODE=disable
- DATABASE_MAX_CONNS=2
- DATABASE_MIN_CONNS=1
- DATABASE_HEALTH_CHECK_PERIOD=30s
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- TESLASYNC_LOG_LEVEL=error
- HEALTH_PORT=8082
- OTEL_ENABLED=true
- OTEL_ENDPOINT=otel-collector:4317
- OTEL_SERVICE_NAME=teslasync-export-worker
- OTEL_INSECURE=true
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
otel-collector:
condition: service_started
healthcheck:
test: ["CMD", "/usr/local/bin/export-worker", "healthcheck"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
automation-worker:
build:
context: .
dockerfile: Dockerfile.automation
args:
VERSION: dev
container_name: teslasync-automation-worker-dev
restart: unless-stopped
environment:
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=teslasync
- DATABASE_PASS=teslasync
- DATABASE_NAME=teslasync
- DATABASE_SSLMODE=disable
- DATABASE_MAX_CONNS=2
- DATABASE_MIN_CONNS=1
- DATABASE_HEALTH_CHECK_PERIOD=30s
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- TESLA_CLIENT_ID=${TESLA_CLIENT_ID:-dev-client-id}
- TESLA_CLIENT_SECRET=${TESLA_CLIENT_SECRET:-dev-client-secret}
- TESLA_API_BASE_URL=${TESLA_API_BASE_URL:-https://fleet-api.prd.na.vn.cloud.tesla.com}
- TESLASYNC_LOG_LEVEL=error
- HEALTH_PORT=8083
- OTEL_ENABLED=true
- OTEL_ENDPOINT=otel-collector:4317
- OTEL_SERVICE_NAME=teslasync-automation-worker
- OTEL_INSECURE=true
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
otel-collector:
condition: service_started
healthcheck:
test: ["CMD", "/usr/local/bin/automation-worker", "healthcheck"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
# ββ Infrastructure ββββββββββββββββββββββββββββββββββββββββ
postgres:
# β οΈ TimescaleDB-HA migration (ADR-007):
# Migrated from postgres:17-alpine to timescale/timescaledb-ha:pg17.
# If upgrading an existing deployment, you MUST wipe the volume:
# docker compose -f docker-compose.dev.yml down
# docker volume rm teslasync_dev_postgres_data
# docker compose -f docker-compose.dev.yml up -d
# Existing data is replaced; staging losses accepted per ADR-009.
image: timescale/timescaledb-ha:pg17
container_name: teslasync-postgres-dev
restart: unless-stopped
command: ["postgres", "-c", "max_connections=50", "-c", "shared_buffers=128MB", "-c", "effective_cache_size=512MB", "-c", "maintenance_work_mem=64MB", "-c", "shared_preload_libraries=timescaledb,pg_stat_statements,pg_textsearch", "-c", "pg_stat_statements.track=all"]
ports:
- "5432:5432"
environment:
- POSTGRES_USER=teslasync
- POSTGRES_PASSWORD=teslasync
- POSTGRES_DB=teslasync
- PGDATA=/home/postgres/pgdata/data
volumes:
- dev_postgres_data:/home/postgres/pgdata
- ./scripts/init-timescaledb.sql:/docker-entrypoint-initdb.d/00-init-timescaledb.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U teslasync"]
interval: 5s
timeout: 3s
retries: 5
redis:
image: redis:7-alpine
container_name: teslasync-redis-dev
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- dev_redis_data:/data
command: redis-server --appendonly yes --maxmemory 128mb --maxmemory-policy noeviction
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
mosquitto:
image: eclipse-mosquitto:2
container_name: teslasync-mosquitto-dev
restart: unless-stopped
ports:
- "1883:1883"
- "9001:9001"
volumes:
- dev_mosquitto_data:/mosquitto/data
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
healthcheck:
test: ["CMD", "mosquitto_sub", "-t", "$$SYS/#", "-C", "1", "-i", "healthcheck", "-W", "3"]
interval: 15s
timeout: 5s
retries: 3
grafana:
image: grafana/grafana:10.4.0
container_name: teslasync-grafana-dev
restart: unless-stopped
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=teslasync
- GF_INSTALL_PLUGINS=grafana-clock-panel
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_USER=teslasync
- POSTGRES_PASSWORD=teslasync
- POSTGRES_DB=teslasync
- PROMETHEUS_URL=http://prometheus:9090
volumes:
- dev_grafana_data:/var/lib/grafana
- ./grafana/custom.ini:/etc/grafana/grafana.ini:ro
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./grafana/dashboards:/var/lib/grafana/dashboards
depends_on:
postgres:
condition: service_healthy
prometheus:
condition: service_started
prometheus:
image: prom/prometheus:v2.51.0
container_name: teslasync-prometheus-dev
restart: unless-stopped
ports:
- "9099:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./helm/teslasync/files/prometheus/recording-rules.yaml:/etc/prometheus/rules/recording-rules.yaml:ro
- ./helm/teslasync/files/prometheus/alerting-rules.yaml:/etc/prometheus/rules/alerting-rules.yaml:ro
- dev_prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=15d'
- '--web.enable-remote-write-receiver'
- '--enable-feature=exemplar-storage'
# ββ Observability βββββββββββββββββββββββββββββββββββββββββ
jaeger:
image: jaegertracing/all-in-one:1.57
container_name: teslasync-jaeger-dev
restart: unless-stopped
ports:
- "16686:16686" # Jaeger UI
environment:
- COLLECTOR_OTLP_ENABLED=true
deploy:
resources:
limits:
memory: 256M
tempo:
image: grafana/tempo:2.7.0
container_name: teslasync-tempo-dev
restart: unless-stopped
command:
- "-config.file=/etc/tempo/config.yaml"
ports:
- "3200:3200"
volumes:
- ./observability/tempo/config.yaml:/etc/tempo/config.yaml:ro
- dev_tempo_data:/var/tempo
depends_on:
prometheus:
condition: service_started
otel-collector:
image: otel/opentelemetry-collector-contrib:0.103.1
container_name: teslasync-otel-collector-dev
restart: unless-stopped
command:
- "--config=/etc/otelcol/config.yaml"
volumes:
- ./observability/otel-collector/config.yaml:/etc/otelcol/config.yaml:ro
ports:
- "4317:4317"
- "4318:4318"
- "9464:9464"
depends_on:
jaeger:
condition: service_started
tempo:
condition: service_started
deploy:
resources:
limits:
memory: 256M
volumes:
dev_postgres_data:
dev_redis_data:
dev_mosquitto_data:
dev_grafana_data:
dev_prometheus_data:
dev_tempo_data: