Repository navigation
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
232 lines (224 loc) · 7.98 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
232 lines (224 loc) · 7.98 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
# docker-compose.prod.yml — Production deployment
#
# Usage:
# docker compose -f docker-compose.prod.yml up -d
#
# Secrets (see secrets/ directory and DEPLOYMENT_GUIDE.md "Production Secrets"):
# secrets/jwt_secret.txt — required. Copy from jwt_secret.txt.example.
# secrets/database_url.txt — required only when DB_PROVIDER=postgres.
# Compose still requires the file to exist even
# when unused — `touch secrets/database_url.txt`
# is fine for the default SQLite mode.
# secrets/webhook_encryption_key.txt — required (NODE_ENV=production).
# secrets/rate_limit_ip_hash_salt.txt — required (NODE_ENV=production), 32+ chars.
# secrets/anthropic_api_key.txt — optional. Leave empty if AI payment parsing is unused.
#
# Required non-secret environment variables (set in .env or via shell):
# ALLOWED_ORIGINS — comma-separated CORS origins (e.g. https://finchippay.io)
# DB_PROVIDER — "sqlite" (default) or "postgres"
#
# Docker Content Trust — verify image signatures on pull/build:
# export DOCKER_CONTENT_TRUST=1
# docker compose -f docker-compose.prod.yml pull
# docker compose -f docker-compose.prod.yml build
# Note: this only works for images with published trust data. node, nginx,
# and redis are Docker Official Images and are signed. jaegertracing/all-in-one
# is not — verify before enabling DCT project-wide, or pull it separately
# with DCT disabled. See DEPLOYMENT_GUIDE.md "Docker Content Trust".
secrets:
jwt_secret:
file: ./secrets/jwt_secret.txt
database_url:
file: ./secrets/database_url.txt
webhook_encryption_key:
file: ./secrets/webhook_encryption_key.txt
rate_limit_ip_hash_salt:
file: ./secrets/rate_limit_ip_hash_salt.txt
anthropic_api_key:
file: ./secrets/anthropic_api_key.txt
services:
frontend:
build:
# Repo-root context so the file:../sdk dependency (and the SDK source)
# is inside the build; see frontend/Dockerfile.prod.
context: .
dockerfile: frontend/Dockerfile.prod
ports:
- "80:8080"
environment:
- BACKEND_URL=http://backend:4000
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8080"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
restart: always
# ─── Hardening ────────────────────────────────────────────────────────────
# No "user:" override needed — the nginx-unprivileged base image already
# runs as the non-root "nginx" user (see frontend/Dockerfile.prod).
read_only: true
tmpfs:
- /var/cache/nginx
- /var/run
- /tmp
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
deploy:
resources:
limits:
cpus: "0.5"
memory: "256M"
reservations:
cpus: "0.1"
memory: "64M"
backend:
build:
context: .
dockerfile: backend/Dockerfile.prod
ports:
- "4000:4000"
environment:
- PORT=4000
- NODE_ENV=production
- STELLAR_NETWORK=mainnet
- HORIZON_URL=https://horizon.stellar.org
- TURRETS_EVALUATION_INTERVAL_MS=60000
- ALLOWED_ORIGINS=${ALLOWED_ORIGINS}
- REDIS_URL=redis://redis:6379
# Database (defaults to SQLite if unset)
- DB_PROVIDER=${DB_PROVIDER:-sqlite}
# Secrets — resolved from /run/secrets/* at startup by
# backend/src/config/dockerSecrets.js. An explicit non-_FILE env var
# (e.g. JWT_SECRET) always takes precedence if also set.
- JWT_SECRET_FILE=/run/secrets/jwt_secret
- DATABASE_URL_FILE=/run/secrets/database_url
- WEBHOOK_ENCRYPTION_KEY_FILE=/run/secrets/webhook_encryption_key
- RATE_LIMIT_IP_HASH_SALT_FILE=/run/secrets/rate_limit_ip_hash_salt
- ANTHROPIC_API_KEY_FILE=/run/secrets/anthropic_api_key
# Optional: set to enable distributed tracing via OTLP
# - OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318
secrets:
- jwt_secret
- database_url
- webhook_encryption_key
- rate_limit_ip_hash_salt
- anthropic_api_key
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:4000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: always
# ─── Hardening ────────────────────────────────────────────────────────────
user: "node"
read_only: true
tmpfs:
- /tmp
- /app/.ipfs-cache
volumes:
# Persistent — must survive restarts (SQLite DB, token-metadata cache,
# DB backups). Only actually written to when DB_PROVIDER=sqlite (the
# default) or when a scheduled backup runs.
- backend_data:/app/data
- backend_backups:/app/backups
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
deploy:
resources:
limits:
cpus: "1.0"
memory: "512M"
reservations:
cpus: "0.25"
memory: "256M"
# ─── Redis (rate limiting, caching) ────────────────────────────────────────
redis:
image: redis:7-alpine
ports:
- "127.0.0.1:6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
start_period: 5s
restart: always
# ─── Hardening ────────────────────────────────────────────────────────────
# No "user:" override: the official redis image's entrypoint expects to
# start as root (it does not perform its own privilege drop like the
# postgres/mysql images do), so forcing a non-root UID here without
# verifying it against the actual image is riskier than leaving it
# default. Filesystem and capability hardening still apply.
read_only: true
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
deploy:
resources:
limits:
cpus: "0.5"
memory: "256M"
reservations:
cpus: "0.1"
memory: "64M"
# ─── Jaeger all-in-one (production distributed tracing) ──────────────────────
jaeger:
image: jaegertracing/all-in-one:1.64
ports:
- "127.0.0.1:16686:16686"
- "127.0.0.1:4318:4318"
environment:
- COLLECTOR_OTLP_ENABLED=true
- SPAN_STORAGE_TYPE=badger
- BADGER_EPHEMERAL=false
- BADGER_DIRECTORY_VALUE=/badger/data
- BADGER_DIRECTORY_KEY=/badger/key
volumes:
- jaeger_data:/badger
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:16686"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
restart: always
# ─── Hardening ────────────────────────────────────────────────────────────
# No "user:" override: same rationale as redis above — not verified
# against the actual jaegertracing/all-in-one image in this environment.
read_only: true
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
deploy:
resources:
limits:
cpus: "0.5"
memory: "512M"
reservations:
cpus: "0.1"
memory: "128M"
volumes:
jaeger_data:
redis_data:
backend_data:
backend_backups: