Skip to content

Commit 5ef645e

Browse files
xiao-zi-chenclaude
andcommitted
Add Docker deployment support
- Add Dockerfile for multi-service container - Add docker-compose.yml for service orchestration - Add docker-start scripts for Windows and Linux/Mac - Add environment variable templates - Update README with Docker deployment instructions - Add comprehensive Docker deployment documentation Features: - One-click deployment with docker-start scripts - Cross-platform support (Windows/Linux/Mac) - Data persistence through volume mounts - No Python environment setup required - Complete English and Chinese documentation Services: - auth-portal (port 8010) - multiagent (port 8011) - novelclaw (port 8012) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent c9e48da commit 5ef645e

12 files changed

Lines changed: 750 additions & 2 deletions

.dockerignore

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# Python
7+
__pycache__
8+
*.py[cod]
9+
*$py.class
10+
*.so
11+
.Python
12+
*.egg-info
13+
dist
14+
build
15+
.venv
16+
.venv-shared
17+
venv
18+
env
19+
ENV
20+
21+
# IDEs
22+
.vscode
23+
.idea
24+
*.swp
25+
*.swo
26+
*~
27+
28+
# OS
29+
.DS_Store
30+
Thumbs.db
31+
desktop.ini
32+
33+
# Local data and runtime
34+
apps/*/local_web_portal/data/
35+
apps/*/local_web_portal/runs/
36+
state_snapshots/
37+
*.db
38+
*.db-journal
39+
*.log
40+
41+
# Environment files (will be mounted as volumes)
42+
.env
43+
*.env
44+
!*.env.example
45+
46+
# Documentation
47+
*.md
48+
docs/
49+
50+
# Scripts (not needed in container)
51+
scripts/*.ps1
52+
scripts/*.bat
53+
*.bat
54+
*.ps1
55+
56+
# Infra configs (not needed in container)
57+
infra/nginx/
58+
infra/systemd/
59+
60+
# ISTask.dll (Windows specific)
61+
ISTask.dll

.env.auth-portal.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# .env template for auth-portal
2+
# Copy this file to apps/auth-portal/.env and configure your values
3+
4+
# Database
5+
DATABASE_URL=sqlite:///./local_web_portal/data/app.db
6+
7+
# Security
8+
SECRET_KEY=your-secret-key-here-change-in-production
9+
10+
# Server
11+
HOST=0.0.0.0
12+
PORT=8010

.env.multiagent.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# .env template for multiagent
2+
# Copy this file to apps/multiagent/.env and configure your values
3+
4+
# API Keys
5+
OPENAI_API_KEY=your-openai-api-key-here
6+
ANTHROPIC_API_KEY=your-anthropic-api-key-here
7+
8+
# Database
9+
DATABASE_URL=sqlite:///./local_web_portal/data/app.db
10+
11+
# Server
12+
HOST=0.0.0.0
13+
PORT=8011

.env.novelclaw.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# .env template for novelclaw
2+
# Copy this file to apps/novelclaw/.env and configure your values
3+
4+
# API Keys
5+
OPENAI_API_KEY=your-openai-api-key-here
6+
ANTHROPIC_API_KEY=your-anthropic-api-key-here
7+
8+
# Database
9+
DATABASE_URL=sqlite:///./local_web_portal/data/app.db
10+
11+
# Server
12+
HOST=0.0.0.0
13+
PORT=8012
14+
15+
# Storage
16+
RUNS_DIR=./local_web_portal/runs
17+
DATA_DIR=./local_web_portal/data

DOCKER_DEPLOYMENT.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Docker Deployment Guide
2+
3+
## Quick Start with Docker
4+
5+
### Prerequisites
6+
- Docker and Docker Compose installed
7+
- Git (to clone the repository)
8+
9+
### Setup Steps
10+
11+
1. **Clone the repository** (if not already done):
12+
```bash
13+
git clone https://github.com/iLearn-Lab/NovelClaw.git
14+
cd NovelClaw
15+
```
16+
17+
2. **Configure environment variables**:
18+
```bash
19+
# Copy example env files to actual .env files
20+
cp .env.auth-portal.example apps/auth-portal/.env
21+
cp .env.multiagent.example apps/multiagent/.env
22+
cp .env.novelclaw.example apps/novelclaw/.env
23+
```
24+
25+
3. **Edit the .env files** with your API keys:
26+
- `apps/novelclaw/.env` - Add your OpenAI/Anthropic API keys
27+
- `apps/multiagent/.env` - Add your OpenAI/Anthropic API keys
28+
- `apps/auth-portal/.env` - Change the SECRET_KEY
29+
30+
4. **Build and start all services**:
31+
```bash
32+
docker-compose up -d
33+
```
34+
35+
5. **Access the application**:
36+
- Auth Portal: http://localhost:8010/select-mode
37+
- MultiAgent: http://localhost:8011/dashboard
38+
- NovelClaw: http://localhost:8012/dashboard
39+
40+
### Docker Commands
41+
42+
**Start services**:
43+
```bash
44+
docker-compose up -d
45+
```
46+
47+
**Stop services**:
48+
```bash
49+
docker-compose down
50+
```
51+
52+
**View logs**:
53+
```bash
54+
# All services
55+
docker-compose logs -f
56+
57+
# Specific service
58+
docker-compose logs -f novelclaw
59+
docker-compose logs -f multiagent
60+
docker-compose logs -f auth-portal
61+
```
62+
63+
**Rebuild after code changes**:
64+
```bash
65+
docker-compose up -d --build
66+
```
67+
68+
**Restart a specific service**:
69+
```bash
70+
docker-compose restart novelclaw
71+
```
72+
73+
### Data Persistence
74+
75+
The following directories are mounted as volumes to persist data:
76+
- `apps/auth-portal/local_web_portal/data` - Auth portal database
77+
- `apps/multiagent/local_web_portal/data` - MultiAgent data
78+
- `apps/novelclaw/local_web_portal/data` - NovelClaw database
79+
- `apps/novelclaw/local_web_portal/runs` - Writing runs and outputs
80+
81+
### Troubleshooting
82+
83+
**Port conflicts**:
84+
If ports 8010, 8011, or 8012 are already in use, edit `docker-compose.yml` to change the port mappings:
85+
```yaml
86+
ports:
87+
- "9010:8010" # Change 9010 to your preferred port
88+
```
89+
90+
**Permission issues**:
91+
On Linux/Mac, you may need to adjust permissions:
92+
```bash
93+
chmod -R 755 apps/*/local_web_portal/data
94+
chmod -R 755 apps/novelclaw/local_web_portal/runs
95+
```
96+
97+
**View container status**:
98+
```bash
99+
docker-compose ps
100+
```
101+
102+
**Enter a container for debugging**:
103+
```bash
104+
docker exec -it novelclaw-workspace bash
105+
```
106+
107+
### Production Deployment
108+
109+
For production deployment:
110+
1. Use proper secrets management (not .env files)
111+
2. Configure reverse proxy (nginx example in `infra/nginx/`)
112+
3. Set up SSL/TLS certificates
113+
4. Use external database instead of SQLite
114+
5. Configure proper backup for data volumes
115+
6. Set resource limits in docker-compose.yml
116+
117+
See [DEPLOYMENT.md](DEPLOYMENT.md) for more production deployment details.

DOCKER_DEPLOYMENT.zh-CN.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Docker 部署指南
2+
3+
## 使用 Docker 快速开始
4+
5+
### 前置要求
6+
- 已安装 Docker 和 Docker Compose
7+
- Git(用于克隆仓库)
8+
9+
### 部署步骤
10+
11+
1. **克隆仓库**(如果还没有克隆):
12+
```bash
13+
git clone https://github.com/iLearn-Lab/NovelClaw.git
14+
cd NovelClaw
15+
```
16+
17+
2. **配置环境变量**
18+
```bash
19+
# 复制示例环境变量文件
20+
cp .env.auth-portal.example apps/auth-portal/.env
21+
cp .env.multiagent.example apps/multiagent/.env
22+
cp .env.novelclaw.example apps/novelclaw/.env
23+
```
24+
25+
3. **编辑 .env 文件**,添加你的 API 密钥:
26+
- `apps/novelclaw/.env` - 添加 OpenAI/Anthropic API 密钥
27+
- `apps/multiagent/.env` - 添加 OpenAI/Anthropic API 密钥
28+
- `apps/auth-portal/.env` - 修改 SECRET_KEY
29+
30+
4. **构建并启动所有服务**
31+
32+
**Windows 用户**
33+
```batch
34+
.\docker-start.bat
35+
```
36+
37+
**Linux/Mac 用户**
38+
```bash
39+
chmod +x docker-start.sh
40+
./docker-start.sh
41+
```
42+
43+
**或手动启动**
44+
```bash
45+
docker-compose up -d
46+
```
47+
48+
5. **访问应用**
49+
- 认证门户:http://localhost:8010/select-mode
50+
- 多智能体:http://localhost:8011/dashboard
51+
- NovelClaw:http://localhost:8012/dashboard
52+
53+
### Docker 常用命令
54+
55+
**启动服务**
56+
```bash
57+
docker-compose up -d
58+
```
59+
60+
**停止服务**
61+
```bash
62+
docker-compose down
63+
```
64+
65+
**查看日志**
66+
```bash
67+
# 查看所有服务日志
68+
docker-compose logs -f
69+
70+
# 查看特定服务日志
71+
docker-compose logs -f novelclaw
72+
docker-compose logs -f multiagent
73+
docker-compose logs -f auth-portal
74+
```
75+
76+
**代码更改后重新构建**
77+
```bash
78+
docker-compose up -d --build
79+
```
80+
81+
**重启特定服务**
82+
```bash
83+
docker-compose restart novelclaw
84+
```
85+
86+
### 数据持久化
87+
88+
以下目录通过卷挂载实现数据持久化:
89+
- `apps/auth-portal/local_web_portal/data` - 认证门户数据库
90+
- `apps/multiagent/local_web_portal/data` - 多智能体数据
91+
- `apps/novelclaw/local_web_portal/data` - NovelClaw 数据库
92+
- `apps/novelclaw/local_web_portal/runs` - 写作运行记录和输出
93+
94+
### 故障排除
95+
96+
**端口冲突**
97+
如果端口 8010、8011 或 8012 已被占用,编辑 `docker-compose.yml` 修改端口映射:
98+
```yaml
99+
ports:
100+
- "9010:8010" # 将 9010 改为你想要的端口
101+
```
102+
103+
**权限问题**:
104+
在 Linux/Mac 上,可能需要调整权限:
105+
```bash
106+
chmod -R 755 apps/*/local_web_portal/data
107+
chmod -R 755 apps/novelclaw/local_web_portal/runs
108+
```
109+
110+
**查看容器状态**
111+
```bash
112+
docker-compose ps
113+
```
114+
115+
**进入容器调试**
116+
```bash
117+
docker exec -it novelclaw-workspace bash
118+
```
119+
120+
### 生产环境部署
121+
122+
生产环境部署建议:
123+
1. 使用专业的密钥管理(不要使用 .env 文件)
124+
2. 配置反向代理(nginx 示例见 `infra/nginx/`
125+
3. 设置 SSL/TLS 证书
126+
4. 使用外部数据库替代 SQLite
127+
5. 配置数据卷的备份策略
128+
6. 在 docker-compose.yml 中设置资源限制
129+
130+
更多生产部署细节请参考 [DEPLOYMENT.md](DEPLOYMENT.md)[docs/DEPLOYMENT.zh-CN.md](docs/DEPLOYMENT.zh-CN.md)
131+
132+
### Docker 部署优势
133+
134+
**无需配置 Python 环境** - 所有依赖都打包在镜像中
135+
136+
**跨平台一致性** - Windows、Linux、Mac 使用相同的部署方式
137+
138+
**易于管理** - 一键启动、停止、重启所有服务
139+
140+
**数据持久化** - 通过卷挂载确保数据不丢失
141+
142+
**隔离性好** - 每个服务运行在独立容器中
143+
144+
**易于扩展** - 可以轻松添加更多服务或调整资源

0 commit comments

Comments
 (0)