-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.production.yml
More file actions
232 lines (221 loc) · 6.39 KB
/
docker-compose.production.yml
File metadata and controls
232 lines (221 loc) · 6.39 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
# Production Docker Compose Configuration for AgentGate
# This file provides production-ready deployment with:
# - PostgreSQL 16 with health checks and persistence
# - Redis 7 with password authentication
# - Proper health check dependencies
# - Resource limits and security configurations
# - Volume persistence for data durability
services:
# PostgreSQL 16 - Production Database
postgres:
image: postgres:16-bookworm
container_name: agentgate-postgres
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER:-agentgate}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set}
POSTGRES_DB: ${POSTGRES_DB:-agentgate}
# Performance tuning
POSTGRES_SHARED_BUFFERS: ${POSTGRES_SHARED_BUFFERS:-256MB}
POSTGRES_EFFECTIVE_CACHE_SIZE: ${POSTGRES_EFFECTIVE_CACHE_SIZE:-1GB}
POSTGRES_MAX_CONNECTIONS: ${POSTGRES_MAX_CONNECTIONS:-100}
volumes:
- postgres_data:/var/lib/postgresql/data
# Optional: Custom PostgreSQL configuration
# - ./deploy/postgres/postgresql.conf:/etc/postgresql/postgresql.conf:ro
ports:
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-agentgate} -d ${POSTGRES_DB:-agentgate}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
security_opt:
- no-new-privileges:true
read_only: true
tmpfs:
- /tmp
- /var/run/postgresql
networks:
- agentgate-network
# Redis 7 - Caching and Rate Limiting
redis:
image: redis:7-alpine
container_name: agentgate-redis
restart: always
command: >
redis-server
--requirepass ${REDIS_PASSWORD:?REDIS_PASSWORD must be set}
--appendonly yes
--maxmemory ${REDIS_MAX_MEMORY:-256mb}
--maxmemory-policy allkeys-lru
--save 900 1
--save 300 10
--save 60 10000
volumes:
- redis_data:/data
ports:
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
healthcheck:
test: ["CMD", "redis-cli", "--no-auth-warning", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.25'
memory: 128M
security_opt:
- no-new-privileges:true
read_only: true
tmpfs:
- /tmp
- /data
networks:
- agentgate-network
# AgentGate API Server
server:
build:
context: .
dockerfile: Dockerfile.server
args:
VERSION: ${VERSION:-1.0.0}
BUILD_DATE: ${BUILD_DATE:-2025-02-10}
container_name: agentgate-server
restart: always
environment:
# Database
DATABASE_URL: "postgresql+asyncpg://${POSTGRES_USER:-agentgate}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-agentgate}"
DATABASE_POOL_SIZE: ${DATABASE_POOL_SIZE:-20}
DATABASE_MAX_OVERFLOW: ${DATABASE_MAX_OVERFLOW:-40}
DATABASE_POOL_TIMEOUT: ${DATABASE_POOL_TIMEOUT:-30}
DATABASE_POOL_RECYCLE: ${DATABASE_POOL_RECYCLE:-3600}
# Redis
REDIS_URL: "redis://:${REDIS_PASSWORD}@redis:6379/0"
# Application
AGENTGATE_ENV: production
SECRET_KEY: ${SECRET_KEY:?SECRET_KEY must be set}
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-https://yourdomain.com}
# Server
WORKERS: ${UVICORN_WORKERS:-4}
LOG_LEVEL: ${LOG_LEVEL:-info}
LOG_FORMAT: ${LOG_FORMAT:-json}
# Feature flags
ENABLE_RATE_LIMITING: ${ENABLE_RATE_LIMITING:-true}
ENABLE_CORS: ${ENABLE_CORS:-true}
ENABLE_CSRF: ${ENABLE_CSRF:-true}
# Monitoring
ENABLE_METRICS: ${ENABLE_METRICS:-true}
METRICS_PORT: ${METRICS_PORT:-9090}
AGENTGATE_STATE_DIR: /app/state
ports:
- "127.0.0.1:${SERVER_PORT:-8000}:8000"
- "127.0.0.1:${METRICS_PORT:-9090}:9090"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health').read()"]
interval: 30s
timeout: 10s
start_period: 60s
retries: 3
deploy:
resources:
limits:
cpus: '2.0'
memory: 4G
reservations:
cpus: '0.5'
memory: 1G
replicas: ${SERVER_REPLICAS:-1}
security_opt:
- no-new-privileges:true
networks:
- agentgate-network
volumes:
- server_state:/app/state
# Optional: Mount volumes for logs and backups
# volumes:
# - ./logs:/app/logs
# - ./backups:/app/backups
# Next.js Dashboard (optional in production - may use separate hosting)
dashboard:
build:
context: ./dashboard
dockerfile: Dockerfile
args:
VERSION: ${VERSION:-1.0.0}
container_name: agentgate-dashboard
restart: always
environment:
NEXTAUTH_URL: ${NEXTAUTH_URL:-https://yourdomain.com}
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:?NEXTAUTH_SECRET must be set}
API_URL: ${API_URL:-http://server:8000}
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://yourdomain.com/api}
NODE_ENV: production
ports:
- "${DASHBOARD_PORT:-3000}:3000"
depends_on:
server:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3000/api/health"]
interval: 30s
timeout: 10s
start_period: 60s
retries: 3
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
replicas: ${DASHBOARD_REPLICAS:-1}
security_opt:
- no-new-privileges:true
networks:
- agentgate-network
volumes:
postgres_data:
driver: local
driver_opts:
type: none
device: ${POSTGRES_DATA_PATH:-./data/postgres}
o: bind
redis_data:
driver: local
driver_opts:
type: none
device: ${REDIS_DATA_PATH:-./data/redis}
o: bind
server_state:
driver: local
driver_opts:
type: none
device: ${SERVER_STATE_PATH:-./data/server}
o: bind
networks:
agentgate-network:
driver: bridge
ipam:
config:
- subnet: 172.28.0.0/16