52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
version: '3.8'
|
||
|
||
services:
|
||
# --- 数据库服务 ---
|
||
db:
|
||
image: postgres:15-alpine
|
||
container_name: inventory_db
|
||
restart: always
|
||
environment:
|
||
POSTGRES_USER: test
|
||
POSTGRES_PASSWORD: 1234
|
||
POSTGRES_DB: inventory_system
|
||
volumes:
|
||
# 数据持久化
|
||
- ./pgdata_docker:/var/lib/postgresql/data
|
||
ports:
|
||
- "5434:5432"
|
||
|
||
# --- 后端 Flask 服务 ---
|
||
backend:
|
||
build:
|
||
context: ./inventory-backend # 【修改】指向你的新后端目录
|
||
container_name: inventory_api
|
||
restart: always
|
||
ports:
|
||
- "8000:8000"
|
||
volumes:
|
||
- ./inventory-backend:/app # 挂载代码,实现热更新
|
||
# 加上 --reload 参数,代码变了自动重启
|
||
command: gunicorn -c gunicorn.conf.py run:app --reload
|
||
environment:
|
||
# Host 必须写 'db'
|
||
DATABASE_URL: postgresql://test:1234@db:5432/inventory_system
|
||
depends_on:
|
||
- db
|
||
|
||
# --- 前端 Vue+Nginx 服务 ---
|
||
# --- 前端 Vue 开发服务 ---
|
||
frontend:
|
||
build:
|
||
context: ./inventory-web
|
||
container_name: inventory_ui
|
||
restart: always
|
||
# 【重点1】把本地代码挂载进去,实现“热更新”
|
||
volumes:
|
||
- ./inventory-web:/app
|
||
- /app/node_modules # 排除 node_modules,防止冲突
|
||
# 【重点2】开发模式端口通常是 5173
|
||
ports:
|
||
- "5173:5173"
|
||
depends_on:
|
||
- backend |