-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.dev.yaml
More file actions
226 lines (216 loc) · 8.17 KB
/
Copy pathcompose.dev.yaml
File metadata and controls
226 lines (216 loc) · 8.17 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
services:
# ── MongoDB ────────────────────────────────────────────────────────────────
mongo:
image: mongo:7
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
# ── mongo-express ─────────────────────────────────────────────────────────
mongo-express:
image: mongo-express:latest
ports:
- "8081:8081"
environment:
ME_CONFIG_MONGODB_URL: mongodb://mongo:27017/
ME_CONFIG_BASICAUTH: "false"
depends_on:
mongo:
condition: service_healthy
# ── Redis ──────────────────────────────────────────────────────────────────
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# ── PostgreSQL ─────────────────────────────────────────────────────────────
postgres:
image: postgres:15-alpine
environment:
POSTGRES_USER: fintrack
POSTGRES_PASSWORD: fintrack
POSTGRES_DB: fintrack
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U fintrack -d fintrack"]
interval: 10s
timeout: 5s
retries: 5
# ── pgAdmin ────────────────────────────────────────────────────────────────
pgadmin:
image: dpage/pgadmin4:latest
environment:
PGADMIN_DEFAULT_EMAIL: admin@fintrack.dev
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5050:80"
volumes:
- pgadmin_data:/var/lib/pgadmin
depends_on:
postgres:
condition: service_healthy
# ── Init (Dependency Installation & Preparation) ───────────────────────────
init:
image: node:22-alpine
working_dir: /app
volumes:
- .:/app
- root_node_modules:/app/node_modules
- api_node_modules:/app/apps/api/node_modules
- bot_node_modules:/app/apps/bot/node_modules
- web_node_modules:/app/apps/web/node_modules
- types_node_modules:/app/packages/types/node_modules
- corepack_cache:/corepack
environment:
- COREPACK_HOME=/corepack
# pnpm install is used instead of frozen-lockfile to benefit from caching in named volumes.
command: sh -c "corepack enable && pnpm install && pnpm --filter @fintrack/types build && pnpm --filter fintrack-api run prisma:generate"
# ── API ────────────────────────────────────────────────────────────────────
api:
image: node:22-alpine
working_dir: /app/apps/api
volumes:
- .:/app
- root_node_modules:/app/node_modules
- api_node_modules:/app/apps/api/node_modules
- types_node_modules:/app/packages/types/node_modules
- corepack_cache:/corepack
ports:
- "8000:8000"
- "5555:5555" # Expose Prisma Studio port
environment:
- NODE_ENV=development
- DX_SERVICE_NAME=api
- COREPACK_HOME=/corepack
# Override hosts: localhost (in .env) → internal compose service names.
- DATABASE_URL=postgresql://fintrack:fintrack@postgres:5432/fintrack?schema=public
- DIRECT_URL=postgresql://fintrack:fintrack@postgres:5432/fintrack?schema=public
- REDIS_URL=redis://redis:6379
- MONGO_URL=mongodb://mongo:27017/fintrack
env_file:
- apps/api/.env
# Apply any pending migrations before starting the dev server.
# `migrate deploy` is safe to run repeatedly — it only applies new migrations.
command: sh -c "corepack enable && pnpm run prisma:migrate:deploy && pnpm run dev"
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:8000/api/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 40s
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
mongo:
condition: service_healthy
init:
condition: service_completed_successfully
# ── Runner (CLI Tooling) ───────────────────────────────────────────────────
# Utility service for one-off commands (lint, test, seed, scripts).
# Use: docker compose -f compose.dev.yaml run --rm runner <command>
runner:
build:
context: .
dockerfile: scripts/Dockerfile.runner
working_dir: /app
profiles: ["tools"] # Prevent starting automatically with 'up'
volumes:
- .:/app
- root_node_modules:/app/node_modules
- api_node_modules:/app/apps/api/node_modules
- bot_node_modules:/app/apps/bot/node_modules
- web_node_modules:/app/apps/web/node_modules
- types_node_modules:/app/packages/types/node_modules
environment:
- DX_SERVICE_NAME=runner
# Override hosts: localhost (in .env) → internal compose service names.
- DATABASE_URL=postgresql://fintrack:fintrack@postgres:5432/fintrack?schema=public
- DIRECT_URL=postgresql://fintrack:fintrack@postgres:5432/fintrack?schema=public
- REDIS_URL=redis://redis:6379
- MONGO_URL=mongodb://mongo:27017/fintrack
env_file:
- apps/api/.env
# Interactive shell by default
command: bash
# ── Telegram bot ───────────────────────────────────────────────────────────
bot:
image: node:22-alpine
working_dir: /app/apps/bot
volumes:
- .:/app
- root_node_modules:/app/node_modules
- bot_node_modules:/app/apps/bot/node_modules
- types_node_modules:/app/packages/types/node_modules
- corepack_cache:/corepack
environment:
- NODE_ENV=development
- DX_SERVICE_NAME=bot
- COREPACK_HOME=/corepack
- API_URL=http://api:8000/api
- REDIS_URL=redis://redis:6379
env_file:
- apps/bot/.env
command: sh -c "corepack enable && pnpm run dev"
depends_on:
redis:
condition: service_healthy
init:
condition: service_completed_successfully
api:
condition: service_healthy
# ── Next.js web ────────────────────────────────────────────────────────────
web:
image: node:22-alpine
working_dir: /app/apps/web
volumes:
- .:/app
- root_node_modules:/app/node_modules
- web_node_modules:/app/apps/web/node_modules
- types_node_modules:/app/packages/types/node_modules
- web_next:/app/apps/web/.next
- corepack_cache:/corepack
ports:
- "5173:5173"
environment:
- NODE_ENV=development
- NEXT_PUBLIC_API_URL=http://localhost:8000/api
- NEXT_PUBLIC_TELEGRAM_BOT_ID=${NEXT_PUBLIC_TELEGRAM_BOT_ID:-}
- DX_SERVICE_NAME=web
- COREPACK_HOME=/corepack
- WATCHPACK_POLLING=true
env_file:
- apps/web/.env
command: sh -c "corepack enable && pnpm run dev"
depends_on:
init:
condition: service_completed_successfully
api:
condition: service_healthy
volumes:
postgres_data:
pgadmin_data:
redis_data:
mongo_data:
root_node_modules:
api_node_modules:
bot_node_modules:
web_node_modules:
types_node_modules:
web_next:
corepack_cache: