gallyg commited on
Commit
2177a43
·
verified ·
1 Parent(s): 8e7f322

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -19
Dockerfile CHANGED
@@ -1,38 +1,36 @@
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
- # 1. 克隆远程项目代码到当前目录
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
- RUN pip install --no-cache-dir -r requirements.txt huggingface_hub
 
 
 
 
 
 
 
 
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
+ # 安装系统基础工具
4
  RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*
5
 
 
6
  RUN useradd -m -u 1000 user
7
  WORKDIR /app
8
 
 
9
  USER root
10
+ # 克隆项目
11
+ RUN git clone https://github.com/dou-jiang/codex-console.git .
12
 
13
+ # 复制同步脚本
 
 
 
14
  COPY sync_run.py /app/sync_run.py
15
+ RUN chown -R user:user /app && chmod +x /app/sync_run.py
16
 
 
 
 
 
 
17
  USER user
18
  ENV PATH="/home/user/.local/bin:$PATH"
19
 
20
+ # --- 关键修复步骤 ---
21
+ # 1. 先安装项目自带的依赖
22
+ RUN pip install --no-cache-dir -r requirements.txt
23
+
24
+ # 2. 强制安装黄金组合:既保留新版 Pydantic V2,又锁死兼容的 Starlette 0.27.0
25
+ RUN pip install --no-cache-dir --force-reinstall \
26
+ "fastapi==0.104.1" \
27
+ "starlette==0.27.0" \
28
+ "pydantic>=2.4.0" \
29
+ "huggingface_hub"
30
 
31
+ RUN mkdir -p data logs output
 
32
 
 
33
  EXPOSE 7860
34
 
35
+ # 启动同步脚本(注意 CMD 后面的空格已经补上)
36
  CMD ["python", "/app/sync_run.py"]