-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
182 lines (163 loc) · 6.59 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
182 lines (163 loc) · 6.59 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Docker Compose for SignUpFlow - DEVELOPMENT ENVIRONMENT
# Includes PostgreSQL, Redis, and API with hot-reload
# Usage: docker-compose -f docker-compose.dev.yml up
services:
# ============================================================================
# PostgreSQL Database (Development)
# ============================================================================
db:
image: postgres:16-alpine
container_name: signupflow-dev-db
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-signupflow_dev}
POSTGRES_USER: ${POSTGRES_USER:-signupflow}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-dev_password_change_in_production}
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=en_US.UTF-8"
volumes:
- postgres_dev_data:/var/lib/postgresql/data
- ./backups:/backups # For database backups
ports:
- "${POSTGRES_PORT:-5433}:5432" # Map to 5433 to avoid conflicts with local PostgreSQL
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-signupflow} -d ${POSTGRES_DB:-signupflow_dev}"]
interval: 5s
timeout: 5s
retries: 5
networks:
- signupflow-dev-network
# ============================================================================
# Redis (for caching, rate limiting, sessions)
# ============================================================================
redis:
image: redis:7-alpine
container_name: signupflow-dev-redis
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD:-dev_redis_password} --appendonly yes
volumes:
- redis_dev_data:/data
ports:
- "${REDIS_PORT:-6380}:6379" # Map to 6380 to avoid conflicts with local Redis
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 5s
timeout: 5s
retries: 5
networks:
- signupflow-dev-network
# ============================================================================
# SignUpFlow FastAPI Backend (Development with Hot-Reload)
# ============================================================================
api:
build:
context: .
dockerfile: Dockerfile.dev
container_name: signupflow-dev-api
restart: unless-stopped
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
# ⭐ NEW: Load secrets from .env file
env_file:
- .env
# ⭐ NEW: Minimal environment config - tells app which YAML profile to use
environment:
# Which environment profile to load (dev/test/prod)
CONFIG_PROFILE: dev
# E2E test API endpoint (required for RBAC security tests in Docker)
# Use service name 'api' for Docker networking (localhost doesn't work inside container)
E2E_API_BASE: http://api:8000/api
# Off unless .env turns it on: the dev stack has no mail catcher.
EMAIL_ENABLED: ${EMAIL_ENABLED:-false}
# Disable rate limiting for E2E tests (prevents HTTP 429 errors during test suite)
DISABLE_RATE_LIMITS: true
# Disable usage limits for E2E tests (prevents volunteer limit errors during test suite)
DISABLE_USAGE_LIMITS: true
# Runtime overrides (secrets from .env, structure from config/env.dev.yaml)
# These are the only values that should be here - everything else in YAML
DATABASE_URL: postgresql://${POSTGRES_USER:-signupflow}:${POSTGRES_PASSWORD:-dev_password_change_in_production}@db:5432/${POSTGRES_DB:-signupflow_dev}
REDIS_URL: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
CELERY_BROKER_URL: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
CELERY_RESULT_BACKEND: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
ports:
- "${PORT:-8000}:8000"
volumes:
# Hot-reload: Mount source code
- ./api:/app/api
- ./web:/app/web
- ./frontend:/app/frontend
- ./locales:/app/locales
- ./alembic:/app/alembic
- ./alembic.ini:/app/alembic.ini
- ./tests:/app/tests
# ⭐ NEW: Mount YAML configuration profiles
- ./config:/app/config:ro # Read-only mount for security
# Persistent data
- ./data:/app/data
- ./logs:/app/logs
# Don't mount these (keep container versions)
# - ./pyproject.toml:/app/pyproject.toml
# - ./poetry.lock:/app/poetry.lock
healthcheck:
# The dev image is Alpine without curl; probe with its own Python.
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health', timeout=3)"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
networks:
- signupflow-dev-network
# Override CMD for development with auto-reload
command: uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload --log-level debug
# ============================================================================
# Celery Worker (Background Tasks)
# ============================================================================
worker:
build:
context: .
dockerfile: Dockerfile.dev
container_name: signupflow-dev-worker
restart: unless-stopped
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
api:
condition: service_started
env_file:
- .env
environment:
CONFIG_PROFILE: dev
EMAIL_ENABLED: ${EMAIL_ENABLED:-false}
# Runtime overrides
DATABASE_URL: postgresql://${POSTGRES_USER:-signupflow}:${POSTGRES_PASSWORD:-dev_password_change_in_production}@db:5432/${POSTGRES_DB:-signupflow_dev}
REDIS_URL: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
CELERY_BROKER_URL: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
CELERY_RESULT_BACKEND: redis://:${REDIS_PASSWORD:-dev_redis_password}@redis:6379/0
volumes:
- ./api:/app/api
- ./config:/app/config:ro
- ./logs:/app/logs
# The image's HEALTHCHECK polls :8000/health, which Celery never serves.
healthcheck:
disable: true
networks:
- signupflow-dev-network
command: celery -A api.celery_app worker --loglevel=info
# ============================================================================
# Volumes (persistent data storage)
# ============================================================================
volumes:
postgres_dev_data:
driver: local
redis_dev_data:
driver: local
# ============================================================================
# Networks
# ============================================================================
networks:
signupflow-dev-network:
driver: bridge