gallyg commited on
Commit
085c4b4
·
verified ·
1 Parent(s): e76f9c3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -10
Dockerfile CHANGED
@@ -1,27 +1,38 @@
 
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
  RUN chown -R user:user /app
 
8
 
 
9
  USER user
10
  ENV PATH="/home/user/.local/bin:$PATH"
11
 
12
- RUN git clone https://github.com/cnlimiter/codex-register.git .
13
-
14
- # 安装依赖 + huggingface_hub
15
  RUN pip install --no-cache-dir -r requirements.txt huggingface_hub
16
 
17
- # 创建目录
18
  RUN mkdir -p data logs
19
 
20
- # 复制刚才写的同步脚本到镜像里
21
- # (如果你是直接在 HF 页面创建文件的,此步可以忽略,只要文件在根目录即可)
22
- # COPY --chown=user:user sync_run.py .
23
-
24
  EXPOSE 7860
25
 
26
- # 启动改为运行同步脚本
27
- CMD ["python", "sync_run.py"]
 
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/cnlimiter/codex-register.git .
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"]