Files
yield-smart-app/Dockerfile
zhenghu 9cb70267b6 feat: 初始化 YieldSmart 农业智能决策系统
基于多因子 Cobb-Douglas 产量模型的作物种植决策支持应用。

  新增文件:
  - app.py: Streamlit 主应用,包含产量预测模型、多作物数据库、
    雷达图/敏感性分析可视化、作物推荐排行及智能建议面板
  - main.py: 入口文件
  - pyproject.toml: 项目配置(Python 3.14+,依赖 streamlit/plotly/pandas/numpy)
  - Dockerfile: 基于 uv 镜像的容器化部署配置
  - justfile: 任务自动化(运行/格式化/检查/清理)
  - .gitignore: Python/IDE/缓存忽略规则
2026-04-13 17:45:14 +08:00

44 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/
# 安装 Python 依赖(使用 uv锁定版本
RUN uv sync --frozen --no-dev
# 复制应用代码和其他文件
COPY . .
# 暴露 Streamlit 默认端口
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"]