-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdocker-compose-prod-swarm.yml
261 lines (251 loc) · 6.15 KB
/
docker-compose-prod-swarm.yml
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
x-build-args: &build-args
DOCKER_BUILDKIT: 1
GO_VERSION: 1.23
ALPINE_VERSION: latest
# name: trenova-prod
services:
trenova-db:
image: postgres:latest
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_DB: ${DB_NAME:-postgres}
POSTGRES_MULTIPLE_EXTENSIONS: "pg_stat_statements,pg_buffercache"
POSTGRES_INITDB_ARGS: "--data-checksums"
command:
- "postgres"
- "-c"
- "wal_level=logical"
- "-c"
- "shared_preload_libraries=pg_stat_statements,pg_buffercache"
- "-c"
- "pg_stat_statements.track=all"
- "-c"
- "max_replication_slots=5" # Increased for replication
- "-c"
- "max_connections=200" # Doubled
- "-c"
- "shared_buffers=4GB" # Increased for better performance
- "-c"
- "effective_cache_size=12GB" # Increased for better performance
- "-c"
- "maintenance_work_mem=1GB" # Increased for maintenance operations
- "-c"
- "work_mem=16MB" # Increased for complex queries
- "-c"
- "max_parallel_workers=8" # Added for parallel query execution
- "-c"
- "max_parallel_workers_per_gather=4" # Added for parallel query execution
- "-c"
- "effective_io_concurrency=200"
- "-c"
- "min_wal_size=2GB" # Increased for write-heavy workload
- "-c"
- "max_wal_size=8GB" # Increased for write-heavy workload
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
resources:
limits:
memory: 16G
cpus: "4"
reservations:
memory: 8G
# networks:
# - app-network
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-postgres}",
]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s # Allow time for initial startup
trenova-search:
image: getmeili/meilisearch:v1.11.3
ports:
- "7700:7700"
environment:
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY:-masterKey}
- MEILI_NO_ANALYTICS=${MEILI_NO_ANALYTICS:-true}
- MEILI_DB_PATH=${MEILI_DB_PATH:-/data.ms}
- MEILI_ENV=${MEILI_ENV:-development}
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
networks:
- app-network
volumes:
- meilisearch_data:/data.ms
healthcheck:
test: set -o pipefail;curl -fsS http://localhost:7700/health | grep -q '{"status":"available"}'
retries: 3
timeout: 5s
trenova-redis:
image: redis/redis-stack:latest
ports:
- "6379:6379"
environment:
- ALLOW_EMPTY_PASSWORD=yes
command: redis-server --maxmemory 768mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
networks:
- app-network
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
trenova-minio:
image: quay.io/minio/minio
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 # API
- 9001:9001 # Console
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
networks:
- app-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
trenova-api:
image: ${REGISTRY:-localhost}/trenova-api:${TAG:-latest} # Adjust for your registry
expose:
- "3001"
deploy:
mode: replicated
replicas: 3
restart_policy:
condition: on-failure
resources:
limits:
memory: 2G
cpus: "2"
reservations:
memory: 1G
environment:
- APP_ENV=production
- GOMAXPROCS=2
- GO_MAX_THREADS=100
depends_on:
- trenova-haproxy
- trenova-caddy
- trenova-db
- trenova-redis
- trenova-search
- trenova-minio
networks:
- app-network
# restart: unless-stopped
trenova-client:
image: ${REGISTRY:-localhost}/trenova-client:${TAG:-latest} # Adjust for your registry
expose:
- "5173"
networks:
- app-network
depends_on:
- trenova-api
environment:
- VITE_API_URL=/api/v1
# restart: unless-stopped
deploy:
mode: replicated
replicas: 2
resources:
limits:
memory: 1G
cpus: "1"
reservations:
memory: 512M
trenova-haproxy:
image: haproxy:latest
ports:
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
networks:
- app-network
trenova-caddy:
image: ${REGISTRY:-localhost}/trenova-caddy:${TAG:-latest} # Adjust for your registry
expose:
- "80"
- "443"
volumes:
- caddy_data:/data
- caddy_config:/config
- ./logs/caddy:/var/log/caddy
environment:
- ACME_AGREE=true
networks:
- app-network
depends_on:
- trenova-api
- trenova-haproxy
# restart: unless-stopped
deploy:
mode: replicated
replicas: 2
resources:
limits:
memory: 512M
cpus: "1"
reservations:
memory: 256M
volumes:
pg_data:
driver: local
driver_opts:
type: "none"
o: "bind"
device: "/mnt/fast-disk/postgresql"
redis_data:
driver: local
minio_data:
driver: local
meilisearch_data:
driver: local
caddy_data:
driver: local
caddy_config:
driver: local
networks:
app-network:
driver: overlay
attachable: true