Files
track/docker-compose.yml
duxingchen 6bc6531e6a chore: 开发环境 CORS 补齐 uniapp H5 调试来源
原先只放行 PC 管理端(8010),移动端 H5 调试的服务起不来联调。
- 8010 = PC 管理端;5173/8020 = track-uniapp 的 H5 调试服务
- HBuilderX「运行到浏览器」起在 5173,直接跑 vite(按 track-uniapp/vite.config.ts)
  是 8020
- 漏了 uniapp 来源时,浏览器会在 CORS 预检阶段就掐掉请求,
  表现是「点登录没反应」,且控制台只报一句笼统的 404/400
2026-09-15 15:52:09 +08:00

92 lines
3.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================================
# 生产流转管理系统 — 全栈 Docker 热更新开发环境
# 启动: docker compose up -d --build
# 停止: docker compose down
# 日志: docker compose logs -f
# ============================================================
services:
# ============================================================
# PostgreSQL 15 + pgvector
# ============================================================
db:
image: pgvector/pgvector:pg15
container_name: track_db
restart: unless-stopped
environment:
POSTGRES_USER: track
POSTGRES_PASSWORD: track_prod_2026
POSTGRES_DB: track_production
ports:
- "8012:5432"
volumes:
- track_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U track -d track_production"]
interval: 10s
timeout: 5s
retries: 5
# ============================================================
# FastAPI 后端 — --reload 热更新
# ============================================================
backend:
build:
context: ./backend
dockerfile: Dockerfile.dev
container_name: track_backend
restart: unless-stopped
environment:
# 🚀 track 主库用容器名 track_db避免与 MOM 的 inventory_db(别名 db) 在同一网络下 DNS 解析冲突
DATABASE_URL: postgresql+asyncpg://track:track_prod_2026@track_db:5432/track_production
SECRET_KEY: change-me-in-production
DEBUG: "true"
# 8010 = PC 管理端5173/8020 = track-uniapp 的 H5 调试服务
# HBuilderX「运行到浏览器」起在 5173直接跑 vite 按 track-uniapp/vite.config.ts 是 8020
# ⚠️ 漏了 uniapp 的来源时,浏览器会在 CORS 预检阶段就掐掉请求,
# 表现是「点登录没反应」,且控制台只报一句笼统的 404/400。
CORS_ORIGINS: '["http://localhost:8010","https://localhost:8010","http://192.168.9.80:8010","https://192.168.9.80:8010","http://localhost:5173","https://localhost:5173","http://192.168.9.80:5173","https://192.168.9.80:5173","http://localhost:8020","https://localhost:8020","tauri://localhost"]'
# 🚀 MOM 老系统数据库 — 通过容器名解析projects_default 网络内 DNS不再写死 IP
MOM_DB_HOST: inventory_db
MOM_DB_PORT: "5432"
# 🚀 MOM 仓储系统回调 Webhook 验签 Key与 MOM 侧 TRACK_WEBHOOK_KEY 保持一致)
TRACK_WEBHOOK_KEY: 2ce5fedb48fde3fd7e0abf67472a5027b03e9ae6f19cf768
ports:
- "8011:8000"
volumes:
- ./backend:/app
depends_on:
db:
condition: service_healthy
networks:
- default
- mom_net
# ============================================================
# Vite + React 前端 — HMR 热更新
# ============================================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.dev
container_name: track_frontend
restart: unless-stopped
environment:
VITE_API_BASE_URL: /api/v1
ports:
- "8010:1420"
volumes:
- ./frontend:/app
- /app/node_modules # 匿名卷,不覆盖容器里的 node_modules
depends_on:
- backend
networks:
mom_net:
external: true
name: projects_default
volumes:
track_pgdata:
name: track_pgdata