fix(deploy): Dokploy-safe compose split + resilient db healthcheck

- docker-compose.yml is now the server form: no published host ports
  (expose only), so a port already taken on the host can no longer stop
  the stack; local ports moved to docker-compose.override.yml, which
  Dokploy never reads
- db healthcheck probes TCP 127.0.0.1 instead of the unix socket and
  allows start_period 30s / 12 retries while initdb finishes
- api start_period 20s
This commit is contained in:
Bkk1234 committed 2026-11-23 11:35:09 +07:00
1 parent 1b6c56b47c
commit b676889816
4 files changed
+46 -15

No files matched your search

+12
View File
@@ -85,6 +85,18 @@ curl -s http://127.0.0.1:8000/api/v1/health # database.connected = tr
- ไฟล์ static ถูก COPY เข้า image — แก้หน้าเว็บแล้วต้อง `docker compose up -d --build`
- ฐานข้อมูลอยู่ใน named volume `pgdata` · ล้างทั้งหมด: `docker compose down -v`
### deploy บนเซิร์ฟเวอร์ (Dokploy)
| ไฟล์ | ใช้ตอนไหน | มี host port ไหม |
|---|---|---|
| `docker-compose.yml` | Dokploy รัน `-f docker-compose.yml` | ไม่มี (ใช้ `expose`) — Traefik คุยผ่าน network ภายใน |
| `docker-compose.override.yml` | `docker compose up` บนเครื่องตัวเอง (merge อัตโนมัติ) | มี (`*_HOST_PORT` จาก `.env`) |
- ตั้ง env ใน Dokploy: `WEB_CONTAINER_PORT=8080`, `API_CONTAINER_PORT=8000`, `DB_PASSWORD=<รหัสจริง>`
- Domains row: Service Name = `web`, Container Port = ค่าของ `WEB_CONTAINER_PORT`
- ถ้า db ขึ้น unhealthy หลัง redeploy ให้ **ลบ volume `pgdata` เก่า** ก่อน (ข้อมูลจากรอบที่พังแล้ว init ค้าง)
- ฐานข้อมูลไม่ต้อง publish ออกนอกเลยบนเซิร์ฟเวอร์
## ไฟล์