Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
87 lines (83 loc) · 3.43 KB
/
Copy pathdocker-compose.yml
File metadata and controls
87 lines (83 loc) · 3.43 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
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-suas}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required; set it in .env}
POSTGRES_DB: ${POSTGRES_DB:-suas}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-suas} -d ${POSTGRES_DB:-suas}"]
interval: 5s
timeout: 5s
retries: 12
restart: unless-stopped
# Migrations are a deploy step (#87): this one-shot service upgrades the
# schema and exits, and the backend starts only once it has succeeded. A
# restart of the backend alone never changes the schema, so a rollback holds.
migrate:
build:
context: .
dockerfile: backend/Dockerfile
command: ["migrate"]
environment:
SUAS_DATABASE_URL: postgresql+psycopg://${POSTGRES_USER:-suas}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-suas}
depends_on:
db:
condition: service_healthy
restart: "no"
backend:
build:
context: .
dockerfile: backend/Dockerfile
environment:
SUAS_DATABASE_URL: postgresql+psycopg://${POSTGRES_USER:-suas}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-suas}
SUAS_OPENAI_API_KEY: ${OPENAI_API_KEY:-}
# Demo mode (#97): fixture weather, every plan advisory, no keys needed.
SUAS_DEMO_MODE: ${DEMO_MODE:-false}
SUAS_OPENAI_MODEL: ${OPENAI_MODEL:-gpt-4o-mini}
SUAS_API_KEY: ${API_KEY:-}
SUAS_API_KEYS: ${API_KEYS:-}
# Per-browser operators (#82). The default is a PUBLIC, demo-only secret:
# anyone can forge any session with it. Set SESSION_KEY_SECRET (32+ chars)
# for any shared deployment. The backend warns at startup while it is used.
SUAS_SESSION_KEY_SECRET: ${SESSION_KEY_SECRET:-demo-only-session-secret-from-docker-compose-never-deploy}
SUAS_CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:3000}
SUAS_LOG_LEVEL: ${LOG_LEVEL:-INFO}
SUAS_JSON_LOGS: ${JSON_LOGS:-true}
SUAS_BATTERY_RESERVE_PERCENT: ${BATTERY_RESERVE_PERCENT:-20}
SUAS_CHECKPOINT_RETENTION_DAYS: ${CHECKPOINT_RETENTION_DAYS:-30}
SUAS_RATE_LIMIT_REQUESTS: ${RATE_LIMIT_REQUESTS:-30}
SUAS_RATE_LIMIT_WINDOW_S: ${RATE_LIMIT_WINDOW_S:-60}
# The image runs two uvicorn workers; one budget in Postgres keeps the
# ceiling at RATE_LIMIT_REQUESTS rather than twice that (#84).
SUAS_RATE_LIMIT_SHARED: ${RATE_LIMIT_SHARED:-true}
# Likewise one weather cache, so worker B reuses worker A's reading (#85).
SUAS_WEATHER_CACHE_SHARED: ${WEATHER_CACHE_SHARED:-true}
depends_on:
db:
condition: service_healthy
migrate:
condition: service_completed_successfully
ports:
- "8000:8000"
restart: unless-stopped
frontend:
build:
context: ./frontend
environment:
# Server-side only. The browser never sees these: it calls the Next
# server's own /api routes, which proxy to the backend with the key.
BACKEND_API_URL: ${BACKEND_API_URL:-http://backend:8000}
BACKEND_API_KEY: ${API_KEY:-}
# Must equal the backend's SUAS_SESSION_KEY_SECRET; demo-only default.
# Each browser gets its own httpOnly session cookie and operator.
BACKEND_SESSION_SECRET: ${SESSION_KEY_SECRET:-demo-only-session-secret-from-docker-compose-never-deploy}
depends_on:
- backend
ports:
- "3000:3000"
restart: unless-stopped
volumes:
pgdata: