251119:1200 set backend

This commit is contained in:
2025-11-19 11:57:46 +07:00
parent a3e25d6c52
commit 2b36e5554b
29 changed files with 7719 additions and 204 deletions

View File

@@ -0,0 +1,62 @@
# File: docker-compose.yml
# บันทึกการแก้ไข: (สร้างไฟล์)
# (สำคัญ: ไฟล์นี้จะถูก import หรือคัดลอกไปใส่ใน UI ของ QNAP Container Station)
version: '3.8'
services:
# ---------------------------------
# Service 1: Backend (NestJS)
# (Req 2.3)
# ---------------------------------
backend:
build:
context: ./backend # (สมมติว่า Dockerfile อยู่ในโฟลเดอร์ backend)
dockerfile: Dockerfile
image: lcbp3-backend:1.3.0 # (ตั้งชื่อ Image)
container_name: lcbp3-backend
restart: unless-stopped
# (สำคัญ) กำหนด Environment Variables ที่นี่ (ห้ามใช้ .env)
# (Req 6.5, 2.1)
environment:
# --- App Config ---
- PORT=3000
- NODE_ENV=production
# --- Database (Req 2.4) ---
# (ชี้ไปที่ Service 'mariadb' ใน Network 'lcbp3')
- DATABASE_HOST=mariadb
- DATABASE_PORT=3306
- DATABASE_USER=your_db_user # (ต้องเปลี่ยน)
- DATABASE_PASSWORD=your_db_pass # (ต้องเปลี่ยน)
- DATABASE_NAME=lcbp3_dms
# --- Security (JWT) (Req 6.5) ---
- JWT_SECRET=YOUR_VERY_STRONG_JWT_SECRET_KEY # (ต้องเปลี่ยน)
- JWT_EXPIRATION_TIME=3600s # (เช่น 1 ชั่วโมง)
# --- Phase 4 Services ---
- ELASTICSEARCH_URL=http://elasticsearch:9200 # (ชี้ไปที่ Service ES ถ้ามี)
- N8N_WEBHOOK_URL=http://n8n:5678/webhook/your-webhook-id # (ชี้ไปที่ N8N)
# (สำคัญ) เชื่อมต่อ Network กลาง (Req 2.1)
networks:
- lcbp3
# (Deploy) ตั้งค่า Health Check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/v1/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s # (รอให้ App เริ่มก่อน)
# ---------------------------------
# Network กลาง (Req 2.1)
# (ต้องสร้าง Network นี้ไว้ก่อนใน QNAP หรือสร้างพร้อมกัน)
# ---------------------------------
networks:
lcbp3:
external: true # (ถ้าสร้างไว้แล้ว)
# name: lcbp3 # (ถ้าต้องการให้ Compose สร้าง)