-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
93 lines (87 loc) · 2.3 KB
/
docker-compose.yml
File metadata and controls
93 lines (87 loc) · 2.3 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
version: '3.8'
services:
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: memory_tracker
POSTGRES_USER: memory_tracker_user
POSTGRES_PASSWORD: memory_tracker_password
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U memory_tracker_user -d memory_tracker"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
backend:
build:
context: ./backend
dockerfile: Dockerfile
env_file:
- .env
environment:
DATABASE_URL: postgresql+asyncpg://memory_tracker_user:memory_tracker_password@db:5432/memory_tracker
ports:
- "8000:8000"
depends_on:
db:
condition: service_healthy
volumes:
# Mount the scripts directory to run initialization
- ./backend/scripts:/app/scripts:ro
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
NEXT_PUBLIC_API_BASE: http://localhost:8000
environment:
NEXT_PUBLIC_API_BASE: http://localhost:8000
ports:
- "3000:3000"
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
# Service to initialize the database with default binaries
db-init:
build:
context: ./backend
dockerfile: Dockerfile
env_file:
- .env
environment:
DATABASE_URL: postgresql+asyncpg://memory_tracker_user:memory_tracker_password@db:5432/memory_tracker
depends_on:
backend:
condition: service_healthy
command: >
sh -c "
echo 'Waiting for backend to be ready...' &&
sleep 10 &&
echo 'Populating database with default binaries...' &&
python scripts/populate_binaries.py &&
echo 'Database initialization complete!'
"
restart: "no"
volumes:
postgres_data:
networks:
default:
name: memory_tracker_network