-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
41 lines (38 loc) · 1.4 KB
/
docker-compose.yml
File metadata and controls
41 lines (38 loc) · 1.4 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
version: '3.8'
services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- "5432:5432" # Expose DB port to host for direct access if needed
volumes:
- pg_data:/var/lib/postgresql/data # Persist database data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql # Initialize DB with schema and data
healthcheck: # Basic health check to ensure DB is ready
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s # Check every 10 seconds (was 5s)
timeout: 5s
retries: 10 # Try more times (was 5)
start_period: 30s # <--- ADD THIS: Give it a grace period for initial startup
app:
build: .
restart: unless-stopped
ports:
- "8000:8000" # Expose FastAPI app port to host
environment:
# Pass environment variables to the app container from .env file
GOOGLE_API_KEY: ${GOOGLE_API_KEY}
LLM_MODEL: ${LLM_MODEL}
DB_HOST: db # This matches the service name of the database container
DB_NAME: ${DB_NAME}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
depends_on:
db:
condition: service_healthy # Ensure the app starts only after DB is healthy
volumes:
pg_data: # Define named volume for database persistence