-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
261 lines (250 loc) · 8.09 KB
/
docker-compose.yml
File metadata and controls
261 lines (250 loc) · 8.09 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
# docker-compose.yml
#
# Local development environment for sublime247/mobile-money.
# Starts the app alongside Postgres, PgBouncer, Redis, and ELK stack with live-reload via ts-node.
#
# Usage:
# docker compose up # start everything
# docker compose up -d # start in background
# docker compose down # stop and remove containers
# docker compose down -v # stop and wipe volumes (fresh DB)
services:
# ---------------------------------------------------------------------------
# PostgreSQL
# ---------------------------------------------------------------------------
postgres:
image: postgres:16-alpine
container_name: mobilemoney_postgres
restart: unless-stopped
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: mobilemoney_stellar
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database/schema.sql:/docker-entrypoint-initdb.d/01_schema.sql:ro
- ./database/migrations:/docker-entrypoint-initdb.d/migrations:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user -d mobilemoney_stellar"]
interval: 5s
timeout: 5s
retries: 10
# ---------------------------------------------------------------------------
# PgBouncer Connection Pooler
# ---------------------------------------------------------------------------
pgbouncer:
image: edoburu/pgbouncer:latest
container_name: mobilemoney_pgbouncer
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
DATABASE_URL: postgres://user:password@postgres:5432/mobilemoney_stellar
POOL_MODE: transaction
MAX_CLIENT_CONN: 1000
DEFAULT_POOL_SIZE: 25
MIN_POOL_SIZE: 5
RESERVE_POOL_SIZE: 5
RESERVE_POOL_TIMEOUT: 3
MAX_DB_CONNECTIONS: 100
MAX_USER_CONNECTIONS: 100
SERVER_LIFETIME: 3600
SERVER_IDLE_TIMEOUT: 600
SERVER_CONNECT_TIMEOUT: 15
SERVER_CHECK_QUERY: "select 1"
SERVER_CHECK_DELAY: 30
SERVER_RESET_QUERY: "DISCARD ALL"
CLIENT_IDLE_TIMEOUT: 900
QUERY_TIMEOUT: 0
QUERY_WAIT_TIMEOUT: 120000
LOG_CONNECTIONS: 1
LOG_DISCONNECTIONS: 1
LOG_POOLER_ERRORS: 1
VERBOSE: 1
STATS_PERIOD: 60
DISABLE_STATISTICS: 0
TCP_DEFER_ACCEPT: 1
TCP_KEEPALIVES: 1
AUTH_TYPE: plain
ports:
- "6432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user -h localhost -p 5432 -d mobilemoney_stellar || exit 1"]
interval: 5s
timeout: 5s
retries: 10
# ---------------------------------------------------------------------------
# Redis
# ---------------------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: mobilemoney_redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
# ---------------------------------------------------------------------------
# Datadog Agent
# ---------------------------------------------------------------------------
datadog-agent:
image: gcr.io/datadoghq/agent:latest
container_name: mobilemoney_datadog_agent
environment:
- DD_API_KEY=${DD_API_KEY}
- DD_SITE=datadoghq.com
- DD_APM_ENABLED=true
- DD_APM_NON_LOCAL_TRAFFIC=true
- DD_ENV=development
ports:
- "8126:8126"
# ---------------------------------------------------------------------------
# Elasticsearch
# ---------------------------------------------------------------------------
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.2
container_name: mobilemoney_elasticsearch
restart: unless-stopped
environment:
discovery.type: single-node
xpack.security.enabled: "false"
ES_JAVA_OPTS: -Xms512m -Xmx512m
ports:
- "9200:9200"
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
healthcheck:
test:
[
"CMD-SHELL",
"curl -fsS http://localhost:9200/_cluster/health || exit 1",
]
interval: 15s
timeout: 10s
retries: 20
# ---------------------------------------------------------------------------
# Logstash
# ---------------------------------------------------------------------------
logstash:
image: docker.elastic.co/logstash/logstash:8.12.2
container_name: mobilemoney_logstash
restart: unless-stopped
depends_on:
elasticsearch:
condition: service_healthy
ports:
- "5044:5044"
volumes:
- ./elk/logstash/pipeline:/usr/share/logstash/pipeline:ro
- ./elk/logstash/templates:/usr/share/logstash/templates:ro
# ---------------------------------------------------------------------------
# Filebeat
# ---------------------------------------------------------------------------
filebeat:
image: docker.elastic.co/beats/filebeat:8.12.2
container_name: mobilemoney_filebeat
user: root
restart: unless-stopped
depends_on:
logstash:
condition: service_started
command: ["filebeat", "-e", "--strict.perms=false"]
volumes:
- ./elk/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
- app_logs:/var/log/mobile-money:ro
# ---------------------------------------------------------------------------
# Kibana
# ---------------------------------------------------------------------------
kibana:
image: docker.elastic.co/kibana/kibana:8.12.2
container_name: mobilemoney_kibana
restart: unless-stopped
environment:
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
XPACK_SECURITY_ENABLED: "false"
depends_on:
elasticsearch:
condition: service_healthy
ports:
- "5601:5601"
volumes:
- kibana_data:/usr/share/kibana/data
healthcheck:
test:
["CMD-SHELL", "curl -fsS http://localhost:5601/api/status || exit 1"]
interval: 20s
timeout: 10s
retries: 20
# ---------------------------------------------------------------------------
# Kibana Importer
# ---------------------------------------------------------------------------
kibana-importer:
image: curlimages/curl:8.7.1
container_name: mobilemoney_kibana_importer
restart: "no"
depends_on:
kibana:
condition: service_healthy
entrypoint: ["/bin/sh", "/scripts/import-kibana.sh"]
volumes:
- ./elk/scripts/import-kibana.sh:/scripts/import-kibana.sh:ro
- ./elk/kibana/mobile-money-dashboard.ndjson:/usr/share/kibana/import/mobile-money-dashboard.ndjson:ro
# ---------------------------------------------------------------------------
# Application (live reload via ts-node-dev)
# ---------------------------------------------------------------------------
app:
build:
context: .
dockerfile: Dockerfile.dev
container_name: mobilemoney_app
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
pgbouncer:
condition: service_healthy
redis:
condition: service_healthy
elasticsearch:
condition: service_healthy
logstash:
condition: service_started
env_file:
- .env
environment:
# Connect through PgBouncer instead of direct Postgres
DATABASE_URL: postgresql://user:password@pgbouncer:5432/mobilemoney_stellar
REDIS_URL: redis://redis:6379
LOG_FILE_PATH: /var/log/mobile-money/app.log
ELASTICSEARCH_URL: http://elasticsearch:9200
KIBANA_URL: http://kibana:5601
DD_AGENT_HOST: datadog-agent
DD_ENV: development
DD_SERVICE: mobile-money
DD_VERSION: 1.0.0
ports:
- "${PORT:-3000}:3000"
volumes:
- .:/app
- /app/node_modules
- app_logs:/var/log/mobile-money
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
volumes:
postgres_data:
redis_data:
app_logs:
elasticsearch_data:
kibana_data: