-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
94 lines (90 loc) · 2.75 KB
/
docker-compose.yml
File metadata and controls
94 lines (90 loc) · 2.75 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
services:
# ============================================
# PostgreSQL (Development Database)
# ============================================
postgres:
image: postgres:16-alpine
container_name: acmelearn_postgres
env_file:
- .env
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
# ============================================
# PostgreSQL (Test Database)
# In-memory storage for fast test runs
# ============================================
postgres_test:
image: postgres:16-alpine
container_name: acmelearn_postgres_test
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: acmelearn_test
ports:
- "5433:5432"
tmpfs:
- /var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d acmelearn_test"]
interval: 5s
timeout: 3s
retries: 3
# ============================================
# Backend (FastAPI)
# ============================================
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: acmelearn_backend
env_file:
- .env
environment:
# Override DATABASE_URL to use Docker internal hostname
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
# Test database URL for running tests inside container
TEST_DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres_test:5432/acmelearn_test
ports:
- "8000:8000"
volumes:
- ./backend:/app
- ./tests:/tests # Mount tests directory
- ./courses.json:/courses.json # Mount courses data for seeding
- /app/.venv # Exclude container's venv from mount
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
# ============================================
# Frontend (React + Vite)
# ============================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: acmelearn_frontend
ports:
- "5173:5173"
volumes:
- ./frontend:/app
- /app/node_modules # Exclude container's node_modules from mount
environment:
- CHOKIDAR_USEPOLLING=true # For macOS/Windows file watching
depends_on:
- backend
restart: unless-stopped
volumes:
postgres_data:
driver: local