Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
158 lines (145 loc) · 5.65 KB
/
Copy pathdocker-compose.yml
File metadata and controls
158 lines (145 loc) · 5.65 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
# ใช้งาน:
# docker compose --profile infra up -d # เฉพาะ Postgres/RabbitMQ/RustFS/Mailpit (pnpm infra:up)
# docker compose --profile infra --profile identity up # รัน Service เดียวบน Docker (profile = ชื่อ Service)
# docker compose --profile all up --build # ทุกอย่าง
# ตอนพัฒนาปกติให้รัน infra ใน Docker แล้วรัน Service ด้วย `pnpm --filter @internpath/<name> start:dev`
x-service: &service
env_file:
- path: .env
required: false
restart: unless-stopped
environment: &service-env
# ในคอนเทนเนอร์ต้องเรียก infra ด้วยชื่อ service ไม่ใช่ localhost
RABBITMQ_URL: amqp://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@rabbitmq:5672
S3_ENDPOINT: http://rustfs:9000
SMTP_HOST: mailpit
services:
# ---------- infra ----------
postgres:
image: postgres:16
profiles: ["infra", "all"]
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
interval: 5s
timeout: 3s
retries: 10
rabbitmq:
image: rabbitmq:3.13-management
profiles: ["infra", "all"]
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
ports:
- "127.0.0.1:5672:5672"
- "127.0.0.1:15672:15672"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 10s
timeout: 5s
retries: 10
rustfs:
# แทน MinIO (Docker Hub ไม่มี image ให้ดึงแล้ว) — ปักเวอร์ชัน ไม่ใช้ latest; ใช้เฉพาะ dev/สาธิตในเครื่อง (สาธิตจริงใช้ Cloudflare R2)
# ครั้งแรกรัน `pnpm infra:init-buckets` เพื่อสร้าง bucket
image: rustfs/rustfs:1.0.6
profiles: ["infra", "all"]
restart: unless-stopped
environment:
RUSTFS_ACCESS_KEY: ${S3_ACCESS_KEY}
RUSTFS_SECRET_KEY: ${S3_SECRET_KEY}
ports:
- "127.0.0.1:9000:9000"
- "127.0.0.1:9001:9001"
volumes:
- rustfs-data:/data
mailpit:
image: axllent/mailpit:latest
profiles: ["infra", "all"]
ports:
- "127.0.0.1:1025:1025"
- "127.0.0.1:8025:8025"
# ---------- services (profile = ชื่อ Service) ----------
gateway:
<<: *service
profiles: ["gateway", "all"]
build: { context: ., dockerfile: apps/gateway/Dockerfile }
ports: ["127.0.0.1:3000:3000"]
environment:
<<: *service-env
PORT: "3000"
IDENTITY_URL: http://identity:3001
JOB_URL: http://job:3002
VERIFICATION_URL: http://verification:3003
LIFECYCLE_URL: http://lifecycle:3004
NOTIFICATION_URL: http://notification:3005
identity:
<<: *service
profiles: ["identity", "all"]
build: { context: ., dockerfile: apps/identity/Dockerfile }
ports: ["127.0.0.1:3001:3001"]
environment:
<<: *service-env
PORT: "3001"
IDENTITY_DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/identity_db
IDENTITY_DIRECT_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/identity_db
JOB_URL: http://job:3002
job:
<<: *service
profiles: ["job", "all"]
build: { context: ., dockerfile: apps/job/Dockerfile }
ports: ["127.0.0.1:3002:3002"]
environment:
<<: *service-env
PORT: "3002"
JOB_DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/job_db
JOB_DIRECT_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/job_db
LIFECYCLE_URL: http://lifecycle:3004
verification:
<<: *service
profiles: ["verification", "all"]
build: { context: ., dockerfile: apps/verification/Dockerfile }
ports: ["127.0.0.1:3003:3003"]
environment:
<<: *service-env
PORT: "3003"
VERIFICATION_DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/verification_db
VERIFICATION_DIRECT_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/verification_db
lifecycle:
<<: *service
profiles: ["lifecycle", "all"]
build: { context: ., dockerfile: apps/lifecycle/Dockerfile }
ports: ["127.0.0.1:3004:3004"]
environment:
<<: *service-env
PORT: "3004"
LIFECYCLE_DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/lifecycle_db
LIFECYCLE_DIRECT_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/lifecycle_db
JOB_URL: http://job:3002
notification:
<<: *service
profiles: ["notification", "all"]
build: { context: ., dockerfile: apps/notification/Dockerfile }
ports: ["127.0.0.1:3005:3005"]
environment:
<<: *service-env
PORT: "3005"
IDENTITY_URL: http://identity:3001
NOTIFICATION_DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/notification_db
NOTIFICATION_DIRECT_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/notification_db
web:
<<: *service
profiles: ["web", "all"]
build: { context: ., dockerfile: apps/web/Dockerfile }
ports: ["3100:3100"]
volumes:
postgres-data:
rustfs-data: