update docker (#328)
Browse files- .container/Dockerfile +16 -17
- .container/docker-compose.yml +10 -7
- owl/webapp.py +1 -1
- owl/webapp_zh.py +1 -1
.container/Dockerfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
#
|
4 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
5 |
PYTHONUNBUFFERED=1 \
|
6 |
PIP_NO_CACHE_DIR=0 \
|
@@ -10,51 +10,50 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
10 |
DEBIAN_FRONTEND=noninteractive \
|
11 |
PATH="/app/.venv/bin:$PATH"
|
12 |
|
13 |
-
#
|
14 |
WORKDIR /app
|
15 |
|
16 |
-
#
|
17 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
18 |
curl git ffmpeg libsm6 libxext6 xvfb xauth x11-utils \
|
19 |
-
build-essential python3-dev \
|
20 |
&& apt-get clean \
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
-
#
|
24 |
RUN pip install uv
|
25 |
|
26 |
-
#
|
27 |
COPY pyproject.toml .
|
28 |
COPY README.md .
|
29 |
-
#
|
30 |
-
RUN if [ ! -f "README.md" ]; then echo -e "# OWL Project\n\
|
31 |
|
32 |
-
#
|
33 |
RUN uv venv .venv --python=3.10 && \
|
34 |
. .venv/bin/activate && \
|
35 |
uv pip install -e .
|
36 |
|
37 |
-
#
|
38 |
COPY owl/ ./owl/
|
39 |
COPY licenses/ ./licenses/
|
40 |
COPY assets/ ./assets/
|
41 |
COPY README_zh.md .
|
42 |
|
43 |
-
|
44 |
-
# 创建启动脚本
|
45 |
RUN echo '#!/bin/bash\nxvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" python "$@"' > /usr/local/bin/xvfb-python && \
|
46 |
chmod +x /usr/local/bin/xvfb-python
|
47 |
|
48 |
-
#
|
49 |
-
RUN echo '#!/bin/bash\necho "
|
50 |
chmod +x /usr/local/bin/owl-welcome
|
51 |
|
52 |
-
#
|
53 |
WORKDIR /app/owl
|
54 |
|
55 |
-
#
|
56 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
57 |
CMD python -c "import sys; sys.exit(0 if __import__('os').path.exists('/app/owl') else 1)"
|
58 |
|
59 |
-
#
|
60 |
CMD ["/bin/bash", "-c", "owl-welcome && /bin/bash"]
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
+
# Set environment variables
|
4 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
5 |
PYTHONUNBUFFERED=1 \
|
6 |
PIP_NO_CACHE_DIR=0 \
|
|
|
10 |
DEBIAN_FRONTEND=noninteractive \
|
11 |
PATH="/app/.venv/bin:$PATH"
|
12 |
|
13 |
+
# Set working directory
|
14 |
WORKDIR /app
|
15 |
|
16 |
+
# Install system dependencies (combine into one RUN command to reduce layers)
|
17 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
18 |
curl git ffmpeg libsm6 libxext6 xvfb xauth x11-utils \
|
19 |
+
build-essential python3-dev vim\
|
20 |
&& apt-get clean \
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
+
# Install uv tool
|
24 |
RUN pip install uv
|
25 |
|
26 |
+
# Copy project build files
|
27 |
COPY pyproject.toml .
|
28 |
COPY README.md .
|
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
|
31 |
|
32 |
+
# Create virtual environment and install dependencies
|
33 |
RUN uv venv .venv --python=3.10 && \
|
34 |
. .venv/bin/activate && \
|
35 |
uv pip install -e .
|
36 |
|
37 |
+
# Copy project runtime files
|
38 |
COPY owl/ ./owl/
|
39 |
COPY licenses/ ./licenses/
|
40 |
COPY assets/ ./assets/
|
41 |
COPY README_zh.md .
|
42 |
|
43 |
+
# Create startup script
|
|
|
44 |
RUN echo '#!/bin/bash\nxvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" python "$@"' > /usr/local/bin/xvfb-python && \
|
45 |
chmod +x /usr/local/bin/xvfb-python
|
46 |
|
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 && \
|
49 |
chmod +x /usr/local/bin/owl-welcome
|
50 |
|
51 |
+
# Set working directory
|
52 |
WORKDIR /app/owl
|
53 |
|
54 |
+
# Add health check
|
55 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
56 |
CMD python -c "import sys; sys.exit(0 if __import__('os').path.exists('/app/owl') else 1)"
|
57 |
|
58 |
+
# Container startup command
|
59 |
CMD ["/bin/bash", "-c", "owl-welcome && /bin/bash"]
|
.container/docker-compose.yml
CHANGED
@@ -10,13 +10,13 @@ services:
|
|
10 |
# dockerfile: .container/Dockerfile
|
11 |
|
12 |
volumes:
|
13 |
-
#
|
14 |
- ../owl/.env:/app/owl/.env
|
15 |
-
#
|
16 |
- ../examples:/app/examples
|
17 |
-
#
|
18 |
- ./data:/app/owl/data
|
19 |
-
#
|
20 |
- ~/.cache/pip:/root/.pip/cache
|
21 |
- ~/.cache/playwright:/root/.cache/ms-playwright
|
22 |
environment:
|
@@ -25,18 +25,21 @@ services:
|
|
25 |
- PYTHONDONTWRITEBYTECODE=1
|
26 |
- PYTHONUNBUFFERED=1
|
27 |
- TERM=xterm-256color
|
|
|
|
|
|
|
28 |
ports:
|
29 |
- "7860:7860"
|
30 |
stdin_open: true
|
31 |
tty: true
|
32 |
shm_size: 2gb
|
33 |
-
#
|
34 |
deploy:
|
35 |
resources:
|
36 |
limits:
|
37 |
memory: 4G
|
38 |
|
39 |
-
#
|
40 |
volumes:
|
41 |
playwright-cache:
|
42 |
-
pip-cache:
|
|
|
10 |
# dockerfile: .container/Dockerfile
|
11 |
|
12 |
volumes:
|
13 |
+
# Mount .env file for easy API key configuration
|
14 |
- ../owl/.env:/app/owl/.env
|
15 |
+
# Mount examples folder to support running code examples inside the Docker container
|
16 |
- ../examples:/app/examples
|
17 |
+
# Mount data directory
|
18 |
- ./data:/app/owl/data
|
19 |
+
# Mount cache directories to avoid repeated downloads
|
20 |
- ~/.cache/pip:/root/.pip/cache
|
21 |
- ~/.cache/playwright:/root/.cache/ms-playwright
|
22 |
environment:
|
|
|
25 |
- PYTHONDONTWRITEBYTECODE=1
|
26 |
- PYTHONUNBUFFERED=1
|
27 |
- TERM=xterm-256color
|
28 |
+
- GRADIO_SERVER_NAME=0.0.0.0
|
29 |
+
- GRADIO_SERVER_PORT=7860
|
30 |
+
- PYTHONPATH=.
|
31 |
ports:
|
32 |
- "7860:7860"
|
33 |
stdin_open: true
|
34 |
tty: true
|
35 |
shm_size: 2gb
|
36 |
+
# Simplify resource limits
|
37 |
deploy:
|
38 |
resources:
|
39 |
limits:
|
40 |
memory: 4G
|
41 |
|
42 |
+
# Define persistent volumes for caching
|
43 |
volumes:
|
44 |
playwright-cache:
|
45 |
+
pip-cache:
|
owl/webapp.py
CHANGED
@@ -1287,7 +1287,7 @@ def main():
|
|
1287 |
app = create_ui()
|
1288 |
|
1289 |
app.queue()
|
1290 |
-
app.launch(share=False
|
1291 |
except Exception as e:
|
1292 |
logging.error(f"Error occurred while starting the application: {str(e)}")
|
1293 |
print(f"Error occurred while starting the application: {str(e)}")
|
|
|
1287 |
app = create_ui()
|
1288 |
|
1289 |
app.queue()
|
1290 |
+
app.launch(share=False)
|
1291 |
except Exception as e:
|
1292 |
logging.error(f"Error occurred while starting the application: {str(e)}")
|
1293 |
print(f"Error occurred while starting the application: {str(e)}")
|
owl/webapp_zh.py
CHANGED
@@ -1257,7 +1257,7 @@ def main():
|
|
1257 |
app = create_ui()
|
1258 |
|
1259 |
app.queue()
|
1260 |
-
app.launch(share=False
|
1261 |
except Exception as e:
|
1262 |
logging.error(f"启动应用程序时发生错误: {str(e)}")
|
1263 |
print(f"启动应用程序时发生错误: {str(e)}")
|
|
|
1257 |
app = create_ui()
|
1258 |
|
1259 |
app.queue()
|
1260 |
+
app.launch(share=False)
|
1261 |
except Exception as e:
|
1262 |
logging.error(f"启动应用程序时发生错误: {str(e)}")
|
1263 |
print(f"启动应用程序时发生错误: {str(e)}")
|