-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
190 lines (183 loc) · 7.29 KB
/
docker-compose.yml
File metadata and controls
190 lines (183 loc) · 7.29 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
# Aframp Backend — local development stack
#
# Services:
# postgres — PostgreSQL 16 with persistent volume
# redis — Redis 7 with persistent volume
# app — Aframp backend (built from source)
# prometheus — Prometheus metrics collection and alert evaluation
# alertmanager — Alert routing, deduplication, and notification dispatch
#
# Usage:
# docker compose up --build # first run
# docker compose up # subsequent runs
# docker compose down -v # stop and remove volumes
# =============================================================================
services:
# ---------------------------------------------------------------------------
# PostgreSQL
# ---------------------------------------------------------------------------
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-aframp}
POSTGRES_USER: ${POSTGRES_USER:-aframp}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "${POSTGRES_PORT:-5432}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-aframp} -d ${POSTGRES_DB:-aframp}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# ---------------------------------------------------------------------------
# Redis
# ---------------------------------------------------------------------------
redis:
image: redis:7-alpine
restart: unless-stopped
command: >
redis-server
--requirepass ${REDIS_PASSWORD:?REDIS_PASSWORD is required}
--maxmemory 256mb
--maxmemory-policy allkeys-lru
--save 60 1
--appendonly yes
volumes:
- redis_data:/data
ports:
- "${REDIS_PORT:-6379}:6379"
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# ---------------------------------------------------------------------------
# Application
# ---------------------------------------------------------------------------
app:
build:
context: .
dockerfile: Dockerfile
target: runtime
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "${SERVER_PORT:-8000}:8000"
environment:
SERVER_HOST: "0.0.0.0"
SERVER_PORT: "${SERVER_PORT:-8000}"
DATABASE_URL: "postgres://${POSTGRES_USER:-aframp}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-aframp}"
DB_HOST: "postgres"
DB_PORT: "5432"
DB_MAX_CONNECTIONS: "${DB_MAX_CONNECTIONS:-20}"
DB_MIN_CONNECTIONS: "${DB_MIN_CONNECTIONS:-5}"
DB_CONNECTION_TIMEOUT: "${DB_CONNECTION_TIMEOUT:-30}"
DB_IDLE_TIMEOUT: "${DB_IDLE_TIMEOUT:-600}"
DB_MAX_LIFETIME: "${DB_MAX_LIFETIME:-1800}"
REDIS_URL: "redis://:${REDIS_PASSWORD}@redis:6379"
REDIS_MAX_CONNECTIONS: "${REDIS_MAX_CONNECTIONS:-20}"
REDIS_MIN_IDLE: "${REDIS_MIN_IDLE:-5}"
APP_ENV: "${APP_ENV:-development}"
LOG_LEVEL: "${LOG_LEVEL:-INFO}"
LOG_FORMAT: "${LOG_FORMAT:-json}"
CORS_ALLOWED_ORIGINS: "${CORS_ALLOWED_ORIGINS:-http://localhost:3000}"
STELLAR_NETWORK: "${STELLAR_NETWORK:-testnet}"
STELLAR_HORIZON_URL: "${STELLAR_HORIZON_URL:-https://horizon-testnet.stellar.org}"
STELLAR_REQUEST_TIMEOUT: "${STELLAR_REQUEST_TIMEOUT:-15}"
STELLAR_MAX_RETRIES: "${STELLAR_MAX_RETRIES:-3}"
SYSTEM_WALLET_ADDRESS: "${SYSTEM_WALLET_ADDRESS}"
SYSTEM_WALLET_SECRET: "${SYSTEM_WALLET_SECRET}"
CNGN_ISSUER_ADDRESS: "${CNGN_ISSUER_ADDRESS}"
PAYSTACK_SECRET_KEY: "${PAYSTACK_SECRET_KEY}"
PAYSTACK_PUBLIC_KEY: "${PAYSTACK_PUBLIC_KEY}"
FLUTTERWAVE_SECRET_KEY: "${FLUTTERWAVE_SECRET_KEY}"
FLUTTERWAVE_PUBLIC_KEY: "${FLUTTERWAVE_PUBLIC_KEY}"
MPESA_CONSUMER_KEY: "${MPESA_CONSUMER_KEY}"
MPESA_CONSUMER_SECRET: "${MPESA_CONSUMER_SECRET}"
MPESA_PASSKEY: "${MPESA_PASSKEY}"
MPESA_SHORTCODE: "${MPESA_SHORTCODE}"
JWT_SECRET: "${JWT_SECRET:?JWT_SECRET is required}"
OTEL_SERVICE_NAME: "${OTEL_SERVICE_NAME:-aframp-backend}"
OTEL_EXPORTER_OTLP_ENDPOINT: "${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4317}"
OTEL_SAMPLING_RATE: "${OTEL_SAMPLING_RATE:-1.0}"
TX_MONITOR_ENABLED: "${TX_MONITOR_ENABLED:-true}"
OFFRAMP_PROCESSOR_ENABLED: "${OFFRAMP_PROCESSOR_ENABLED:-true}"
ONRAMP_PROCESSOR_ENABLED: "${ONRAMP_PROCESSOR_ENABLED:-true}"
BILL_PROCESSOR_ENABLED: "${BILL_PROCESSOR_ENABLED:-true}"
PAYMENT_POLLER_ENABLED: "${PAYMENT_POLLER_ENABLED:-true}"
WEBHOOK_RETRY_ENABLED: "${WEBHOOK_RETRY_ENABLED:-true}"
RUN_MIGRATIONS: "true"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${SERVER_PORT:-8000}/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 90s
# ---------------------------------------------------------------------------
# Prometheus — metrics collection and alert rule evaluation
# ---------------------------------------------------------------------------
prometheus:
image: prom/prometheus:v2.51.0
restart: unless-stopped
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention.time=15d"
- "--web.enable-lifecycle"
- "--web.enable-admin-api"
volumes:
- ./monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./monitoring/prometheus/rules:/etc/prometheus/rules:ro
- prometheus_data:/prometheus
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
depends_on:
app:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
interval: 15s
timeout: 5s
retries: 3
# ---------------------------------------------------------------------------
# Alertmanager — alert routing, deduplication, and notification dispatch
# ---------------------------------------------------------------------------
alertmanager:
image: prom/alertmanager:v0.27.0
restart: unless-stopped
command:
- "--config.file=/etc/alertmanager/alertmanager.yml"
- "--storage.path=/alertmanager"
# Disable clustering for single-node development setup
- "--cluster.listen-address="
volumes:
- ./monitoring/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
- alertmanager_data:/alertmanager
ports:
- "${ALERTMANAGER_PORT:-9093}:9093"
environment:
ALERTMANAGER_ONCALL_SLACK_WEBHOOK: "${ALERTMANAGER_ONCALL_SLACK_WEBHOOK:-}"
ALERTMANAGER_ENGINEERING_SLACK_WEBHOOK: "${ALERTMANAGER_ENGINEERING_SLACK_WEBHOOK:-}"
ALERTMANAGER_ONCALL_CHANNEL: "${ALERTMANAGER_ONCALL_CHANNEL:-#oncall}"
ALERTMANAGER_ENGINEERING_CHANNEL: "${ALERTMANAGER_ENGINEERING_CHANNEL:-#engineering-alerts}"
depends_on:
- prometheus
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9093/-/healthy"]
interval: 15s
timeout: 5s
retries: 3
volumes:
postgres_data:
redis_data:
prometheus_data:
alertmanager_data: