1.9 KiB
1.9 KiB
Docker 部署说明
快速启动
1. 直接使用 docker-compose 启动
# 启动服务(需要提前配置好外部 MySQL 连接)
docker-compose up -d
# 查看日志
docker-compose logs -f api
# 停止服务
docker-compose down
2. 单独构建镜像
# 构建镜像
docker build -t assetmanager-api:latest .
# 运行容器(需要自行配置 MySQL 连接)
docker run -d -p 7040:8080 \
-e ConnectionStrings__Default="server=你的MySQL地址;Database=assetmanager;Uid=root;Pwd=你的密码;CharSet=utf8mb4;" \
-e Jwt__SecretKey="你的自定义密钥" \
assetmanager-api:latest
环境变量说明
| 环境变量 | 说明 | 默认值 |
|---|---|---|
ASPNETCORE_ENVIRONMENT |
运行环境 | Production |
ConnectionStrings__Default |
MySQL 连接字符串 | - |
Jwt__SecretKey |
JWT 签名密钥 | 开发环境默认值 |
Jwt__Issuer |
JWT 签发者 | AssetManager |
Jwt__Audience |
JWT 受众 | AssetManager |
Wechat__AppId |
微信小程序 AppId | 测试默认值 |
Wechat__AppSecret |
微信小程序 AppSecret | 测试默认值 |
Tiingo__ApiKey |
Tiingo 股票数据 API Key | 测试默认值 |
TZ |
时区 | Asia/Shanghai |
端口说明
| 端口 | 服务 | 说明 |
|---|---|---|
7040 |
后端 API | HTTP 接口 |
数据持久化
- 应用日志:存储在
logs卷中
生产环境注意事项
-
必须修改默认密码和密钥:
- MySQL 连接密码
- JWT 签名密钥 (
Jwt__SecretKey) - 微信 AppId/AppSecret
- Tiingo API Key
-
建议使用反向代理(Nginx/Caddy)提供 HTTPS 访问
常见问题
启动后 API 访问 500
检查 MySQL 连接是否正常,确认连接字符串配置正确。
微信登录失败
检查 Wechat__AppId 和 Wechat__AppSecret 是否配置正确。
市场数据获取失败
检查 Tiingo__ApiKey 是否有效,网络是否能访问 Tiingo API。