-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
701 lines (683 loc) Β· 26.6 KB
/
Copy pathdocker-compose.yml
File metadata and controls
701 lines (683 loc) Β· 26.6 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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# β οΈ 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 down
# docker volume rm teslasync_postgres_data
# docker compose up -d
# Existing data is replaced; staging losses accepted per ADR-009.
services:
teslasync-api:
build:
context: .
dockerfile: Dockerfile
args:
VERSION: ${VERSION:-dev}
container_name: teslasync-api
restart: unless-stopped
ports:
- "${TESLASYNC_PORT:-8080}:8080"
environment:
- TESLASYNC_PORT=8080
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=${POSTGRES_USER:-teslasync}
- DATABASE_PASSWORD=${POSTGRES_PASSWORD:-teslasync}
- DATABASE_NAME=${POSTGRES_DB:-teslasync}
- DATABASE_SSL_MODE=disable
- DATABASE_CONNECT_TIMEOUT=5
- DATABASE_STATEMENT_TIMEOUT=30000
- DATABASE_HEALTH_CHECK_PERIOD=5s
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_ENABLED=true
- TESLA_CLIENT_ID=${TESLA_CLIENT_ID}
- TESLA_CLIENT_SECRET=${TESLA_CLIENT_SECRET}
- TESLA_REDIRECT_URI=${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=${WORKER_POLL_INTERVAL:-30s}
- LOG_LEVEL=${LOG_LEVEL:-error}
- FLEET_TELEMETRY_ENABLED=${FLEET_TELEMETRY_ENABLED:-false}
- FLEET_TELEMETRY_HOST=${FLEET_TELEMETRY_HOST:-}
- FLEET_TELEMETRY_PORT=${FLEET_TELEMETRY_PORT:-4443}
- FLEET_TELEMETRY_TOPIC_BASE=${FLEET_TELEMETRY_TOPIC_BASE:-telemetry}
- FLEET_TELEMETRY_BATCH_MS=${FLEET_TELEMETRY_BATCH_MS:-100}
- FLEET_TELEMETRY_STALE_TIMEOUT=${FLEET_TELEMETRY_STALE_TIMEOUT:-15m}
- FLEET_TELEMETRY_FALLBACK_POLL_INTERVAL=${FLEET_TELEMETRY_FALLBACK_POLL_INTERVAL:-5m}
- FLEET_TELEMETRY_SNAPSHOT_WRITE_INTERVAL=${FLEET_TELEMETRY_SNAPSHOT_WRITE_INTERVAL:-1s}
- LIVE_SIGNAL_STORE_MODE=${LIVE_SIGNAL_STORE_MODE:-hybrid}
- OTEL_ENABLED=${OTEL_ENABLED:-false}
- OTEL_ENDPOINT=${OTEL_ENDPOINT:-otel-collector:4317}
- OTEL_EXPORTER_OTLP_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT:-http://otel-collector:4317}
- OTEL_TRACES_SAMPLER_ARG=${OTEL_TRACES_SAMPLER_ARG:-1.0}
- OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-teslasync-api}
- OTEL_INSECURE=${OTEL_INSECURE:-true}
# Pyroscope continuous profiling β opt-in via PYROSCOPE_ENABLED.
# When enabled the API uploads CPU/heap/goroutine/mutex/block deltas
# to the Pyroscope server every PYROSCOPE_UPLOAD_RATE (default 15s).
# Phase-49 / p49-profiling.
- PYROSCOPE_ENABLED=${PYROSCOPE_ENABLED:-false}
- PYROSCOPE_SERVER_ADDRESS=${PYROSCOPE_SERVER_ADDRESS:-http://pyroscope:4040}
- PYROSCOPE_UPLOAD_RATE=${PYROSCOPE_UPLOAD_RATE:-15s}
# Phase-46 / SOTA observability batch.
# SLO board β empty PROMETHEUS_BASE_URL serves catalog
# metadata only (no live tier evaluation).
- SLO_CATALOG_PATH=${SLO_CATALOG_PATH:-slo/catalog.yaml}
- PROMETHEUS_BASE_URL=${PROMETHEUS_BASE_URL:-}
# Data quality scoring over signal_log.
- DATA_QUALITY_ENABLED=${DATA_QUALITY_ENABLED:-true}
- DATA_QUALITY_WINDOW_MINS=${DATA_QUALITY_WINDOW_MINS:-60}
# Synthetic monitoring (outside-in probes). Opt-in.
- SYNTHETIC_ENABLED=${SYNTHETIC_ENABLED:-false}
- SYNTHETIC_INTERVAL_SECONDS=${SYNTHETIC_INTERVAL_SECONDS:-60}
- SYNTHETIC_TIMEOUT_SECONDS=${SYNTHETIC_TIMEOUT_SECONDS:-30}
- SYNTHETIC_PROBE_URLS=${SYNTHETIC_PROBE_URLS:-}
# Phase-44 / observability-batch / Prompt F4 β DLQ Inspector.
# Replay is opt-in because re-publishing a payload that already
# triggered a production exception is consequential. Replay is
# also gated by sudo-token AND audited on every code path.
- DLQ_REPLAY_ENABLED=${DLQ_REPLAY_ENABLED:-false}
- DLQ_RING_CAPACITY=${DLQ_RING_CAPACITY:-200}
- GOOGLE_MAPS_API_KEY=${GOOGLE_MAPS_API_KEY:-}
- AZURE_MAPS_API_KEY=${AZURE_MAPS_API_KEY:-}
# Inbound api_call_logs middleware (Phase 38-10).
# Body capture defaults to OFF; enable only for diagnostic windows.
- API_LOGS_INBOUND_ENABLED=${API_LOGS_INBOUND_ENABLED:-true}
- API_LOG_CAPTURE_BODIES=${API_LOG_CAPTURE_BODIES:-false}
- API_LOG_QUEUE_CAPACITY=${API_LOG_QUEUE_CAPACITY:-4096}
- API_LOG_BATCH_SIZE=${API_LOG_BATCH_SIZE:-100}
- API_LOG_FLUSH_INTERVAL=${API_LOG_FLUSH_INTERVAL:-1s}
# Audit log retention (Phase-40 / Prompt 49 β Recent Activity Discoverability).
# AUDIT_RETENTION_DAYS: hard delete entries older than N days (0 = never).
# AUDIT_IP_RETENTION_DAYS: redact ip + user_agent on entries older than N days
# so per-user activity stays usable without retaining network PII forever.
- AUDIT_RETENTION_DAYS=${AUDIT_RETENTION_DAYS:-365}
- AUDIT_IP_RETENTION_DAYS=${AUDIT_IP_RETENTION_DAYS:-30}
# Web Push (VAPID) β Phase 40 / Prompt 52.
# Generate keys once with: go run ./cmd/teslasync vapid-keygen
# When unset, the API logs a Warn at startup and the push channel
# is disabled (no behaviour change for existing installs).
- TESLASYNC_VAPID_PUBLIC_KEY=${TESLASYNC_VAPID_PUBLIC_KEY:-}
- TESLASYNC_VAPID_PRIVATE_KEY=${TESLASYNC_VAPID_PRIVATE_KEY:-}
- TESLASYNC_VAPID_SUBJECT=${TESLASYNC_VAPID_SUBJECT:-}
# Service-mode banner override β Phase 46 / Prompt 04.
# When TESLASYNC_SYSTEM_MODE is set ("ok", "degraded",
# "maintenance"), it overrides the system_state DB row so an
# operator can force-set or force-clear the top-of-app banner
# during deploys/rollbacks without touching the database. Leave
# empty to defer to the DB row + admin POST API.
- TESLASYNC_SYSTEM_MODE=${TESLASYNC_SYSTEM_MODE:-}
- TESLASYNC_SYSTEM_MAINTENANCE_MESSAGE=${TESLASYNC_SYSTEM_MAINTENANCE_MESSAGE:-}
- TESLASYNC_SYSTEM_MAINTENANCE_UNTIL=${TESLASYNC_SYSTEM_MAINTENANCE_UNTIL:-}
# Optional GitHub Issues bridge for the in-app feedback widget
# (Phase 46 / Prompt 08). When both REPO ("owner/name") and TOKEN
# (PAT with Issues:write) are set, the admin feedback queue
# exposes a "Forward to GitHub" action that mirrors the user
# report into a real GitHub issue. Leave empty to disable β the
# SPA hides the action when the server reports the bridge as
# unconfigured.
- TESLASYNC_GITHUB_REPO=${TESLASYNC_GITHUB_REPO:-}
- TESLASYNC_GITHUB_TOKEN=${TESLASYNC_GITHUB_TOKEN:-}
# Vehicle photo upload root β Phase 46 / Prompt 54.
# User-uploaded vehicle hero photos are written to this dir
# at runtime (3 sizes per upload). Mount a volume here in
# production so photos survive container restart.
- TESLASYNC_VEHICLE_PHOTO_DIR=${TESLASYNC_VEHICLE_PHOTO_DIR:-/var/lib/teslasync/photos}
# Auth-mode contract β Phase 46 / Prompt 57.
# Free-text hint surfaced verbatim by /system/auth-mode and
# rendered by the SPA's RequiresAuth empty state. Set to the
# name of your upstream IdP (Authentik, Authelia, oauth2-proxy,
# Keycloak, β¦) for nicer copy. TeslaSync NEVER speaks to the
# IdP's admin API and NEVER routes off this value β it is
# presentation-only. Default empty: SPA falls back to a
# generic "your authentication provider" string.
- TESLASYNC_AUTH_PROVIDER_HINT=${TESLASYNC_AUTH_PROVIDER_HINT:-}
# Cookie / GDPR consent banner β Phase 46 / Prompt 70.
# Default OFF: self-hosted single-user installs do not need a
# consent banner. Flip to "true" on multi-user fleet
# deployments or any public-facing instance with optional
# client-side reporting enabled (web vitals, error reporter)
# to comply with ePrivacy / GDPR. When true, the SPA renders
# a non-blocking banner the first visit and gates optional
# POSTs on the user's stored consent.
- TESLASYNC_REQUIRE_COOKIE_CONSENT=${TESLASYNC_REQUIRE_COOKIE_CONSENT:-false}
volumes:
- vehicle_photos:/var/lib/teslasync/photos
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "/usr/local/bin/teslasync", "healthcheck"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
web:
build:
context: .
dockerfile: Dockerfile.web
# Frontend RUM is build-time inlined: Vite reads VITE_* at build to bake
# them into the bundle. Forwarding them as build args means a single
# `docker compose build web` picks up changes to the collector endpoint
# without re-engineering the Dockerfile. The SPA gracefully no-ops when
# VITE_OTLP_HTTP_ENDPOINT is unset (see web/src/observability/rum.ts).
args:
VITE_OTLP_HTTP_ENDPOINT: ${VITE_OTLP_HTTP_ENDPOINT:-}
VITE_OTEL_SERVICE_NAME: ${VITE_OTEL_SERVICE_NAME:-teslasync-web}
VITE_OTEL_DEPLOY_ENV: ${VITE_OTEL_DEPLOY_ENV:-dev-compose}
VITE_APP_VERSION: ${VERSION:-dev}
container_name: teslasync-web
restart: unless-stopped
ports:
- "${WEB_PORT:-3000}:80"
depends_on:
teslasync-api:
condition: service_healthy
deploy:
resources:
limits:
memory: 128M
reservations:
memory: 32M
notification-worker:
build:
context: .
dockerfile: Dockerfile.notification
args:
VERSION: ${VERSION:-dev}
container_name: teslasync-notification-worker
restart: unless-stopped
environment:
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=${POSTGRES_USER:-teslasync}
- DATABASE_PASSWORD=${POSTGRES_PASSWORD:-teslasync}
- DATABASE_NAME=${POSTGRES_DB:-teslasync}
- DATABASE_SSL_MODE=disable
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- LOG_LEVEL=${LOG_LEVEL:-error}
- HEALTH_PORT=8081
- OTEL_ENABLED=${OTEL_ENABLED:-false}
- OTEL_ENDPOINT=${OTEL_ENDPOINT:-otel-collector:4317}
- OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-teslasync-notification-worker}
- OTEL_INSECURE=${OTEL_INSECURE:-true}
- PYROSCOPE_ENABLED=${PYROSCOPE_ENABLED:-false}
- PYROSCOPE_SERVER_ADDRESS=${PYROSCOPE_SERVER_ADDRESS:-http://pyroscope:4040}
- PYROSCOPE_UPLOAD_RATE=${PYROSCOPE_UPLOAD_RATE:-15s}
# Web Push (VAPID) β same env vars as the API server. Required so
# the notification worker can deliver "webpush" Requests pulled
# from the MQTT internal topic.
- TESLASYNC_VAPID_PUBLIC_KEY=${TESLASYNC_VAPID_PUBLIC_KEY:-}
- TESLASYNC_VAPID_PRIVATE_KEY=${TESLASYNC_VAPID_PRIVATE_KEY:-}
- TESLASYNC_VAPID_SUBJECT=${TESLASYNC_VAPID_SUBJECT:-}
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
healthcheck:
test: ["CMD", "/usr/local/bin/notification-worker", "healthcheck"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 128M
reservations:
memory: 32M
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 down
# docker volume rm teslasync_postgres_data
# docker compose up -d
# Existing data is replaced; staging losses accepted per ADR-009.
image: timescale/timescaledb-ha:pg17
container_name: teslasync-postgres
restart: unless-stopped
command: ["postgres", "-c", "max_connections=100", "-c", "shared_buffers=256MB", "-c", "shared_preload_libraries=timescaledb,pg_stat_statements,pg_textsearch", "-c", "pg_stat_statements.track=all"]
ports:
- "${POSTGRES_PORT:-5432}:5432"
environment:
- POSTGRES_USER=${POSTGRES_USER:-teslasync}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-teslasync}
- POSTGRES_DB=${POSTGRES_DB:-teslasync}
- PGDATA=/home/postgres/pgdata/data
volumes:
- 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 ${POSTGRES_USER:-teslasync}"]
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 256M
grafana:
image: grafana/grafana:10.4.0
container_name: teslasync-grafana
restart: unless-stopped
ports:
- "${GRAFANA_PORT:-3001}:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-teslasync}
- GF_INSTALL_PLUGINS=grafana-clock-panel
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_USER=${POSTGRES_USER:-teslasync}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-teslasync}
- POSTGRES_DB=${POSTGRES_DB:-teslasync}
- PROMETHEUS_URL=http://prometheus:9090
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/var/lib/grafana/dashboards
depends_on:
postgres:
condition: service_healthy
prometheus:
condition: service_started
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
prometheus:
image: prom/prometheus:v2.51.0
container_name: teslasync-prometheus
restart: unless-stopped
ports:
- "${PROMETHEUS_PORT:-9099}:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
# SLO recording + alerting rules are generated from slo/catalog.yaml by
# `go run ./cmd/slogen generate {recording,alerting}` and committed under
# helm/teslasync/files/prometheus/. Mounting the same artefacts here keeps
# dev and K8s on identical rule definitions β drift would mean a SLO
# tested in dev does not exist in prod.
- ./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
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=15d'
- '--web.enable-lifecycle'
# exemplar-storage retains the trace_id/span_id labels attached to
# histogram observations by internal/api/middleware.go +
# internal/metrics/exemplar.go so Grafana can render the "View trace"
# dot on RED latency panels. Without this flag the labels are accepted
# at ingest but dropped at query time, hiding the link entirely.
- '--enable-feature=exemplar-storage'
depends_on:
teslasync-api:
condition: service_healthy
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
mosquitto:
image: eclipse-mosquitto:2
container_name: teslasync-mosquitto
restart: unless-stopped
ports:
- "${MQTT_PORT:-1883}:1883"
- "9001:9001"
volumes:
- mosquitto_data:/mosquitto/data
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
healthcheck:
test: ["CMD", "mosquitto_sub", "-t", "$$SYS/#", "-C", "1", "-i", "healthcheck", "-W", "3"]
interval: 30s
timeout: 5s
retries: 3
deploy:
resources:
limits:
memory: 64M
reservations:
memory: 16M
redis:
image: redis:7-alpine
container_name: teslasync-redis
restart: unless-stopped
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes --maxmemory 128mb --maxmemory-policy allkeys-lru
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
deploy:
resources:
limits:
memory: 192M
reservations:
memory: 32M
export-worker:
build:
context: .
dockerfile: Dockerfile.export-worker
args:
VERSION: ${VERSION:-dev}
container_name: teslasync-export-worker
restart: unless-stopped
environment:
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=${POSTGRES_USER:-teslasync}
- DATABASE_PASSWORD=${POSTGRES_PASSWORD:-teslasync}
- DATABASE_NAME=${POSTGRES_DB:-teslasync}
- DATABASE_SSL_MODE=disable
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- LOG_LEVEL=${LOG_LEVEL:-error}
- HEALTH_PORT=8082
- OTEL_ENABLED=${OTEL_ENABLED:-false}
- OTEL_ENDPOINT=${OTEL_ENDPOINT:-otel-collector:4317}
- OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-teslasync-export-worker}
- OTEL_INSECURE=${OTEL_INSECURE:-true}
- PYROSCOPE_ENABLED=${PYROSCOPE_ENABLED:-false}
- PYROSCOPE_SERVER_ADDRESS=${PYROSCOPE_SERVER_ADDRESS:-http://pyroscope:4040}
- PYROSCOPE_UPLOAD_RATE=${PYROSCOPE_UPLOAD_RATE:-15s}
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
healthcheck:
test: ["CMD", "/usr/local/bin/export-worker", "healthcheck"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 64M
automation-worker:
build:
context: .
dockerfile: Dockerfile.automation
args:
VERSION: ${VERSION:-dev}
container_name: teslasync-automation-worker
restart: unless-stopped
environment:
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=${POSTGRES_USER:-teslasync}
- DATABASE_PASSWORD=${POSTGRES_PASSWORD:-teslasync}
- DATABASE_NAME=${POSTGRES_DB:-teslasync}
- DATABASE_SSL_MODE=disable
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- TESLA_CLIENT_ID=${TESLA_CLIENT_ID}
- TESLA_CLIENT_SECRET=${TESLA_CLIENT_SECRET}
- TESLA_API_BASE_URL=${TESLA_API_BASE_URL:-https://fleet-api.prd.na.vn.cloud.tesla.com}
- LOG_LEVEL=${LOG_LEVEL:-error}
- HEALTH_PORT=8083
- OTEL_ENABLED=${OTEL_ENABLED:-false}
- OTEL_ENDPOINT=${OTEL_ENDPOINT:-otel-collector:4317}
- OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-teslasync-automation-worker}
- OTEL_INSECURE=${OTEL_INSECURE:-true}
- PYROSCOPE_ENABLED=${PYROSCOPE_ENABLED:-false}
- PYROSCOPE_SERVER_ADDRESS=${PYROSCOPE_SERVER_ADDRESS:-http://pyroscope:4040}
- PYROSCOPE_UPLOAD_RATE=${PYROSCOPE_UPLOAD_RATE:-15s}
depends_on:
postgres:
condition: service_healthy
mosquitto:
condition: service_started
healthcheck:
test: ["CMD", "/usr/local/bin/automation-worker", "healthcheck"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
# Jaeger (optional β docker compose --profile tracing up)
# Provides distributed tracing via OpenTelemetry (OTLP gRPC).
# Jaeger UI: http://localhost:16686
#
# In the dev compose layout, services emit spans to the otel-collector below
# rather than direct to jaeger, so the collector's batching + tail-sampling
# (when enabled) takes effect even locally. The collector then forwards to
# jaeger:4317 via the otlp/jaeger exporter. Jaeger no longer needs to bind
# 4317 to the host β the host-facing OTLP ingest is owned by otel-collector.
jaeger:
image: jaegertracing/all-in-one:1.57
container_name: teslasync-jaeger
restart: unless-stopped
profiles:
- tracing
ports:
- "${JAEGER_UI_PORT:-16686}:16686"
environment:
- COLLECTOR_OTLP_ENABLED=true
deploy:
resources:
limits:
memory: 256M
# OpenTelemetry Collector (optional β docker compose --profile tracing up)
# Dev variant of helm/teslasync/files/otel-collector/config.yaml β 100%
# sampling (no tail policy), CORS-enabled OTLP HTTP receiver for browser
# RUM, and Jaeger as the trace backend instead of Tempo. See
# observability/otel-collector/config.yaml for the full pipeline and the
# rationale behind each dev-specific divergence.
#
# Ports:
# 4317 - OTLP gRPC (Go services)
# 4318 - OTLP HTTP (browser RUM, with CORS)
# 9464 - Prometheus exposition of collector + forwarded OTLP metrics
# 8888 - Collector's own internal telemetry metrics
otel-collector:
image: otel/opentelemetry-collector-contrib:0.103.1
container_name: teslasync-otel-collector
restart: unless-stopped
profiles:
- tracing
command:
- "--config=/etc/otelcol/config.yaml"
volumes:
- ./observability/otel-collector/config.yaml:/etc/otelcol/config.yaml:ro
ports:
- "${OTEL_COLLECTOR_GRPC_PORT:-4317}:4317"
- "${OTEL_COLLECTOR_HTTP_PORT:-4318}:4318"
- "${OTEL_COLLECTOR_METRICS_PORT:-9464}:9464"
depends_on:
jaeger:
condition: service_started
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
# Pyroscope continuous profiling server (optional β docker compose --profile profiling up)
# Receives godeltaprof uploads from API + 3 workers. Surfaces CPU, heap,
# goroutine, mutex, block profiles in Grafana via the Pyroscope datasource.
# Phase-49 / p49-profiling. See docs/runbooks/phase-49-pyroscope.md.
#
# Ports:
# 4040 - Pyroscope HTTP ingest + UI
pyroscope:
image: grafana/pyroscope:1.7.1
container_name: teslasync-pyroscope
restart: unless-stopped
profiles:
- profiling
ports:
- "${PYROSCOPE_PORT:-4040}:4040"
command:
- "server"
volumes:
- pyroscope_data:/var/lib/pyroscope
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
# Fleet Telemetry Server (optional β docker compose --profile telemetry up)
# Receives streaming data from Tesla vehicles via WebSocket and publishes
# to MQTT (Mosquitto). TeslaSync's MQTT subscriber picks up the signals.
# Requires TLS certificates and Tesla Developer account with Fleet Telemetry access.
# See: https://github.com/teslamotors/fleet-telemetry
fleet-telemetry:
image: tesla/fleet-telemetry:latest
container_name: teslasync-fleet-telemetry
restart: unless-stopped
profiles:
- telemetry
ports:
- "${FLEET_TELEMETRY_PORT:-4443}:4443"
volumes:
- ./fleet-telemetry-config.json:/etc/fleet-telemetry/config.json:ro
- ${FLEET_TELEMETRY_TLS_CERT:-./certs/server.crt}:/certs/server.crt:ro
- ${FLEET_TELEMETRY_TLS_KEY:-./certs/server.key}:/certs/server.key:ro
depends_on:
mosquitto:
condition: service_started
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
# Vehicle Command Proxy (optional β enables signed vehicle commands)
# Routes commands through Tesla's Vehicle Command SDK for end-to-end signing.
# Required for 2021+ Model S/X and all Model 3/Y vehicles.
# Setup: 1) Generate keypair via /dev-tools/generate-keypair
# 2) Save private key to ./certs/private-key.pem
# 3) Register public key with Tesla and pair with vehicle
# 4) Set TESLA_COMMAND_PROXY_URL=https://vehicle-command-proxy:4443 in .env
vehicle-command-proxy:
image: tesla/vehicle-command:latest
container_name: teslasync-vehicle-command-proxy
restart: unless-stopped
profiles:
- commands
environment:
- TESLA_HTTP_PROXY_HOST=0.0.0.0
- TESLA_HTTP_PROXY_PORT=4443
- TESLA_HTTP_PROXY_TLS_CERT=/data/tls-cert.pem
- TESLA_HTTP_PROXY_TLS_KEY=/data/tls-key.pem
- TESLA_KEY_FILE=/data/private-key.pem
- TESLA_VERBOSE=${TESLA_VERBOSE:-false}
volumes:
- ${COMMAND_PROXY_DATA_DIR:-./data/vehicle-command}:/data
healthcheck:
test: ["CMD", "wget", "--no-check-certificate", "-qO-", "https://localhost:4443/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
memory: 128M
reservations:
memory: 32M
# Toxiproxy chaos / fault-injection harness (optional β docker compose --profile chaos up)
# Phase-49 / p49-chaos. Programmable TCP proxy that injects latency,
# drops, and bandwidth limits between TeslaSync and its backing
# services. The cmd/chaos-runner binary drives it via the admin API
# on :8474. See internal/chaos/scenarios.go for the default suite.
#
# NOT used in steady-state operation β operators bring this profile
# up to exercise the recovery contracts of the FSM, signal pipeline,
# and reconciliation loop. The runner removes every injected toxic
# on completion; restart toxiproxy to clear any state if a run is
# killed mid-execution.
#
# Ports:
# 8474 - Toxiproxy HTTP admin API (host-bound for the runner)
toxiproxy:
image: ghcr.io/shopify/toxiproxy:2.9.0
container_name: teslasync-toxiproxy
restart: unless-stopped
profiles:
- chaos
ports:
- "${TOXIPROXY_PORT:-8474}:8474"
command: ["-host=0.0.0.0", "-config=/etc/toxiproxy/config.json"]
volumes:
- ./observability/toxiproxy/config.json:/etc/toxiproxy/config.json:ro
deploy:
resources:
limits:
memory: 64M
reservations:
memory: 16M
# OCPP 1.6-J CSMS (optional β docker compose --profile ocpp up)
# Phase-50 / p50-ocpp. Accepts WebSocket connections from non-Tesla
# chargers (Wallbox, OpenEVSE, EVlink) on the `ocpp1.6` subprotocol
# and routes messages through internal/ocpp.Dispatcher.
#
# Foundation PR uses the in-memory session store; a Postgres-backed
# store can be wired in a follow-up without touching the protocol
# layer.
#
# Ports:
# 9090 - OCPP WebSocket endpoint at /ocpp/<chargePointId> + /healthz
ocpp-server:
build:
context: .
dockerfile: Dockerfile.ocpp-server
container_name: teslasync-ocpp-server
restart: unless-stopped
profiles:
- ocpp
ports:
- "${OCPP_PORT:-9090}:9090"
environment:
- OCPP_LISTEN_ADDR=:9090
- OCPP_HEARTBEAT_INTERVAL=${OCPP_HEARTBEAT_INTERVAL:-300s}
- OCPP_READ_DEADLINE=${OCPP_READ_DEADLINE:-900s}
deploy:
resources:
limits:
memory: 64M
reservations:
memory: 16M
volumes:
postgres_data:
grafana_data:
mosquitto_data:
redis_data:
prometheus_data:
pyroscope_data:
vehicle_photos: