62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
# ================================================
|
|
# PMS Docker Compose 配置
|
|
# ================================================
|
|
version: '3.8'
|
|
|
|
services:
|
|
# PMS 数据库(可读写)
|
|
postgres-pms:
|
|
image: postgres:15-alpine
|
|
container_name: pms-db
|
|
environment:
|
|
POSTGRES_DB: pms_db
|
|
POSTGRES_USER: pms_user
|
|
POSTGRES_PASSWORD: pms_pass
|
|
ports:
|
|
- "5433:5432"
|
|
volumes:
|
|
- postgres-pms-data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U pms_user -d pms_db"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# 后端服务
|
|
backend:
|
|
build:
|
|
context: .
|
|
dockerfile: backend/Dockerfile
|
|
container_name: pms-backend
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
environment:
|
|
# 连接真实的旧库存数据库
|
|
DATABASE_URL_INVENTORY: postgresql://test:1234@host.docker.internal:5435/inventory_system
|
|
DATABASE_URL_PMS: postgresql://pms_user:pms_pass@postgres-pms:5432/pms_db
|
|
ports:
|
|
- "8001:8001"
|
|
depends_on:
|
|
postgres-pms:
|
|
condition: service_healthy
|
|
volumes:
|
|
# 把宿主机 backend/app/ 映射到容器 /app/app/,与 from app.xxx 匹配
|
|
- ./backend/app:/app/app
|
|
|
|
# 前端服务
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
container_name: pms-frontend
|
|
ports:
|
|
- "5176:5173" # 将内部的 5173 映射到外部的 5176
|
|
depends_on:
|
|
- backend
|
|
volumes:
|
|
- ./frontend:/app # 将外面的 Vue 代码实时映射到容器内(热更新)
|
|
- /app/node_modules # 保护容器内的 node_modules 不被外部覆盖
|
|
|
|
volumes:
|
|
postgres-pms-data:
|