-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
90 lines (85 loc) · 2.92 KB
/
Copy pathdocker-compose.yml
File metadata and controls
90 lines (85 loc) · 2.92 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
# Docker Compose starter for local development
# Usage: docker compose up -d
# Includes: app, postgres, redis (optional)
# Add your application under src/ before enabling the app service.
services:
# --------------------------------------------------------------------------
# Application
# --------------------------------------------------------------------------
app:
build:
context: .
target: development
ports:
- "8000:8000"
volumes:
- ./src:/app/src:cached
- ./tests:/app/tests:cached
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-CHANGE_ME_POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-app_dev}
- REDIS_URL=redis://redis:6379/0
- DEBUG=true
- LOG_LEVEL=DEBUG
# Add your env vars here or use .env file
env_file:
- .env
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# --------------------------------------------------------------------------
# PostgreSQL
# --------------------------------------------------------------------------
db:
image: postgres:16-alpine
ports:
- "127.0.0.1:5432:5432" # Bind to localhost only for security
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-CHANGE_ME_POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:-app_dev}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
# --------------------------------------------------------------------------
# Redis (Optional - comment out if not needed)
# --------------------------------------------------------------------------
redis:
image: redis:7-alpine
ports:
- "127.0.0.1:6379:6379" # Bind to localhost only for security
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
command: redis-server --appendonly yes
# --------------------------------------------------------------------------
# pgAdmin (Optional - for database management UI)
# WARNING: Change default credentials before enabling in any shared environment
# --------------------------------------------------------------------------
# pgadmin:
# image: dpage/pgadmin4:latest
# ports:
# - "127.0.0.1:5050:80"
# environment:
# PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL:?set PGADMIN_EMAIL in .env}
# PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD:?set PGADMIN_PASSWORD in .env}
# depends_on:
# - db
volumes:
postgres_data:
redis_data: