-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
171 lines (161 loc) · 5.1 KB
/
Copy pathdocker-compose.yml
File metadata and controls
171 lines (161 loc) · 5.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
services:
reverse-proxy:
image: traefik:v3.6.4
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entryPoints.web.address=:80"
- "--api.insecure=true"
- "--entryPoints.traefik.address=:8833" # ← isolate the API/dashboard entrypoint
- "--api.dashboard=true"
- "--log.level=DEBUG"
- "--ping=true"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`traefik.localhost`)"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.entrypoints=traefik"
container_name: co2-calculator-traefik
restart: unless-stopped
healthcheck:
test: ["CMD", "traefik", "healthcheck", "--ping"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "127.0.0.1:80:80"
- "127.0.0.1:8080:8833"
expose:
- "80"
- "8833"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
# PostgreSQL for Auth module
postgres:
image: postgres:18-alpine
container_name: co2-calculator-postgres
restart: unless-stopped
env_file:
- ./backend/.env
- ./.database.env
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"
ports:
- "127.0.0.1:5432:5432"
labels:
- "traefik.enable=false"
volumes:
- postgres-data-18:/var/lib/postgresql
command: ["postgres", "-c", "listen_addresses=*"]
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $$DB_URL"]
interval: 3s
timeout: 5s
retries: 5
pgadmin:
image: dpage/pgadmin4:latest
container_name: co2-calculator-pgadmin
restart: always
labels:
- "traefik.enable=false"
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: admin
volumes:
- pgadmin_data:/var/lib/pgadmin
ports:
- "127.0.0.1:5050:80"
depends_on:
- postgres
# FastAPI Backend
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: co2-backend
environment:
# Local compose only — never True on stage/prod (see app/core/config.py).
DEBUG: "True"
HOST: "0.0.0.0"
PORT: "8000"
WORKERS: "1"
command: >
sh -c '
alembic upgrade head &&
exec opentelemetry-instrument uvicorn app.main:app --host $$HOST --port $$PORT --workers $$WORKERS
'
env_file:
- ./backend/.env
# volumes:
# - ./app:/app/app:ro
labels:
- "traefik.enable=true"
# Router
- "traefik.http.routers.backend.rule=PathPrefix(`/api`)"
- "traefik.http.routers.backend.entrypoints=web"
- "traefik.http.routers.backend.priority=200"
- "traefik.http.routers.backend.middlewares=backend-stripprefix"
# Middleware
- "traefik.http.middlewares.backend-stripprefix.stripprefix.prefixes=/api"
# Service
- "traefik.http.services.backend.loadbalancer.server.port=8000"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8000/ready"]
interval: 10s
timeout: 3s
retries: 3
start_period: 20s # give alembic time to run migrations first
depends_on:
postgres:
condition: service_healthy
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: co2-frontend
ports:
- "127.0.0.1:3000:8080"
# Match the k8s pod's securityContext (readOnlyRootFilesystem: true plus
# the three emptyDir mounts in helm/templates/frontend-deployment.yaml).
# Catches read-only-fs regressions locally before they ship to a cluster
# — see fix(344): write injectEnv.js to /tmp.
read_only: true
tmpfs:
- /tmp
- /var/cache/nginx
- /var/run
environment:
# Empty by default. Set in your shell (or repo-root .env) to enable
# Sentry/GlitchTip from a `docker compose up` run. Same vars the k8s
# pod receives via helm/values.yaml frontend.env.
APP_SENTRY_DSN: "${APP_SENTRY_DSN:-}"
APP_ENVIRONMENT: "${APP_ENVIRONMENT:-compose}"
labels:
- "traefik.enable=true"
# match everything else
- "traefik.http.routers.frontend.rule=PathPrefix(`/`)"
- "traefik.http.routers.frontend.entrypoints=web"
- "traefik.http.routers.frontend.priority=100"
- "traefik.http.routers.frontend.middlewares=frontend-compress"
- "traefik.http.middlewares.frontend-compress.compress=true"
- "traefik.http.services.frontend.loadbalancer.server.port=8080"
depends_on:
- backend
otel:
image: otel/opentelemetry-collector-contrib:0.86.0
command: ["--config=/etc/otel-collector-config.yaml"]
labels:
- "traefik.enable=false"
ports:
- "127.0.0.1:9464:9464" # Prometheus — host access
- "127.0.0.1:4317:4317" # gRPC OTLP — add if you need host access too
expose:
- "4317" # gRPC OTLP — makes it reachable by other containers
- "4318" # HTTP OTLP
volumes:
- ./otel/otel-collector-config.yaml:/etc/otel-collector-config.yaml:ro
volumes:
pgadmin_data:
driver: local
postgres-data-18:
driver: local