Repository navigation
Expand file tree
/
Copy pathcompose.yaml
More file actions
230 lines (216 loc) · 6.76 KB
/
Copy pathcompose.yaml
File metadata and controls
230 lines (216 loc) · 6.76 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
name: ${COMPOSE_PROJECT_NAME:-loanhub}
x-backend: &backend
image: ${LOANHUB_BACKEND_IMAGE:-loanhub-backend}:${LOANHUB_IMAGE_TAG:-local}
build:
context: ./apps/backend
dockerfile: Dockerfile
x-backend-environment: &backend-environment
ENVIRONMENT: ${ENVIRONMENT:-production}
APP_TIMEZONE: ${APP_TIMEZONE:-Africa/Maseru}
PUBLIC_APP_URL: ${PUBLIC_APP_URL:-https://loanhub.co.ls}
CORS_ORIGINS: ${CORS_ORIGINS:-https://loanhub.co.ls}
DB_HOST: db
DB_PORT: "5432"
DB_NAME: ${DB_NAME:-loanhub}
DB_USER: ${DB_USER:-loanhub}
DB_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env.production}
REDIS_URL: redis://redis:6379/0
JWT_PRIVATE_KEY_PATH: /app/secrets/jwt_private.pem
JWT_PUBLIC_KEY_PATH: /app/secrets/jwt_public.pem
FILE_STORAGE_PATH: /app/media/uploads
RUN_MIGRATIONS: "false"
services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: ${DB_NAME:-loanhub}
POSTGRES_USER: ${DB_USER:-loanhub}
POSTGRES_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env.production}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-loanhub} -d ${DB_NAME:-loanhub}"]
interval: 10s
timeout: 5s
retries: 12
start_period: 10s
networks: [loanhub]
redis:
image: redis:7-alpine
restart: unless-stopped
command: ["redis-server", "--appendonly", "yes", "--maxmemory-policy", "allkeys-lru"]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 20
networks: [loanhub]
db-role-bootstrap:
image: postgres:16-alpine
restart: "no"
environment:
DB_NAME: ${DB_NAME:-loanhub}
DB_USER: ${DB_USER:-loanhub}
DB_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env.production}
DB_RUNTIME_USER: ${DB_RUNTIME_USER:-loanhub_app}
DB_RUNTIME_PASSWORD: ${DB_RUNTIME_PASSWORD:?Set DB_RUNTIME_PASSWORD in .env.production}
command: ["/bin/sh", "/loanhub-scripts/ensure_database_runtime_role.sh"]
depends_on:
db:
condition: service_healthy
volumes:
- ./scripts:/loanhub-scripts:ro
networks: [loanhub]
migrate:
<<: *backend
restart: "no"
env_file: ${LOANHUB_ENV_FILE:-.env.production}
environment:
<<: *backend-environment
command: ["alembic", "upgrade", "head"]
depends_on:
db-role-bootstrap:
condition: service_completed_successfully
volumes:
- ./secrets:/app/secrets:ro
networks: [loanhub]
backend:
<<: *backend
restart: unless-stopped
env_file: ${LOANHUB_ENV_FILE:-.env.production}
environment:
<<: *backend-environment
DB_USER: ${DB_RUNTIME_USER:-loanhub_app}
DB_PASSWORD: ${DB_RUNTIME_PASSWORD:?Set DB_RUNTIME_PASSWORD in .env.production}
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
LOANHUB_RUST_COMPUTE_URL: ${LOANHUB_RUST_COMPUTE_URL:-}
LOANHUB_GO_WORKER_URL: ${LOANHUB_GO_WORKER_URL:-}
LOANHUB_JAVA_WORKER_URL: ${LOANHUB_JAVA_WORKER_URL:-}
depends_on:
migrate:
condition: service_completed_successfully
redis:
condition: service_healthy
volumes:
- ./secrets:/app/secrets:ro
- loanhub_files:/app/media
ports:
- "${BACKEND_BIND:-127.0.0.1}:${BACKEND_PORT:-8000}:8000"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health/ready', timeout=3)"]
interval: 15s
timeout: 5s
retries: 12
start_period: 45s
networks: [loanhub]
maintenance:
<<: *backend
restart: unless-stopped
env_file: ${LOANHUB_ENV_FILE:-.env.production}
environment:
<<: *backend-environment
DB_USER: ${DB_RUNTIME_USER:-loanhub_app}
DB_PASSWORD: ${DB_RUNTIME_PASSWORD:?Set DB_RUNTIME_PASSWORD in .env.production}
command: ["python", "docker/maintenance.py"]
healthcheck:
test: ["CMD", "python", "-c", "import os,time; p='/tmp/loanhub-maintenance-heartbeat'; assert os.path.isfile(p) and time.time()-os.path.getmtime(p) < 900, 'Maintenance heartbeat is missing or stale'"]
interval: 30s
timeout: 5s
retries: 3
start_period: 180s
depends_on:
backend:
condition: service_healthy
volumes:
- ./secrets:/app/secrets:ro
- loanhub_files:/app/media
networks: [loanhub]
rust-compute:
profiles: ["workers"]
image: ${LOANHUB_RUST_COMPUTE_IMAGE:-loanhub-rust-compute}:${LOANHUB_IMAGE_TAG:-local}
build:
context: ./services
dockerfile: compute-rust/Dockerfile
restart: unless-stopped
environment:
LOANHUB_RUST_COMPUTE_ADDR: 0.0.0.0:8082
expose:
- "8082"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8082/health/ready"]
interval: 15s
timeout: 5s
retries: 8
start_period: 10s
networks: [loanhub]
go-worker:
profiles: ["workers"]
image: ${LOANHUB_GO_WORKER_IMAGE:-loanhub-go-worker}:${LOANHUB_IMAGE_TAG:-local}
build:
context: ./services/worker-go
restart: unless-stopped
environment:
LOANHUB_GO_WORKER_ADDR: :8081
LOANHUB_GO_HTTP_CONCURRENCY: ${LOANHUB_GO_HTTP_CONCURRENCY:-16}
LOANHUB_GO_PUSH_CONCURRENCY: ${LOANHUB_GO_PUSH_CONCURRENCY:-32}
expose:
- "8081"
healthcheck:
test: ["CMD", "/loanhub-go-worker", "--healthcheck"]
interval: 15s
timeout: 5s
retries: 8
start_period: 10s
networks: [loanhub]
java-worker:
profiles: ["workers"]
image: ${LOANHUB_JAVA_WORKER_IMAGE:-loanhub-java-worker}:${LOANHUB_IMAGE_TAG:-local}
build:
context: ./services/worker-java
restart: unless-stopped
environment:
LOANHUB_JAVA_WORKER_PORT: "8083"
expose:
- "8083"
healthcheck:
test: ["CMD", "java", "-jar", "/app/worker-java.jar", "--healthcheck"]
interval: 15s
timeout: 5s
retries: 8
start_period: 15s
networks: [loanhub]
frontend:
image: ${LOANHUB_FRONTEND_IMAGE:-loanhub-frontend}:${LOANHUB_IMAGE_TAG:-local}
build:
context: ./apps/frontend
dockerfile: Dockerfile
args:
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-https://api.loanhub.co.ls/api/v1}
restart: unless-stopped
environment:
NODE_ENV: production
NEXT_TELEMETRY_DISABLED: "1"
PORT: "3000"
HOSTNAME: 0.0.0.0
depends_on:
backend:
condition: service_healthy
ports:
- "${FRONTEND_BIND:-127.0.0.1}:${FRONTEND_PORT:-3000}:3000"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/"]
interval: 15s
timeout: 5s
retries: 12
start_period: 45s
networks: [loanhub]
networks:
loanhub:
driver: bridge
volumes:
postgres_data:
redis_data:
loanhub_files: