- 在 Dockerfile 中复制 vendor/ 目录,确保镜像构建时可用本地 wheel - pyproject.toml 中将 pcse 依赖从 file:///job/pcse 固定为 ==6.0.12 - 配置 uv find-links 指向 ./vendor,解析本地 wheel 源 - 新增 vendor/pcse-6.0.12-py3-none-any.whl,避免依赖外部绝对路径
45 lines
1.2 KiB
Docker
45 lines
1.2 KiB
Docker
# 使用 uv 官方镜像作为基础镜像
|
|
FROM 172.16.102.3:30648/astral-sh/uv:python3.14-bookworm
|
|
|
|
WORKDIR /app
|
|
|
|
# 配置 apt 使用阿里云镜像源
|
|
RUN sed -i 's/httpredir.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 复制项目配置文件与本地 wheel 依赖
|
|
COPY pyproject.toml justfile ./
|
|
COPY vendor/ ./vendor/
|
|
|
|
# 配置 uv 使用阿里云镜像源
|
|
ENV UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ \
|
|
UV_HTTP_TIMEOUT=300
|
|
|
|
# 安装 Python 依赖
|
|
RUN uv sync --no-dev
|
|
|
|
# 复制应用代码
|
|
COPY . .
|
|
|
|
# 暴露端口
|
|
EXPOSE 8000
|
|
|
|
# Streamlit 环境变量
|
|
ENV STREAMLIT_SERVER_PORT=8000 \
|
|
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
|
|
STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false \
|
|
STREAMLIT_SERVER_ENABLE_CORS=false \
|
|
STREAMLIT_SERVER_HEADLESS=true \
|
|
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
|
|
|
# 健康检查
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/_stcore/health || exit 1
|
|
|
|
# 启动应用
|
|
CMD ["uv", "run", "streamlit", "run", "app.py", "--server.port=8000", "--server.address=0.0.0.0"]
|