-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
283 lines (263 loc) · 8.17 KB
/
docker-compose.yml
File metadata and controls
283 lines (263 loc) · 8.17 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
# ===========================================
# FilantropiaSolar - Docker Compose
# ===========================================
version: '3.9'
# ===========================================
# Network configuration
# ===========================================
networks:
filantropia-net:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
# ===========================================
# Volume definitions
# ===========================================
volumes:
postgres_data:
driver: local
redis_data:
driver: local
filantropia_models:
driver: local
filantropia_data:
driver: local
filantropia_logs:
driver: local
# ===========================================
# Services
# ===========================================
services:
# =========================================
# PostgreSQL Database
# =========================================
postgres:
image: postgres:15-alpine
container_name: filantropia-postgres
restart: unless-stopped
environment:
POSTGRES_DB: filantropia_solar
POSTGRES_USER: fs_user
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-dev_password_change_in_production}
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql:ro
ports:
- "${POSTGRES_PORT:-5432}:5432"
networks:
- filantropia-net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U fs_user -d filantropia_solar"]
interval: 10s
timeout: 5s
retries: 5
# =========================================
# Redis Cache
# =========================================
redis:
image: redis:7-alpine
container_name: filantropia-redis
restart: unless-stopped
command: >
redis-server
--requirepass ${REDIS_PASSWORD:-dev_redis_password}
--appendonly yes
--appendfsync everysec
--maxmemory 256mb
--maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
ports:
- "${REDIS_PORT:-6379}:6379"
networks:
- filantropia-net
healthcheck:
test: ["CMD", "redis-cli", "--no-auth-warning", "-a", "${REDIS_PASSWORD:-dev_redis_password}", "ping"]
interval: 10s
timeout: 3s
retries: 5
# =========================================
# FilantropiaSolar API Service
# =========================================
filantropia-api:
build:
context: .
dockerfile: Dockerfile
target: api
args:
BUILD_TARGET: api
container_name: filantropia-api
restart: unless-stopped
environment:
# Database configuration
DATABASE_URL: postgresql+asyncpg://fs_user:${POSTGRES_PASSWORD:-dev_password_change_in_production}@postgres:5432/filantropia_solar
REDIS_URL: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
# Application configuration
ENVIRONMENT: ${ENVIRONMENT:-production}
DEBUG: ${DEBUG:-false}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
# API configuration
API_HOST: 0.0.0.0
API_PORT: 8000
API_WORKERS: ${API_WORKERS:-4}
API_RELOAD: ${API_RELOAD:-false}
# Security
SECRET_KEY: ${SECRET_KEY:-change-this-in-production}
ACCESS_TOKEN_EXPIRE_MINUTES: ${ACCESS_TOKEN_EXPIRE_MINUTES:-30}
# External APIs
OPENWEATHER_API_KEY: ${OPENWEATHER_API_KEY:-}
# ML Model configuration
MODEL_CACHE_SIZE: ${MODEL_CACHE_SIZE:-3}
ENABLE_MODEL_PERSISTENCE: ${ENABLE_MODEL_PERSISTENCE:-true}
volumes:
- filantropia_models:/app/models
- filantropia_data:/app/data:ro
- filantropia_logs:/app/logs
- ./exports:/app/exports
ports:
- "${API_PORT:-8000}:8000"
networks:
- filantropia-net
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# =========================================
# FilantropiaSolar Worker (Background Tasks)
# =========================================
filantropia-worker:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: filantropia-worker
restart: unless-stopped
command: ["python", "-m", "filantropia_solar.worker"]
environment:
# Database configuration
DATABASE_URL: postgresql+asyncpg://fs_user:${POSTGRES_PASSWORD:-dev_password_change_in_production}@postgres:5432/filantropia_solar
REDIS_URL: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
# Worker configuration
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
WORKER_LOG_LEVEL: ${WORKER_LOG_LEVEL:-INFO}
# Application configuration
ENVIRONMENT: ${ENVIRONMENT:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
volumes:
- filantropia_models:/app/models
- filantropia_data:/app/data:ro
- filantropia_logs:/app/logs
networks:
- filantropia-net
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
# =========================================
# FilantropiaSolar GUI (Desktop in Container)
# =========================================
filantropia-gui:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: filantropia-gui
restart: "no" # Manual start for GUI
command: ["python", "-m", "filantropia_solar.gui.main"]
environment:
DISPLAY: ${DISPLAY:-:0}
XDG_RUNTIME_DIR: /tmp/runtime-appuser
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- filantropia_models:/app/models
- filantropia_data:/app/data:ro
- filantropia_logs:/app/logs
- ./exports:/app/exports
networks:
- filantropia-net
profiles:
- gui # Only start with --profile gui
# =========================================
# Nginx Reverse Proxy
# =========================================
nginx:
image: nginx:1.25-alpine
container_name: filantropia-nginx
restart: unless-stopped
ports:
- "${NGINX_HTTP_PORT:-80}:80"
- "${NGINX_HTTPS_PORT:-443}:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d:/etc/nginx/conf.d:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- filantropia_logs:/var/log/nginx
networks:
- filantropia-net
depends_on:
- filantropia-api
profiles:
- nginx # Only start with --profile nginx
# =========================================
# Monitoring: Prometheus
# =========================================
prometheus:
image: prom/prometheus:v2.50.1
container_name: filantropia-prometheus
restart: unless-stopped
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
networks:
- filantropia-net
profiles:
- monitoring
# =========================================
# Monitoring: Grafana
# =========================================
grafana:
image: grafana/grafana:10.3.1
container_name: filantropia-grafana
restart: unless-stopped
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-admin}
GF_USERS_ALLOW_SIGN_UP: "false"
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
ports:
- "${GRAFANA_PORT:-3000}:3000"
networks:
- filantropia-net
depends_on:
- prometheus
profiles:
- monitoring
# ===========================================
# Additional volumes for monitoring
# ===========================================
volumes:
prometheus_data:
driver: local
grafana_data:
driver: local