FROM python:3.11 # 安装系统依赖 RUN apt-get update && \ apt-get install -y ca-certificates curl gnupg && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # 克隆DeepClaude仓库 RUN git clone https://github.com/ErlichLiu/DeepClaude.git /app WORKDIR /app # 安装必要的依赖 RUN pip install --no-cache-dir fastapi uvicorn python-dotenv huggingface_hub # 自动检测可能需要的其他依赖 RUN grep -r "import" --include="*.py" /app | grep -v "from app" | sort | uniq | \ grep -oP "(?<=import )[a-zA-Z0-9_]+|(?<=from )[a-zA-Z0-9_]+" | sort | uniq | \ xargs -I{} pip install --no-cache-dir {} || true # 如果仓库中有requirements.txt,也安装 RUN if [ -f requirements.txt ]; then \ pip install --no-cache-dir -r requirements.txt; \ fi # 创建数据目录并赋予权限 RUN mkdir -p /app/data && chmod -R 777 /app/data RUN mkdir -p /tmp/.cache && chmod -R 777 /tmp/.cache ENV HF_HOME=/tmp/.cache/huggingface \ HF_HUB_DISABLE_SYMLINKS_WARNING=1 \ HF_HUB_DISABLE_PROGRESS_BARS=1 \ HF_HUB_CACHE=/tmp/.cache/huggingface \ HUGGINGFACE_HUB_CACHE=/tmp/.cache/huggingface # 创建.env文件 RUN touch .env # 暴露端口 EXPOSE 7860 # 将外部备份脚本复制到容器内 COPY sync_data.sh /app/sync_data.sh RUN chmod +x /app/sync_data.sh # 关键修复:将整个 /app 目录权限开放,避免权限问题 RUN chmod -R 777 /app # 使用备份脚本启动服务 CMD ["/app/sync_data.sh"]