Update Dockerfile
Browse files- Dockerfile +9 -19
Dockerfile
CHANGED
|
@@ -1,38 +1,28 @@
|
|
| 1 |
-
# 使用官方 Python 轻量级镜像
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
-
# 安装 Git 及必要工具
|
| 5 |
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*
|
| 6 |
|
| 7 |
-
# Hugging Face 强制要求使用非 root 用户运行
|
| 8 |
RUN useradd -m -u 1000 user
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
-
# 先切换到 root 权限进行克隆和复制
|
| 12 |
USER root
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
RUN git clone https://github.com/dou-jiang/codex-console .
|
| 16 |
-
|
| 17 |
-
# 2. 【关键步骤】将你在 HF 网页创建的 sync_run.py 复制到容器的 /app 目录
|
| 18 |
COPY sync_run.py /app/sync_run.py
|
|
|
|
| 19 |
|
| 20 |
-
# 3. 赋予权限
|
| 21 |
-
RUN chown -R user:user /app
|
| 22 |
-
RUN chmod +x /app/sync_run.py
|
| 23 |
-
|
| 24 |
-
# 切换回 user 身份
|
| 25 |
USER user
|
| 26 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 27 |
|
| 28 |
-
# 安装
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
RUN mkdir -p data logs
|
| 33 |
|
| 34 |
-
# 暴露端口
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
-
# 启动脚本
|
| 38 |
CMD ["python", "/app/sync_run.py"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
|
|
|
| 3 |
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*
|
| 4 |
|
|
|
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
WORKDIR /app
|
| 7 |
|
|
|
|
| 8 |
USER root
|
| 9 |
+
# 克隆新项目
|
| 10 |
+
RUN git clone https://github.com/dou-jiang/codex-console.git .
|
| 11 |
|
| 12 |
+
# 复制同步脚本
|
|
|
|
|
|
|
|
|
|
| 13 |
COPY sync_run.py /app/sync_run.py
|
| 14 |
+
RUN chown -R user:user /app && chmod +x /app/sync_run.py
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
USER user
|
| 17 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 18 |
|
| 19 |
+
# 【修复核心】强制安装兼容版本的 Jinja2 和 FastAPI 相关的组件
|
| 20 |
+
# 解决 TypeError: unhashable type: 'dict' 错误
|
| 21 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
+
RUN pip install --no-cache-dir huggingface_hub "jinja2<=3.0.3" "starlette>=0.27.0"
|
| 23 |
|
| 24 |
+
RUN mkdir -p data logs output
|
|
|
|
| 25 |
|
|
|
|
| 26 |
EXPOSE 7860
|
| 27 |
|
|
|
|
| 28 |
CMD ["python", "/app/sync_run.py"]
|