Files
pest-image-search/Dockerfile
zhenghu ec7c9f8dbe feat: 初始化病虫害以图搜图应用
- 基于 CLIP 模型实现图片相似度搜索(app.py / main.py)
  - 新增 Streamlit 可视化交互界面
  - 新增 pyproject.toml、justfile、Dockerfile 项目配置
  - 补充完整 README 文档(功能介绍、快速开始、Docker 部署)
  - 新增 .gitignore
2026-04-14 16:24:04 +08:00

45 lines
1.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用 uv 官方镜像作为基础镜像(已包含 Python 3.14 和 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/*
# 复制项目配置文件和锁定文件
COPY pyproject.toml justfile uv.lock ./
# 配置 uv 使用阿里云镜像源(通过环境变量)
ENV UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ \
UV_HTTP_TIMEOUT=300
# 安装 Python 依赖(使用 uv锁定版本
RUN uv sync --frozen --no-dev
# 复制应用代码和其他文件
COPY . .
# 暴露端口
EXPOSE 8000
# 设置环境变量
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
# 运行 Streamlit 应用
CMD ["uv", "run", "streamlit", "run", "app.py", "--server.port=8000", "--server.address=0.0.0.0"]