fix(deploy): PORT ชนกับ env ของ Dokploy → ใช้ APP_PORT + บันทึกเคส deploy Error 0s

- docker-compose: substitution ใช้ ${APP_PORT:-30004} แล้วส่งเข้า env PORT ของ container
  เพราะ Dokploy รัน `docker compose` จากโปรเซสที่ตัวเองมี PORT=3000
  → shell env ชนะ .env ทำให้ nginx ฟัง 3000 แต่ Traefik ชี้ 30004 = 503 ทั้งเว็บ
- docker-compose.override.yml: ใช้ APP_PORT ตามกัน
- docs/deploy-dokploy.md: 2 สาเหตุจริงที่เจอบน production
  1) ช่อง Command ของ compose app ค้าง `docker rm -f <id>` → Dokploy ต่อเป็น `docker docker ...`
     → unknown shorthand flag: 'f' in -f → deployment Error ใช้เวลา 0s
     แก้โดยล้าง command = '' (บันทึกคำสั่ง SQL ไว้)
  2) PORT=3000 จาก container ของ Dokploy ทับ .env → 503, healthcheck ผ่านแต่ Traefik DOWN
This commit is contained in:
Bkk1234 committed 2026-11-25 03:45:36 +07:00
1 parent 6cdfbae561
commit 0f5e587c77
3 files changed
+49 -8

No files matched your search

+7 -4
View File
@@ -11,17 +11,20 @@ services:
image: alterflixhub-web:latest
# ห้ามใส่ container_name: ต้องไม่ตายตัว ไม่งั้นหลาย stack บนเครื่องเดียวชนกัน
environment:
# PORT = พอร์ตที่ nginx ฟัง *ใน* คอนเทนเนอร์ (Dokploy ตั้ง PORT=30004)
PORT: ${PORT:-30004}
# PORT = พอร์ตที่ nginx ฟัง *ใน* คอนเทนเนอร์ (Traefik/Dokploy ชี้ 30004)
# ⚠️ อย่าเขียน PORT: ${PORT:-30004} — Dokploy รัน compose จากโปรเซสที่ตัวเองมี env PORT=3000
# shell env ชนะ .env → nginx ฟัง 3000 แต่ Traefik ชี้ 30004 = 503 ทั้งเว็บ (เคสจริง 2026-11-24)
# จึงใช้ชื่อตัวแปรฝั่ง substitution เป็น APP_PORT (ไม่ชนกับ env ของ Dokploy)
PORT: ${APP_PORT:-30004}
# origin ที่เขียนลง canonical/OG/JSON-LD/sitemap/robots ตอน start
PUBLIC_ORIGIN: ${PUBLIC_ORIGIN:-https://alterflixhub.hobbypj.com}
BAKED_ORIGIN: ${BAKED_ORIGIN:-https://alterflixhub.hobbypj.com}
TZ: ${TZ:-Asia/Bangkok}
expose:
- "${PORT:-30004}"
- "${APP_PORT:-30004}"
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:${PORT:-30004}/healthz >/dev/null 2>&1 || exit 1"]
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:${APP_PORT:-30004}/healthz >/dev/null 2>&1 || exit 1"]
interval: 30s
timeout: 4s
start_period: 5s