Wendong-Fan commited on
Commit
e891a8a
·
2 Parent(s): 4f46ba3 f01d276

add dockerreadme (#81)

Browse files
Files changed (3) hide show
  1. DOCKER_README_en.md +298 -0
  2. README.md +26 -0
  3. README_zh.md +23 -0
DOCKER_README_en.md ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OWL Project Docker Usage Guide
2
+
3
+ This document provides detailed instructions on how to run the OWL project using Docker.
4
+
5
+ ## Prerequisites
6
+
7
+ • Install [Docker](https://docs.docker.com/get-docker/)
8
+ • Install [Docker Compose](https://docs.docker.com/compose/install/) (recommended v2.x version)
9
+ • Obtain necessary API keys (OpenAI API, etc.)
10
+
11
+ ## Technical Notes
12
+
13
+ This Docker configuration uses the following technologies to ensure the OWL project runs smoothly in containers:
14
+
15
+ • **Xvfb**: Virtual framebuffer, used to simulate an X server in a headless environment
16
+ • **Playwright**: Used for browser automation, configured in headless mode
17
+ • **Shared Memory**: Increased shared memory size to improve browser performance
18
+ • **BuildKit**: Uses Docker BuildKit to accelerate the build process
19
+ • **Cache Optimization**: Uses persistent volumes to cache pip and Playwright dependencies
20
+ • **Cross-Platform Compatibility**: Provides scripts for both Windows and macOS/Linux
21
+
22
+ ## Docker Compose Version Notes
23
+
24
+ The docker-compose.yml file used in this project is compatible with Docker Compose v2.x. If you are using an older Docker Compose v1.x version, you may need to manually add the version number:
25
+
26
+ ```yaml
27
+ version: '3'
28
+
29
+ services:
30
+ # ...rest of the configuration remains unchanged
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ### 0. Check Environment
36
+
37
+ First, run the check script to ensure your environment is ready:
38
+
39
+ #### Check on macOS/Linux
40
+
41
+ ```bash
42
+ # First, add execute permissions to the script
43
+ chmod +x check_docker.sh
44
+
45
+ # Run the check script
46
+ ./check_docker.sh
47
+ ```
48
+
49
+ #### Check on Windows
50
+
51
+ ```cmd
52
+ check_docker.bat
53
+ ```
54
+
55
+ If the check script finds any issues, please follow the prompts to fix them.
56
+
57
+ ### 1. Configure Environment Variables
58
+
59
+ Copy the environment variable template file and fill in the necessary API keys:
60
+
61
+ ```bash
62
+ cp owl/.env_template owl/.env
63
+ ```
64
+
65
+ Then edit the `owl/.env` file and fill in the necessary API keys, for example:
66
+
67
+ ```
68
+ OPENAI_API_KEY=your_openai_api_key
69
+ GOOGLE_API_KEY=your_google_api_key
70
+ SEARCH_ENGINE_ID=your_search_engine_id
71
+ ```
72
+
73
+ ### 2. Quick Build Docker Image
74
+
75
+ #### Build on macOS/Linux
76
+
77
+ Use the provided shell script to speed up the Docker image build:
78
+
79
+ ```bash
80
+ # First, add execute permissions to the script
81
+ chmod +x build_docker.sh
82
+
83
+ # Run the build script
84
+ ./build_docker.sh
85
+ ```
86
+
87
+ #### Build on Windows
88
+
89
+ Use the provided batch file:
90
+
91
+ ```cmd
92
+ build_docker.bat
93
+ ```
94
+
95
+ Or build and start using the standard method:
96
+
97
+ ```bash
98
+ # Use BuildKit to accelerate the build
99
+ set DOCKER_BUILDKIT=1
100
+ set COMPOSE_DOCKER_CLI_BUILD=1
101
+ docker-compose build --build-arg BUILDKIT_INLINE_CACHE=1
102
+
103
+ # Start the container
104
+ docker-compose up -d
105
+ ```
106
+
107
+ ### 3. Interactive Use of the Container
108
+
109
+ After the container starts, it will automatically enter an interactive shell environment and display a welcome message and a list of available scripts:
110
+
111
+ ```bash
112
+ # Enter the container (if not automatically entered)
113
+ docker-compose exec owl bash
114
+ ```
115
+
116
+ Inside the container, you can directly run any available script:
117
+
118
+ ```bash
119
+ # Run the default script
120
+ xvfb-python run.py
121
+
122
+ # Run the DeepSeek example
123
+ xvfb-python run_deepseek_example.py
124
+
125
+ # Run the script and pass query parameters
126
+ xvfb-python run.py "What is artificial intelligence?"
127
+ ```
128
+
129
+ ### 4. Run Queries Using External Scripts
130
+
131
+ #### Run on macOS/Linux
132
+
133
+ ```bash
134
+ # First, add execute permissions to the script
135
+ chmod +x run_in_docker.sh
136
+
137
+ # Default to using the run.py script
138
+ ./run_in_docker.sh "your question"
139
+
140
+ # Specify a particular script
141
+ ./run_in_docker.sh run_deepseek_example.py "your question"
142
+ ```
143
+
144
+ #### Run on Windows
145
+
146
+ ```cmd
147
+ REM Default to using the run.py script
148
+ run_in_docker.bat "your question"
149
+
150
+ REM Specify a particular script
151
+ run_in_docker.bat run_deepseek_example.py "your question"
152
+ ```
153
+
154
+ **Available Scripts**:
155
+ • `run.py` - Default script, uses OpenAI GPT-4o model
156
+ • `run_deepseek_example.py` - Uses the DeepSeek model
157
+ • `run_gaia_roleplaying.py` - GAIA benchmark script
158
+
159
+ ## Directory Mounts
160
+
161
+ The Docker Compose configuration has set up the following mount points:
162
+
163
+ • `./owl/.env:/app/owl/.env`: Mounts the environment variable file for easy modification of API keys
164
+ • `./data:/app/data`: Mounts the data directory for storing and accessing data files
165
+ • `playwright-cache`: Persistent volume for caching Playwright browsers
166
+ • `pip-cache`: Persistent volume for caching pip packages
167
+
168
+ ## Environment Variables
169
+
170
+ You can set environment variables in two ways:
171
+
172
+ 1. Modify the `owl/.env` file
173
+ 2. Add environment variables in the `environment` section of the `docker-compose.yml` file
174
+
175
+ ## Build Optimization
176
+
177
+ This Docker configuration includes several build optimizations:
178
+
179
+ 1. **Use of Domestic Mirror Sources**: Uses Tsinghua University mirror sources to accelerate pip package downloads
180
+ 2. **Layer Optimization**: Reduces the number of layers in the Dockerfile to improve build efficiency
181
+ 3. **Cache Utilization**:
182
+ • Enables pip caching to avoid repeated dependency downloads
183
+ • Uses Docker BuildKit inline caching
184
+ • Arranges Dockerfile instructions to maximize cache utilization
185
+ 4. **BuildKit**: Enables Docker BuildKit to accelerate builds
186
+ 5. **Persistent Caching**:
187
+ • Uses Docker volumes to cache pip packages (`pip-cache`)
188
+ • Uses Docker volumes to cache Playwright browsers (`playwright-cache`)
189
+ • Local cache directory (`.docker-cache`)
190
+
191
+ ### Cache Cleanup
192
+
193
+ If you need to clean the cache, you can use the following commands:
194
+
195
+ ```bash
196
+ # Clean Docker build cache
197
+ docker builder prune
198
+
199
+ # Clean Docker volumes (will delete all unused volumes, including cache volumes)
200
+ docker volume prune
201
+
202
+ # Clean local cache directory
203
+ rm -rf .docker-cache
204
+ ```
205
+
206
+ ## Cross-Platform Compatibility
207
+
208
+ This project provides scripts for different operating systems:
209
+
210
+ 1. **Check Scripts**:
211
+ • `check_docker.sh` (macOS/Linux): Checks the Docker environment
212
+ • `check_docker.bat` (Windows): Checks the Docker environment
213
+
214
+ 2. **Build Scripts**:
215
+ • `build_docker.sh` (macOS/Linux): Builds the Docker image
216
+ • `build_docker.bat` (Windows): Builds the Docker image
217
+
218
+ 3. **Run Scripts**:
219
+ • `run_in_docker.sh` (macOS/Linux): Runs scripts in the Docker container
220
+ • `run_in_docker.bat` (Windows): Runs scripts in the Docker container
221
+
222
+ These scripts automatically detect the operating system type and use appropriate commands.
223
+
224
+ ## Troubleshooting
225
+
226
+ ### Container Fails to Start
227
+
228
+ Check the logs for more information:
229
+
230
+ ```bash
231
+ docker-compose logs
232
+ ```
233
+
234
+ ### API Key Issues
235
+
236
+ Ensure that you have correctly set all necessary API keys in the `owl/.env` file.
237
+
238
+ ### Docker Compose Warnings
239
+
240
+ If you see a warning about the `version` attribute being obsolete:
241
+
242
+ ```
243
+ WARN[0000] docker-compose.yml: the attribute `version` is obsolete
244
+ ```
245
+
246
+ This is because you are using Docker Compose v2.x, which no longer requires an explicit version number. We have removed this attribute from the configuration file, so you should no longer see this warning.
247
+
248
+ ### Browser-Related Issues
249
+
250
+ If you encounter browser-related issues, try the following solutions:
251
+
252
+ 1. Ensure that you are using the `xvfb-python` command to run Python scripts in the Docker container
253
+ 2. Check that Xvfb and related dependencies are correctly installed
254
+ 3. Increase the shared memory size (set to 2GB in docker-compose.yml)
255
+
256
+ ### Slow Build Speed
257
+
258
+ If the build speed is slow, try the following solutions:
259
+
260
+ 1. Ensure that Docker BuildKit is enabled (`DOCKER_BUILDKIT=1`)
261
+ 2. Ensure that pip caching is enabled (configured in docker-compose.yml)
262
+ 3. Use the `--build-arg BUILDKIT_INLINE_CACHE=1` parameter when building (configured in the build script)
263
+ 4. If this is the first build, downloading dependencies may take some time, but subsequent builds will be faster
264
+
265
+ ### Windows-Specific Issues
266
+
267
+ If you encounter issues on Windows:
268
+
269
+ 1. Ensure that you are running the Command Prompt or PowerShell with administrator privileges
270
+ 2. If you encounter path issues, try using forward slashes (/) instead of backslashes (\)
271
+ 3. If you encounter Docker Compose command issues, try using `docker compose` (without the hyphen)
272
+
273
+ ### Insufficient Memory
274
+
275
+ If you encounter insufficient memory issues, you can adjust resource limits in the `docker-compose.yml` file:
276
+
277
+ ```yaml
278
+ services:
279
+ owl:
280
+ # Other configurations...
281
+ deploy:
282
+ resources:
283
+ limits:
284
+ cpus: '4' # Increase CPU cores
285
+ memory: 8G # Increase memory limit
286
+ ```
287
+
288
+ ## Custom Docker Image
289
+
290
+ If you need to customize the Docker image, modify the `Dockerfile` file and then rebuild:
291
+
292
+ ```bash
293
+ # macOS/Linux
294
+ ./build_docker.sh
295
+
296
+ # Windows
297
+ build_docker.bat
298
+ ```
README.md CHANGED
@@ -70,6 +70,8 @@ Our vision is to revolutionize how AI agents collaborate to solve real-world tas
70
  - [**Set up Environment**](#set-up-environment)
71
  - [**Install Dependencies**](#install-dependencies)
72
  - [**Setup Environment Variables**](#setup-environment-variables)
 
 
73
  - [🚀 Quick Start](#-quick-start)
74
  - [🧪 Experiments](#-experiments)
75
  - [⏱️ Future Plans](#️-future-plans)
@@ -146,7 +148,31 @@ cp owl/.env_template .env
146
 
147
  > **Note**: For optimal performance, we strongly recommend using OpenAI models. Our experiments show that other models may result in significantly lower performance on complex tasks and benchmarks.
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  # 🚀 Quick Start
 
 
150
 
151
  Run the following demo case:
152
 
 
70
  - [**Set up Environment**](#set-up-environment)
71
  - [**Install Dependencies**](#install-dependencies)
72
  - [**Setup Environment Variables**](#setup-environment-variables)
73
+ - [**Running with Docker**](#running-with-docker)
74
+
75
  - [🚀 Quick Start](#-quick-start)
76
  - [🧪 Experiments](#-experiments)
77
  - [⏱️ Future Plans](#️-future-plans)
 
148
 
149
  > **Note**: For optimal performance, we strongly recommend using OpenAI models. Our experiments show that other models may result in significantly lower performance on complex tasks and benchmarks.
150
 
151
+ ## **Running with Docker**
152
+
153
+ If you prefer to run the OWL project using Docker, we provide full Docker support:
154
+
155
+ ```bash
156
+ # Clone the repository
157
+ git clone https://github.com/camel-ai/owl.git
158
+ cd owl
159
+
160
+ # Configure environment variables
161
+ cp owl/.env_template owl/.env
162
+ # Edit the .env file and fill in your API keys
163
+
164
+ # Build and run the Docker container
165
+ docker-compose up -d
166
+
167
+ # Run OWL inside the container
168
+ docker-compose exec owl bash -c "xvfb-python run.py"
169
+ ```
170
+
171
+ For more detailed Docker usage instructions, including cross-platform support, optimized configurations, and troubleshooting, please refer to [DOCKER_README.md](DOCKER_README_en.md).
172
+
173
  # 🚀 Quick Start
174
+
175
+
176
 
177
  Run the following demo case:
178
 
README_zh.md CHANGED
@@ -71,6 +71,7 @@
71
  - [**设置环境**](#设置环境)
72
  - [**安装依赖**](#安装依赖)
73
  - [**设置环境变量**](#设置环境变量)
 
74
  - [🚀 快速开始](#-快速开始)
75
  - [🧪 实验](#-实验)
76
  - [⏱️ 未来计划](#️-未来计划)
@@ -140,6 +141,28 @@ python -m pip install -r requirements.txt
140
 
141
  > **注意**:为获得最佳性能,我们强烈建议使用 OpenAI 模型。我们通过测试发现,其他模型在处理复杂任务和基准测试时可能会导致性能显著降低。
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  # 🚀 快速开始
144
 
145
  运行以下示例:
 
71
  - [**设置环境**](#设置环境)
72
  - [**安装依赖**](#安装依赖)
73
  - [**设置环境变量**](#设置环境变量)
74
+ - [**使用Docker运行**](#使用docker运行)
75
  - [🚀 快速开始](#-快速开始)
76
  - [🧪 实验](#-实验)
77
  - [⏱️ 未来计划](#️-未来计划)
 
141
 
142
  > **注意**:为获得最佳性能,我们强烈建议使用 OpenAI 模型。我们通过测试发现,其他模型在处理复杂任务和基准测试时可能会导致性能显著降低。
143
 
144
+ ## **使用Docker运行**
145
+
146
+ 如果您希望使用Docker运行OWL项目,我们提供了完整的Docker支持:
147
+
148
+ ```bash
149
+ # 克隆仓库
150
+ git clone https://github.com/camel-ai/owl.git
151
+ cd owl
152
+
153
+ # 配置环境变量
154
+ cp owl/.env_template owl/.env
155
+ # 编辑.env文件,填入您的API密钥
156
+
157
+ # 构建并运行Docker容器
158
+ docker-compose up -d
159
+
160
+ # 在容器中运行OWL
161
+ docker-compose exec owl bash -c "xvfb-python run.py"
162
+ ```
163
+
164
+ 更多详细的Docker使用说明,包括跨平台支持、优化配置和故障排除,请参阅 [DOCKER_README.md](DOCKER_README.md)
165
+
166
  # 🚀 快速开始
167
 
168
  运行以下示例: