-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
102 lines (96 loc) · 2.64 KB
/
docker-compose.yml
File metadata and controls
102 lines (96 loc) · 2.64 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
# IntelliWeather API - Docker Compose Configuration
#
# This configuration includes:
# - Multiple app replicas for load balancing
# - NGINX reverse proxy/load balancer
# - Redis for session storage (production)
# - Volume mounts for data persistence
#
# Usage:
# docker-compose up -d # Start all services
# docker-compose up -d --scale app=3 # Start with 3 app replicas
# docker-compose logs -f # View logs
# docker-compose down # Stop all services
version: '3.8'
services:
# ==================== APPLICATION ====================
app:
build:
context: .
dockerfile: Dockerfile
environment:
- APP_NAME=IntelliWeather
- APP_HOST=0.0.0.0
- APP_PORT=8000
- DATA_DIR=/app/data
- CACHE_TTL_SECONDS=3600
- SESSION_TIMEOUT_SECONDS=86400
- RATE_LIMIT_PER_MIN=60
- LOG_LEVEL=INFO
- LOG_FORMAT=json
# Uncomment for Redis session backend (recommended for multiple replicas)
# - SESSION_BACKEND=redis
# - REDIS_URL=redis://redis:6379/0
# Uncomment for Sentry error tracking
# - SENTRY_DSN=${SENTRY_DSN}
volumes:
- app_data:/app/data
expose:
- "8000"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/healthz')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
restart: unless-stopped
deploy:
replicas: 2
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
# ==================== NGINX LOAD BALANCER ====================
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./static:/usr/share/nginx/html/static:ro
depends_on:
- app
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost/healthz"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
# ==================== REDIS (Optional - for production sessions) ====================
# Uncomment to enable Redis session backend
# redis:
# image: redis:7-alpine
# command: redis-server --appendonly yes
# volumes:
# - redis_data:/data
# expose:
# - "6379"
# healthcheck:
# test: ["CMD", "redis-cli", "ping"]
# interval: 30s
# timeout: 10s
# retries: 3
# restart: unless-stopped
volumes:
app_data:
driver: local
# redis_data:
# driver: local
networks:
default:
name: intelliweather_network
driver: bridge