-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
127 lines (120 loc) · 4.45 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
127 lines (120 loc) · 4.45 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
124
125
126
127
# ==============================================================================
# Spectre — Docker Compose (Full Development Stack)
#
# Usage: docker compose -f docker-compose.dev.yml up
#
# Provides the COMPLETE development ecosystem:
# - PostgreSQL 16 (database)
# - Redis 7 (cache + broker)
# - Spectre API (FastAPI, hot-reload via volume mount)
# - Celery Worker (async webhook delivery)
# - Newman (API contract tests — run on demand)
#
# Zero local dependencies required. Clone → docker compose up → working.
# ==============================================================================
services:
# ─── PostgreSQL ─────────────────────────────────────────────────────────────
postgres:
image: postgres:16-alpine
container_name: spectre-postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: spectre_dev_pass
POSTGRES_DB: spectre
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d spectre"]
interval: 5s
timeout: 3s
retries: 10
restart: unless-stopped
# ─── Redis ──────────────────────────────────────────────────────────────────
redis:
image: redis:7-alpine
container_name: spectre-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru
restart: unless-stopped
# ─── Spectre API ────────────────────────────────────────────────────────────
api:
build:
context: .
dockerfile: Dockerfile.local
container_name: spectre-api
env_file: .env.docker
ports:
- "8000:8000"
volumes:
- ./src:/app/src:ro
- ./artifact:/app/artifact:ro
- ./migrations:/app/migrations:ro
- ./alembic.ini:/app/alembic.ini:ro
- ./seeds:/app/seeds:ro
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
entrypoint: ["/bin/sh", "-c"]
command:
- |
echo "[spectre] Running migrations..."
python -m alembic upgrade head 2>/dev/null || echo "[spectre] Migration skipped (may already be current)"
echo "[spectre] Running seeds..."
python -m seeds all 2>/dev/null || echo "[spectre] Seeds skipped"
echo "[spectre] Starting API server..."
uvicorn spectre.main:create_app --factory --host 0.0.0.0 --port 8000 --reload --reload-dir /app/src
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 3
# ─── Celery Worker ──────────────────────────────────────────────────────────
worker:
build:
context: .
dockerfile: Dockerfile.local
container_name: spectre-worker
env_file: .env.docker
volumes:
- ./src:/app/src:ro
- ./artifact:/app/artifact:ro
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
command: celery -A spectre.workers.celery_app worker --loglevel=info --concurrency=2
restart: unless-stopped
# ─── Newman (API contract tests — run on demand) ────────────────────────────
newman:
image: postman/newman:6-alpine
container_name: spectre-newman
volumes:
- ./tests/postman:/etc/newman:ro
- ./reports:/etc/newman/reports
depends_on:
api:
condition: service_healthy
entrypoint: ["newman", "run", "/etc/newman/spectre-api-v1.postman_collection.json",
"-e", "/etc/newman/env-docker.json",
"--reporters", "cli",
"--timeout-request", "10000"]
profiles:
- test # Only runs with: docker compose --profile test up newman
volumes:
postgres_data:
redis_data: