Files
water-management-system/deploy/production/README.md
T

30 lines
1.3 KiB
Markdown
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.
# 生产环境部署方案(Issue #91)
## 架构
```
公网 443 → Nginx(TLS终结/限流/HSTS) → 127.0.0.1:8000 app(FastAPI, 非root, read_only)
→ postgres(数据卷 pgdata)
```
## 步骤
1. **服务器初始化**:`sudo bash deploy/production/server-setup.sh`
(系统更新、Docker、防火墙仅 22/80/443、SSH 禁 root/密码登录、部署用户 deploy)
2. **域名与证书**:将 `wms.xayunmei.com` A 记录指向服务器,证书放入
`deploy/production/certs/`(wms.crt / wms.key)。
3. **启动**:`REGISTRY=... IMAGE_TAG=<commit> docker compose \
-f docker-compose.yml -f deploy/production/docker-compose.override.yml up -d`
4. **日常部署**:`bash scripts/deploy.sh <commit_sha>`(自动拉取/滚动更新/健康检查/回滚)。
## 备份策略
- `deploy/production/backup.sh`:pg_dump 每日全量 + sha256 校验,保留 30 天,
可选 rsync 异地同步(`BACKUP_REMOTE` 环境变量)。建议 crontab:`0 2 * * * /opt/wms/deploy/production/backup.sh`
## 安全基线
- 容器非 root + 只读文件系统 + 资源限额(2C/2G)+ json-file 日志轮转
- 应用端口仅绑定 127.0.0.1,对外仅 443;HTTP 强制跳转 HTTPS;TLS1.2+;HSTS
- API 限流 20r/s(burst 40),安全响应头齐全