StarrySkyWorld commited on
Commit
c36f16f
·
verified ·
1 Parent(s): 1635285

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -10
Dockerfile CHANGED
@@ -5,7 +5,7 @@ ENV PYTHONUNBUFFERED=1 \
5
  DISPLAY=:99 \
6
  DEBIAN_FRONTEND=noninteractive
7
 
8
- # 2. 安装系统依赖 (修复了 Debian Trixie 的库名)
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
  wget gnupg curl git xvfb unzip \
11
  fonts-liberation libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 \
@@ -15,26 +15,28 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
15
  && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
16
  && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
17
  && apt-get update && apt-get install -y --no-install-recommends google-chrome-stable \
18
- && apt-get clean && rm -rf /var/lib/apt/lists/*
 
19
 
20
  # 3. 设置 HF 要求的用户
21
  RUN useradd -m -u 1000 user
22
  USER user
23
  WORKDIR /home/user/app
24
 
25
- # 4. 克隆代码
26
- RUN git clone --depth 1 https://github.com/Starry-Sky-World/gar.git .
 
27
 
28
- # 5. 核心修复:直接使用 pip 安装,并强制安装 setuptools
29
- # 同时处理目录结构:如果文件在 py/ 文件夹里,就移动到根目录,防止找不到 server.py
30
- RUN if [ -d "py" ]; then cp -r py/* . && rm -rf py; fi && \
31
- pip install --no-cache-dir --upgrade pip setuptools && \
32
- pip install --no-cache-dir flask werkzeug undetected-chromedriver selenium pyyaml faker requests webdavclient3
33
 
34
  # 6. 配置文件
35
  RUN cp config.example.yaml config.yaml 2>/dev/null || true
36
 
37
  EXPOSE 7860
38
 
39
- # 7. 启动脚本:确保 Xvfb 运行并直接用系统 python 启动
40
  CMD ["sh", "-c", "Xvfb :99 -screen 0 1920x1080x24 & sleep 3 && python server.py"]
 
5
  DISPLAY=:99 \
6
  DEBIAN_FRONTEND=noninteractive
7
 
8
+ # 2. 安装系统依赖 (包含 Chrome)
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
  wget gnupg curl git xvfb unzip \
11
  fonts-liberation libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 \
 
15
  && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
16
  && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
17
  && apt-get update && apt-get install -y --no-install-recommends google-chrome-stable \
18
+ && apt-get clean && rm -rf /var/lib/apt/lists/* \
19
+ && pip install --no-cache-dir uv
20
 
21
  # 3. 设置 HF 要求的用户
22
  RUN useradd -m -u 1000 user
23
  USER user
24
  WORKDIR /home/user/app
25
 
26
+ # 4. 克隆代码并强制整理目录结构
27
+ RUN git clone --depth 1 https://github.com/Starry-Sky-World/gar.git . && \
28
+ if [ -d "py" ]; then cp -r py/* . ; fi
29
 
30
+ # 5. 核心修复:自动读取项目依赖文件并安装到系统路径
31
+ # 额外强制安装 waitress (解决刚才的报错) 和 setuptools (解决 distutils 报错)
32
+ RUN uv pip install --system --no-cache . 2>/dev/null || \
33
+ uv pip install --system --no-cache -r pyproject.toml 2>/dev/null || \
34
+ pip install --no-cache-dir flask waitress setuptools undetected-chromedriver selenium pyyaml faker requests webdavclient3
35
 
36
  # 6. 配置文件
37
  RUN cp config.example.yaml config.yaml 2>/dev/null || true
38
 
39
  EXPOSE 7860
40
 
41
+ # 7. 启动
42
  CMD ["sh", "-c", "Xvfb :99 -screen 0 1920x1080x24 & sleep 3 && python server.py"]