feat: 添加.env.example模板和部署检查清单

This commit is contained in:
龙大 2026-03-21 01:41:08 +08:00
parent 1c8e773046
commit 6344f18fb0
2 changed files with 86 additions and 0 deletions

26
backend/.env.example Normal file
View File

@ -0,0 +1,26 @@
# 数据库配置
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/zodiac
# JWT配置
SECRET_KEY=your-production-secret-key-change-this
ACCESS_TOKEN_EXPIRE_MINUTES=60
# 阿里云 DashScope OCR API必须配置
DASHSCOPE_API_KEY=sk-9389024a37da4f7bb455ac9a6b28776f
# 阿里云 OSS配置
OSS_ACCESS_KEY_ID=LTAI5t6HUnpFBLEK9194kPVG
OSS_ACCESS_KEY_SECRET=LEr4Q8yRxb8D5b24cKfCwlt4MMoke1
OSS_BUCKET_NAME=jiachenlong-oss
OSS_ENDPOINT=oss-cn-hangzhou.aliyuncs.com
OSS_PUBLIC_URL=https://jiachenlong-oss.oss-cn-hangzhou.aliyuncs.com
# 阿里云短信配置(必须配置!)
SMS_ACCESS_KEY_ID=LTAI5tQAx5niD7JQVqGE5acE
SMS_ACCESS_KEY_SECRET=QsQFAEKBkaNynIoKyvdIi3BUyWVZu1
SMS_SIGN_NAME=苏州算力
SMS_TEMPLATE_CODE=SMS_501590956
# 服务配置
PORT=3000
HOST=0.0.0.0

View File

@ -0,0 +1,60 @@
# 部署检查清单
## 部署后必须检查
### 1. 环境变量检查
```bash
cat backend/.env
```
必须包含:
- ✅ DASHSCOPE_API_KEY不是sk-xxx
- ✅ SMS_ACCESS_KEY_ID
- ✅ SMS_SIGN_NAME
- ✅ SMS_TEMPLATE_CODE
### 2. 代码版本检查
```bash
git log --oneline -1
```
确认是目标版本
### 3. OCR扩展名检查
```bash
grep temp_extensions backend/app/routers/ocr.py
```
确认包含大小写扩展名 JPG JPEG PNG GIF
### 4. Python版本检查
```bash
python3 --version
```
必须是 3.11+
### 5. 服务启动检查
```bash
curl http://localhost:3000/
```
返回 200
### 6. API测试
```bash
# 登录
TOKEN=$(curl -s -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin&password=admin123" | python3 -c "import sys,json; print(json.load(sys.stdin).get(access_token,))")
# 测试验证码
curl -X POST http://localhost:3000/api/auth/send-verification-code \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"phone":"13800138000"}'
```
## 常见问题快速修复
| 问题 | 修复命令 |
|------|---------|
| OCR慢 | 检查DASHSCOPE_API_KEY是否正确 |
| 验证码失败 | 检查SMS_*配置是否完整 |
| 导入错误 | 使用python3.11启动 |
| 404错误 | 重启后端服务 |