Skip to content

Commit 8d22981

Browse files
authored
update docker (#328)
2 parents fcbf87f + 3a3dd4f commit 8d22981

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

.container/Dockerfile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.10-slim
22

3-
# 设置环境变量
3+
# Set environment variables
44
ENV PYTHONDONTWRITEBYTECODE=1 \
55
PYTHONUNBUFFERED=1 \
66
PIP_NO_CACHE_DIR=0 \
@@ -10,51 +10,50 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
1010
DEBIAN_FRONTEND=noninteractive \
1111
PATH="/app/.venv/bin:$PATH"
1212

13-
# 设置工作目录
13+
# Set working directory
1414
WORKDIR /app
1515

16-
# 安装系统依赖(合并为一个RUN命令减少层数)
16+
# Install system dependencies (combine into one RUN command to reduce layers)
1717
RUN apt-get update && apt-get install -y --no-install-recommends \
1818
curl git ffmpeg libsm6 libxext6 xvfb xauth x11-utils \
19-
build-essential python3-dev \
19+
build-essential python3-dev vim\
2020
&& apt-get clean \
2121
&& rm -rf /var/lib/apt/lists/*
2222

23-
# 安装uv工具
23+
# Install uv tool
2424
RUN pip install uv
2525

26-
# 复制构建项目文件
26+
# Copy project build files
2727
COPY pyproject.toml .
2828
COPY README.md .
29-
# 如果README.md不存在则创建
30-
RUN if [ ! -f "README.md" ]; then echo -e "# OWL Project\n\n这是OWL项目的Docker环境。" > README.md; fi
29+
# Create README.md if it doesn't exist
30+
RUN if [ ! -f "README.md" ]; then echo -e "# OWL Project\n\nThis is the Docker environment for the OWL project." > README.md; fi
3131

32-
# 创建虚拟环境并安装依赖
32+
# Create virtual environment and install dependencies
3333
RUN uv venv .venv --python=3.10 && \
3434
. .venv/bin/activate && \
3535
uv pip install -e .
3636

37-
# 复制运行项目文件
37+
# Copy project runtime files
3838
COPY owl/ ./owl/
3939
COPY licenses/ ./licenses/
4040
COPY assets/ ./assets/
4141
COPY README_zh.md .
4242

43-
44-
# 创建启动脚本
43+
# Create startup script
4544
RUN echo '#!/bin/bash\nxvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" python "$@"' > /usr/local/bin/xvfb-python && \
4645
chmod +x /usr/local/bin/xvfb-python
4746

48-
# 创建欢迎脚本
49-
RUN echo '#!/bin/bash\necho "欢迎使用OWL项目Docker环境!"\necho "Welcome to OWL Project Docker environment!"\necho ""\necho "可用的脚本 | Available scripts:"\nls -1 *.py | grep -v "__" | sed "s/^/- /"\necho ""\necho "运行示例 | Run examples:"\necho " xvfb-python run.py # 运行默认脚本 | Run default script"\necho " xvfb-python run_deepseek_example.py # 运行DeepSeek示例 | Run DeepSeek example"\necho ""\necho "或者使用自定义查询 | Or use custom query:"\necho " xvfb-python run.py \"你的问题 | Your question\""\necho ""' > /usr/local/bin/owl-welcome && \
47+
# Create welcome script
48+
RUN echo '#!/bin/bash\necho "Welcome to the OWL Project Docker environment!"\necho "Welcome to OWL Project Docker environment!"\necho ""\necho "Available scripts:"\nls -1 *.py | grep -v "__" | sed "s/^/- /"\necho ""\necho "Run examples:"\necho " xvfb-python run.py # Run default script"\necho " xvfb-python run_deepseek_example.py # Run DeepSeek example"\necho ""\necho "Or use custom query:"\necho " xvfb-python run.py \"Your question\""\necho ""' > /usr/local/bin/owl-welcome && \
5049
chmod +x /usr/local/bin/owl-welcome
5150

52-
# 设置工作目录
51+
# Set working directory
5352
WORKDIR /app/owl
5453

55-
# 添加健康检查
54+
# Add health check
5655
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
5756
CMD python -c "import sys; sys.exit(0 if __import__('os').path.exists('/app/owl') else 1)"
5857

59-
# 容器启动命令
58+
# Container startup command
6059
CMD ["/bin/bash", "-c", "owl-welcome && /bin/bash"]

.container/docker-compose.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ services:
1010
# dockerfile: .container/Dockerfile
1111

1212
volumes:
13-
# 挂载.env文件,方便配置API密钥
13+
# Mount .env file for easy API key configuration
1414
- ../owl/.env:/app/owl/.env
15-
# 挂载example文件夹,以支持docker容器内运行代码案例
15+
# Mount examples folder to support running code examples inside the Docker container
1616
- ../examples:/app/examples
17-
# 挂载数据目录
17+
# Mount data directory
1818
- ./data:/app/owl/data
19-
# 挂载缓存目录,避免重复下载
19+
# Mount cache directories to avoid repeated downloads
2020
- ~/.cache/pip:/root/.pip/cache
2121
- ~/.cache/playwright:/root/.cache/ms-playwright
2222
environment:
@@ -25,18 +25,21 @@ services:
2525
- PYTHONDONTWRITEBYTECODE=1
2626
- PYTHONUNBUFFERED=1
2727
- TERM=xterm-256color
28+
- GRADIO_SERVER_NAME=0.0.0.0
29+
- GRADIO_SERVER_PORT=7860
30+
- PYTHONPATH=.
2831
ports:
2932
- "7860:7860"
3033
stdin_open: true
3134
tty: true
3235
shm_size: 2gb
33-
# 简化资源限制
36+
# Simplify resource limits
3437
deploy:
3538
resources:
3639
limits:
3740
memory: 4G
3841

39-
# 定义持久化卷,用于缓存 | Define persistent volumes for caching
42+
# Define persistent volumes for caching
4043
volumes:
4144
playwright-cache:
42-
pip-cache:
45+
pip-cache:

owl/webapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def main():
12871287
app = create_ui()
12881288

12891289
app.queue()
1290-
app.launch(share=False, server_name="127.0.0.1", server_port=7860)
1290+
app.launch(share=False)
12911291
except Exception as e:
12921292
logging.error(f"Error occurred while starting the application: {str(e)}")
12931293
print(f"Error occurred while starting the application: {str(e)}")

owl/webapp_zh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ def main():
12571257
app = create_ui()
12581258

12591259
app.queue()
1260-
app.launch(share=False, server_name="127.0.0.1", server_port=7860)
1260+
app.launch(share=False)
12611261
except Exception as e:
12621262
logging.error(f"启动应用程序时发生错误: {str(e)}")
12631263
print(f"启动应用程序时发生错误: {str(e)}")

0 commit comments

Comments
 (0)