-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
95 lines (89 loc) · 3.5 KB
/
Copy pathdocker-compose.yml
File metadata and controls
95 lines (89 loc) · 3.5 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
name: aimeter
# AI-Meter — Option C (event-driven) stack. Everything runs in containers.
# db : TimescaleDB (Postgres + time-series) — the columnar/time-series store + rollups
# redis : Redis Streams — the event queue between ingest and enrichment
# api : FastAPI — ingest endpoint (-> stream) + read endpoints (<- db)
# worker : async consumer — reads the stream, computes impact, writes the db
#
# The stream is the ONLY path into the database: api publishes, worker persists.
services:
db:
build: ./db
command: ["postgres", "-c", "shared_preload_libraries=timescaledb"]
restart: unless-stopped
environment:
POSTGRES_USER: ${AIMETER_DB_USER:-aimeter}
POSTGRES_PASSWORD: ${AIMETER_DB_PASSWORD:-aimeter}
POSTGRES_DB: ${AIMETER_DB_NAME:-aimeter}
volumes:
- dbdata:/var/lib/postgresql/data
- ./db/init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 3s
retries: 20
redis:
image: public.ecr.aws/docker/library/redis:7.4.9-alpine
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec", "--save", "60", "1000"]
restart: unless-stopped
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 20
api:
build: .
image: aimeter-app:local
command: uvicorn aimeter.api.main:app --host 0.0.0.0 --port 8000
restart: unless-stopped
volumes:
# live-mount the static dir so monitor.html edits show on refresh (no rebuild)
- ./aimeter/api/static:/app/aimeter/api/static:ro
environment:
AIMETER_DATABASE_URL: postgresql://${AIMETER_DB_USER:-aimeter}:${AIMETER_DB_PASSWORD:-aimeter}@db:5432/${AIMETER_DB_NAME:-aimeter}
AIMETER_REDIS_URL: redis://redis:6379/0
AIMETER_GRID_PROVIDER: ${AIMETER_GRID_PROVIDER:-bundled}
AIMETER_DEFAULT_REGION: ${AIMETER_DEFAULT_REGION:-WORLD}
AIMETER_API_TOKEN: ${AIMETER_API_TOKEN:-}
AIMETER_CLAIM_IDLE_MS: ${AIMETER_CLAIM_IDLE_MS:-30000}
AIMETER_MAX_DELIVERY_ATTEMPTS: ${AIMETER_MAX_DELIVERY_ATTEMPTS:-5}
ports:
- "127.0.0.1:${AIMETER_API_PORT:-8000}:8000"
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/healthz', timeout=2)"]
interval: 10s
timeout: 3s
retries: 10
worker:
image: aimeter-app:local
command: python -m aimeter.worker
restart: unless-stopped
environment:
AIMETER_DATABASE_URL: postgresql://${AIMETER_DB_USER:-aimeter}:${AIMETER_DB_PASSWORD:-aimeter}@db:5432/${AIMETER_DB_NAME:-aimeter}
AIMETER_REDIS_URL: redis://redis:6379/0
AIMETER_GRID_PROVIDER: ${AIMETER_GRID_PROVIDER:-bundled}
AIMETER_DEFAULT_REGION: ${AIMETER_DEFAULT_REGION:-WORLD}
AIMETER_API_TOKEN: ${AIMETER_API_TOKEN:-}
AIMETER_CLAIM_IDLE_MS: ${AIMETER_CLAIM_IDLE_MS:-30000}
AIMETER_MAX_DELIVERY_ATTEMPTS: ${AIMETER_MAX_DELIVERY_ATTEMPTS:-5}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import redis,os; r=redis.Redis.from_url(os.environ['AIMETER_REDIS_URL']); assert r.get('aimeter:worker:heartbeat')"]
interval: 10s
timeout: 3s
retries: 10
volumes:
dbdata:
redisdata: