49 lines
1.4 KiB
YAML
49 lines
1.4 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# --- 数据库 (保持不变) ---
|
|
db:
|
|
image: postgres:15-alpine
|
|
container_name: inventory_db_prod
|
|
restart: always
|
|
environment:
|
|
POSTGRES_USER: prod_user
|
|
POSTGRES_PASSWORD: StrongPassword123!
|
|
POSTGRES_DB: inventory_system
|
|
volumes:
|
|
- ./pgdata_prod:/var/lib/postgresql/data
|
|
|
|
# --- 后端 (Flask) (保持不变) ---
|
|
backend:
|
|
build:
|
|
context: ./inventory-backend
|
|
container_name: inventory_api_prod
|
|
restart: always
|
|
expose:
|
|
- "8000"
|
|
volumes:
|
|
- ./uploads_prod:/app/uploads
|
|
command: gunicorn -c gunicorn.conf.py run:app
|
|
environment:
|
|
DATABASE_URL: postgresql://prod_user:StrongPassword123!@db:5432/inventory_system
|
|
depends_on:
|
|
- db
|
|
|
|
# --- 前端 (Nginx + Vue) (这是需要修改的部分) ---
|
|
frontend:
|
|
build:
|
|
context: ./inventory-web
|
|
dockerfile: Dockerfile.prod
|
|
container_name: inventory_ui_prod
|
|
restart: always
|
|
ports:
|
|
- "80:80" # HTTP 端口
|
|
- "443:443" # 【新增】HTTPS 端口
|
|
volumes:
|
|
# 【新增】挂载 SSL 证书
|
|
# 左边是服务器路径 ./ssl/nginx.crt
|
|
# 右边是容器内路径 /etc/nginx/ssl/nginx.crt (必须和报错日志里的一致)
|
|
- ./ssl/nginx.crt:/etc/nginx/ssl/nginx.crt
|
|
- ./ssl/nginx.key:/etc/nginx/ssl/nginx.key
|
|
depends_on:
|
|
- backend |