Files
2026-07-08 20:02:29 +08:00

60 lines
1.6 KiB
Markdown
Raw Permalink 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.
# 部署指南 (Docker Compose)
## 前置条件
- Linux 服务器(或 Windows WSL2
- Docker 和 Docker Compose 已安装
- 域名(可选)和 SSL 证书(可选)
## 步骤
### 1. 克隆代码
```bash
git clone <repository-url>
cd doc-forge-reborn
```
### 2. 配置环境变量
复制 `.env.example``.env`,并填写以下关键变量:
```env
# Database
POSTGRES_USER=docforge
POSTGRES_PASSWORD=secure_password
POSTGRES_DB=docforge
# Redis
REDIS_URL=redis://redis:6379/0
# Backend
SECRET_KEY=your-secret-key-for-fernet-encryption
DEFAULT_MODEL_ID=uuid-of-default-model
# AI API Keys (也可在后台模型管理中配置)
OPENAI_API_KEY=sk-...
AZURE_API_KEY=...
```
### 3. 构建并启动所有服务
```bash
docker-compose up -d --build
```
### 4. 执行数据库迁移(首次启动后)
```bash
docker-compose exec backend alembic upgrade head
```
### 5. 验证服务状态
- 前端`http://localhost:3000`
- 后端 API 文档`http://localhost:8000/docs`
- Celery Worker 日志`docker-compose logs celery-worker`
## 服务端口映射
- 前端`3000` (可通过 `nginx` 暴露 80)
- 后端 API`8000`
- PostgreSQL`5432` (仅内部)
- Redis`6379` (仅内部)
## 生产环境优化建议
- 使用外部 PostgreSQL(如 AWS RDS)提升可靠性。
- 将 Redis 配置为持久化模式。
- 挂载 SSL 证书,配置 HTTPS。
- 设置 Celery 并发数根据 CPU 核心数调整。
- 定期备份数据库和文件存储目录。
## 停止服务
```bash
docker-compose down
```
## 升级流程
1. `git pull` 拉取最新代码
2. `docker-compose build` 重新构建镜像
3. `docker-compose up -d` 重启服务
4. 运行数据库迁移(如有)