feature: 启动时不下载依赖包
This commit is contained in:
13
Dockerfile
13
Dockerfile
@@ -1,11 +1,12 @@
|
|||||||
# 使用 Python 3.11 作为基础镜像
|
# 使用 Python 3.11 作为基础镜像
|
||||||
FROM 172.16.102.3:30648/astral-sh/uv:python3.14-bookworm
|
FROM 172.16.102.3:30648/astral-sh/uv:python3.11-bookworm
|
||||||
|
|
||||||
# 设置工作目录
|
# 设置工作目录
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 配置 uv 使用清华 PyPI 镜像源
|
# 配置 uv 使用清华 PyPI 镜像源,并禁用启动时自动同步
|
||||||
ENV UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
ENV UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
ENV UV_NO_SYNC=1
|
||||||
|
|
||||||
# 安装系统依赖
|
# 安装系统依赖
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
@@ -18,8 +19,8 @@ COPY pyproject.toml uv.lock ./
|
|||||||
COPY main.py ./
|
COPY main.py ./
|
||||||
COPY README.md ./
|
COPY README.md ./
|
||||||
|
|
||||||
# 使用 uv 安装依赖
|
# 使用 uv 安装依赖到系统环境
|
||||||
RUN uv sync --frozen
|
RUN uv sync --frozen --no-dev
|
||||||
|
|
||||||
# 暴露 Streamlit 端口
|
# 暴露 Streamlit 端口
|
||||||
EXPOSE 8501
|
EXPOSE 8501
|
||||||
@@ -28,6 +29,6 @@ EXPOSE 8501
|
|||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
CMD python -c "import requests; requests.get('http://localhost:8501/_stcore/health')"
|
CMD python -c "import requests; requests.get('http://localhost:8501/_stcore/health')"
|
||||||
|
|
||||||
# 运行 Streamlit 应用
|
# 运行 Streamlit 应用,直接使用虚拟环境中的 streamlit
|
||||||
CMD ["uv", "run", "streamlit", "run", "main.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
CMD [".venv/bin/streamlit", "run", "main.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user