-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
284 lines (273 loc) · 8.49 KB
/
docker-compose.yml
File metadata and controls
284 lines (273 loc) · 8.49 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
version: '3.9'
# =============================================================================
# Funding Application Platform - Docker Compose Configuration
# Supports: PostgreSQL, Redis, Backend, Frontend, ClamAV
# Compliance: GDPR/UK Data Protection Act 2018 ready
# Target: 99.5% availability during open call windows
# =============================================================================
services:
# ==========================================================================
# PostgreSQL Database
# ==========================================================================
postgres:
image: postgres:16-alpine
container_name: funding_platform_db
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-funding_platform}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database/init:/docker-entrypoint-initdb.d:ro
ports:
- "${POSTGRES_PORT:-5432}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-funding_platform}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- funding_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ==========================================================================
# Redis Cache & Session Store
# ==========================================================================
redis:
image: redis:7-alpine
container_name: funding_platform_redis
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD:-redis} --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
ports:
- "${REDIS_PORT:-6379}:6379"
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-redis}", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- funding_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ==========================================================================
# Backend API
# ==========================================================================
backend:
build:
context: ./backend
dockerfile: Dockerfile
args:
NODE_ENV: ${NODE_ENV:-production}
container_name: funding_platform_api
restart: unless-stopped
environment:
NODE_ENV: ${NODE_ENV:-development}
PORT: 4000
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-funding_platform}
REDIS_URL: redis://:${REDIS_PASSWORD:-redis}@redis:6379
JWT_SECRET: ${JWT_SECRET:-change-me-in-production}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-30m}
SESSION_SECRET: ${SESSION_SECRET:-change-me-in-production}
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost:3000}
# ClamAV Configuration
CLAMAV_HOST: clamav
CLAMAV_PORT: 3310
# File Storage
STORAGE_DRIVER: ${STORAGE_DRIVER:-local}
STORAGE_LOCAL_PATH: /app/uploads
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-}
AWS_REGION: ${AWS_REGION:-eu-west-2}
AWS_S3_BUCKET: ${AWS_S3_BUCKET:-}
# Email
SMTP_HOST: ${SMTP_HOST:-mailhog}
SMTP_PORT: ${SMTP_PORT:-1025}
EMAIL_FROM_ADDRESS: ${EMAIL_FROM_ADDRESS:-noreply@funding-platform.gov.uk}
# Timezone (UK compliance)
TZ: Europe/London
volumes:
- uploads_data:/app/uploads
- ./backend/logs:/app/logs
ports:
- "${BACKEND_PORT:-4000}:4000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- funding_network
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
# ==========================================================================
# Frontend Application
# ==========================================================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:4000}
container_name: funding_platform_web
restart: unless-stopped
environment:
NODE_ENV: ${NODE_ENV:-development}
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:4000}
TZ: Europe/London
ports:
- "${FRONTEND_PORT:-3000}:3000"
depends_on:
- backend
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
networks:
- funding_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ==========================================================================
# ClamAV Virus Scanner
# ==========================================================================
clamav:
image: clamav/clamav:stable
container_name: funding_platform_clamav
restart: unless-stopped
volumes:
- clamav_data:/var/lib/clamav
ports:
- "${CLAMAV_PORT:-3310}:3310"
healthcheck:
test: ["CMD", "clamdscan", "--ping", "3"]
interval: 60s
timeout: 10s
retries: 3
start_period: 120s
networks:
- funding_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ==========================================================================
# MinIO (S3-compatible storage for local development)
# ==========================================================================
minio:
image: minio/minio:latest
container_name: funding_platform_minio
restart: unless-stopped
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin}
volumes:
- minio_data:/data
ports:
- "9000:9000"
- "9001:9001"
profiles:
- dev
- full
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
networks:
- funding_network
# ==========================================================================
# MailHog (Email testing for development)
# ==========================================================================
mailhog:
image: mailhog/mailhog:latest
container_name: funding_platform_mailhog
restart: unless-stopped
ports:
- "1025:1025" # SMTP
- "8025:8025" # Web UI
profiles:
- dev
- full
networks:
- funding_network
# ==========================================================================
# Nginx Reverse Proxy (Production)
# ==========================================================================
nginx:
image: nginx:1.25-alpine
container_name: funding_platform_nginx
restart: unless-stopped
profiles:
- production
depends_on:
- backend
- frontend
volumes:
- ./infrastructure/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./infrastructure/nginx/conf.d:/etc/nginx/conf.d:ro
- ./infrastructure/nginx/ssl:/etc/nginx/ssl:ro
- nginx_logs:/var/log/nginx
ports:
- "80:80"
- "443:443"
healthcheck:
test: ["CMD", "nginx", "-t"]
interval: 30s
timeout: 10s
retries: 3
networks:
- funding_network
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
# =============================================================================
# Volumes
# =============================================================================
volumes:
postgres_data:
driver: local
redis_data:
driver: local
clamav_data:
driver: local
minio_data:
driver: local
uploads_data:
driver: local
nginx_logs:
driver: local
# =============================================================================
# Networks
# =============================================================================
networks:
funding_network:
driver: bridge
name: funding_platform_network