# TSP智能助手Docker镜像 - 优化版本 FROM python:3.11-slim # 设置工作目录 WORKDIR /app # 设置环境变量 ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV PIP_NO_CACHE_DIR=1 ENV PIP_DISABLE_PIP_VERSION_CHECK=1 # 安装系统依赖 RUN apt-get update && apt-get install -y \ gcc \ g++ \ git \ curl \ wget \ vim \ htop \ procps \ && rm -rf /var/lib/apt/lists/* # 升级pip并安装wheel RUN pip install --upgrade pip setuptools wheel # 复制依赖文件 COPY requirements.txt . # 安装Python依赖 RUN pip install --no-cache-dir -r requirements.txt # 复制应用代码 COPY . . # 创建必要目录 RUN mkdir -p logs data backups uploads config # 设置权限 RUN chmod +x scripts/deploy.sh scripts/monitor.sh # 创建非root用户 RUN useradd -m -u 1000 tspuser && \ chown -R tspuser:tspuser /app USER tspuser # 暴露端口 EXPOSE 5000 8765 # 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:5000/api/health || exit 1 # 启动命令 CMD ["python", "start_dashboard.py"]