# 使用官方 Python 轻量级镜像 FROM python:3.11-slim # 安装 Git 及必要工具 RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/* # Hugging Face 强制要求使用非 root 用户运行 RUN useradd -m -u 1000 user WORKDIR /app # 先切换到 root 权限进行克隆和复制 USER root # 1. 克隆远程项目代码到当前目录 RUN git clone https://github.com/dou-jiang/codex-console . # 2. 【关键步骤】将你在 HF 网页创建的 sync_run.py 复制到容器的 /app 目录 COPY sync_run.py /app/sync_run.py # 3. 赋予权限 RUN chown -R user:user /app RUN chmod +x /app/sync_run.py # 切换回 user 身份 USER user ENV PATH="/home/user/.local/bin:$PATH" # 安装依赖 RUN pip install --no-cache-dir -r requirements.txt huggingface_hub # 创建必要目录 RUN mkdir -p data logs # 暴露端口 EXPOSE 7860 # 启动脚本 CMD ["python", "/app/sync_run.py"]