-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
123 lines (117 loc) · 4.27 KB
/
Copy pathdocker-compose.yml
File metadata and controls
123 lines (117 loc) · 4.27 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
services:
# ─── PostgreSQL ──────────────────────────────────────────────────────────────
db:
image: postgres:16-alpine
container_name: ${COMPOSE_PROJECT_NAME:-soc}_db
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-soc_saas}
POSTGRES_USER: ${POSTGRES_USER:-soc_user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-soc_secret}
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-soc_user} -d ${POSTGRES_DB:-soc_saas}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# ─── Redis ───────────────────────────────────────────────────────────────────
redis:
image: redis:7-alpine
container_name: ${COMPOSE_PROJECT_NAME:-soc}_redis
restart: unless-stopped
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# ─── Backend ─────────────────────────────────────────────────────────────────
backend:
build:
context: ./backend
dockerfile: Dockerfile
target: development
container_name: ${COMPOSE_PROJECT_NAME:-soc}_backend
restart: unless-stopped
command: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
volumes:
- ./backend:/app
ports:
- "8000:8000"
env_file:
- ./backend/.env
environment:
# Use Docker service names — these override backend/.env localhost values
- DATABASE_URL=postgresql://${POSTGRES_USER:-soc_user}:${POSTGRES_PASSWORD:-soc_secret}@db:5432/${POSTGRES_DB:-soc_saas}
- REDIS_URL=redis://redis:6379/0
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health"]
interval: 15s
timeout: 5s
retries: 3
start_period: 20s
# ─── Background Workers ───────────────────────────────────────────────────────
worker:
build:
context: ./backend
dockerfile: Dockerfile
target: development
container_name: ${COMPOSE_PROJECT_NAME:-soc}_worker
restart: unless-stopped
command: python -m app.workers.main
volumes:
- ./backend:/app
env_file:
- ./backend/.env
environment:
# Use Docker service names — these override backend/.env localhost values
- DATABASE_URL=postgresql://${POSTGRES_USER:-soc_user}:${POSTGRES_PASSWORD:-soc_secret}@db:5432/${POSTGRES_DB:-soc_saas}
- REDIS_URL=redis://redis:6379/0
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
backend:
condition: service_healthy
# ─── Frontend ─────────────────────────────────────────────────────────────────
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
target: development
container_name: ${COMPOSE_PROJECT_NAME:-soc}_frontend
restart: unless-stopped
command: npm run dev -- --host 0.0.0.0
volumes:
- ./frontend:/app
- /app/node_modules
ports:
- "5173:5173"
environment:
# Browser connects to these from the host machine — keep as localhost:<exposed port>
- VITE_API_URL=http://localhost:8000
- VITE_WS_URL=ws://localhost:8000
depends_on:
- backend
volumes:
postgres_data:
driver: local
redis_data:
driver: local
networks:
default:
name: ${COMPOSE_PROJECT_NAME:-soc}_network