-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
122 lines (116 loc) · 4.25 KB
/
Copy pathdocker-compose.yml
File metadata and controls
122 lines (116 loc) · 4.25 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
# ============================================================================
# Learnault API — Local Development Stack
#
# One command starts a healthy stack (API + wallet worker + PostgreSQL + Redis):
# docker compose up -d --build
#
# The API container applies migrations and seeds deterministic fixtures on
# boot (see docker/entrypoint-dev-api.sh). The worker drains the idempotent
# wallet-provisioning outbox (see src/workers/wallet-provisioning.worker.ts).
#
# Useful commands:
# docker compose ps → service status + health
# docker compose logs -f → follow logs (all services)
# docker compose down → stop the stack (keeps data volumes)
# docker compose down -v → stop and delete data volumes (project-scoped reset)
# pnpm stack:smoke → validate config + run the smoke test
#
# Docs: docs/DEVELOPMENT_STACK.md
# ============================================================================
name: learnault-dev
services:
# --------------------------------------------------------------------------
# PostgreSQL — primary datastore
# --------------------------------------------------------------------------
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-learnault}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-learnault}
POSTGRES_DB: ${POSTGRES_DB:-learnault_dev}
ports:
- '${POSTGRES_PORT:-5432}:5432'
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-learnault} -d ${POSTGRES_DB:-learnault_dev}']
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
# --------------------------------------------------------------------------
# Redis — cache/queue (reserved for upcoming queue-backed work)
# --------------------------------------------------------------------------
redis:
image: redis:7-alpine
restart: unless-stopped
ports:
- '${REDIS_PORT:-6379}:6379'
volumes:
- redisdata:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 5s
retries: 10
# --------------------------------------------------------------------------
# API — Express server (nodemon, hot reload)
# --------------------------------------------------------------------------
api:
build:
context: .
dockerfile: docker/Dockerfile.dev
restart: unless-stopped
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
environment:
NODE_ENV: development
PORT: 5000
DATABASE_URL: postgresql://${POSTGRES_USER:-learnault}:${POSTGRES_PASSWORD:-learnault}@db:5432/${POSTGRES_DB:-learnault_dev}?schema=public
REDIS_URL: redis://redis:6379
JWT_SECRET: ${JWT_SECRET:-dev-only-secret-change-me}
JWT_ISSUER: ${JWT_ISSUER:-learnault-api}
JWT_AUDIENCE: ${JWT_AUDIENCE:-learnault-clients}
RUN_MIGRATIONS: 'true'
RUN_SEED: 'true'
ports:
- '${API_PORT:-5000}:5000'
volumes:
# Bind-mount source for hot reload; keep the image's node_modules
- .:/app
- /app/node_modules
healthcheck:
test: ['CMD', 'node', '-e', "fetch('http://localhost:5000/health/live').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
stop_grace_period: 30s
# --------------------------------------------------------------------------
# Worker — drains the wallet-provisioning outbox
# --------------------------------------------------------------------------
worker:
build:
context: .
dockerfile: docker/Dockerfile.dev
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
NODE_ENV: development
DATABASE_URL: postgresql://${POSTGRES_USER:-learnault}:${POSTGRES_PASSWORD:-learnault}@db:5432/${POSTGRES_DB:-learnault_dev}?schema=public
RUN_MIGRATIONS: 'true'
WORKER_POLL_INTERVAL_MS: ${WORKER_POLL_INTERVAL_MS:-5000}
volumes:
- .:/app
- /app/node_modules
command: ['./docker/entrypoint-dev-worker.sh']
stop_grace_period: 30s
volumes:
pgdata:
redisdata: