countclaw commited on
Commit
29c0b7d
·
verified ·
1 Parent(s): 91f07b0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -26
Dockerfile CHANGED
@@ -1,38 +1,37 @@
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/CountClaw/grok2api-hf .
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 8000
36
 
37
- # 启动脚本
38
- CMD ["python", "/app/sync_run.py"]
 
1
+ FROM python:3.13-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1 \
4
+ PYTHONUNBUFFERED=1 \
5
+ PIP_NO_CACHE_DIR=1 \
6
+ SERVER_HOST=0.0.0.0 \
7
+ SERVER_PORT=8000 \
8
+ SERVER_WORKERS=1 \
9
+ LOG_FILE_ENABLED=false \
10
+ DATA_DIR=/app/grok2api/data \
11
+ LOG_DIR=/app/grok2api/logs
12
+
13
+ ARG SOURCE_REPO=https://github.com/CountClaw/grok2api-hf.git
14
+ ARG SOURCE_REF=main
15
+
16
+ RUN apt-get update && apt-get install -y --no-install-recommends \
17
+ ca-certificates \
18
+ git \
19
+ && rm -rf /var/lib/apt/lists/*
20
 
 
 
 
 
21
  RUN useradd -m -u 1000 user
 
22
 
23
+ WORKDIR /app
 
24
 
25
+ RUN git clone --depth 1 --branch ${SOURCE_REF} ${SOURCE_REPO} /app/grok2api
 
26
 
 
27
  COPY sync_run.py /app/sync_run.py
28
 
29
+ RUN python -m pip install --upgrade pip \
30
+ && python -m pip install -r /app/grok2api/requirements.txt huggingface_hub \
31
+ && chown -R user:user /app
32
 
 
33
  USER user
 
 
 
 
 
 
 
34
 
 
35
  EXPOSE 8000
36
 
37
+ CMD ["python", "/app/sync_run.py"]