Spaces:
Sleeping

judicial_scraper_2 / Dockerfile
drew3952's picture
Upload 4 files
bc0514c verified
Raw History Blame Contribute Delete
1.22 kB
FROM python:3.10-slim
# ---------- 1. 以 root 安裝系統相依套件 ----------
RUN apt-get update && apt-get install -y \
curl wget gnupg unzip fonts-liberation libnss3 libatk1.0-0 \
libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 \
libxdamage1 libxrandr2 libgbm1 libasound2 libpangocairo-1.0-0 \
libgtk-3-0 xvfb libxshmfence1 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# ---------- 2. 建立非 root 帳號(HF 會用 uid 1000 啟動) ----------
RUN useradd -m -u 1000 user
# ---------- 3. 切換至 user;往後動作都以 user 身分 ----------
USER user
WORKDIR /home/user/app
# 將本機 requirements 複製進容器
COPY requirements.txt .
# ---------- 4. 以 user 安裝 Python 套件 ----------
RUN pip install --no-cache-dir -r requirements.txt
# (pip 安裝在 ~/.local/bin,讓它出現在 PATH )
ENV PATH="/home/user/.local/bin:${PATH}"
# ---------- 5. 以 user 安裝 Playwright **瀏覽器** ----------
# 此時系統依賴已齊全,不需要 --with-deps,也不需要 root
RUN python -m playwright install chromium
# ---------- 6. 複製程式碼 ----------
COPY . .
# ---------- 7. 啟動 Gradio App ----------
CMD ["python", "app.py"]