Files
banana-disease-leaf/Dockerfile
zhenghu 86541eb55e feat: 初始化香蕉叶病害智能识别系统
基于 ViT 视觉变换器实现香蕉叶片病害分类应用,支持 7 类病害识别。

  - app.py: Streamlit 前端应用,包含图片上传、病害识别、置信度图表展示及防治建议
  - pyproject.toml: 项目配置,声明 Python 3.14 及依赖(streamlit、transformers、torch、plotly 等)
  - uv.lock: 依赖版本锁定文件
  - Dockerfile: 基于 uv 镜像的容器化部署配置,含健康检查
  - justfile: 常用开发任务脚本(run、install、format、check 等)
  - main.py: 命令行入口
  - .doc/: 模型使用说明文档

  模型来源: Dmitry43243242/banana-disease-leaf-model (HuggingFace)
2026-04-15 11:25:57 +08:00

45 lines
1.3 KiB
Docker
Raw Permalink 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"]