File size: 919 Bytes
085c4b4
d5a09b5
 
085c4b4
d5a09b5
 
085c4b4
d5a09b5
 
085c4b4
 
 
 
 
fd7279d
085c4b4
 
 
 
 
d5a09b5
085c4b4
d5a09b5
085c4b4
d5a09b5
 
 
085c4b4
e76f9c3
d5a09b5
085c4b4
d5a09b5
 
085c4b4
47ba321
d5a09b5
085c4b4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 使用官方 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"]