Spaces:
Paused
Paused
| FROM python:3.11-slim | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| HOME=/home/user \ | |
| XDG_CACHE_HOME=/home/user/.cache \ | |
| SELENIUM_MANAGER_CACHE_DIR=/home/user/.cache/selenium \ | |
| TMPDIR=/tmp \ | |
| PORT=7860 \ | |
| DISPLAY=:99 | |
| # NOTE: ตัด chromium-driver ทิ้งเพื่อลดปัญหา version mismatch กับตัวจัดการไดรเวอร์ของ SeleniumBase/UC | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| xvfb chromium \ | |
| libgtk-3-0 libatk-bridge2.0-0 libxcomposite1 libxrandr2 libxdamage1 \ | |
| libgbm1 libnss3 libxss1 libasound2 libxshmfence1 fonts-liberation ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN mkdir -p /home/user/.cache /home/user/.local /app && chmod -R 777 /home/user /tmp /app | |
| WORKDIR /app | |
| COPY requirements.txt /app/ | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # (คงไว้ตามของเดิม เพื่อโฟลเดอร์ drivers เขียนได้) | |
| RUN python - <<'PY' | |
| import sysconfig, pathlib, os | |
| p = pathlib.Path(sysconfig.get_paths()['purelib'])/'seleniumbase'/'drivers' | |
| p.mkdir(parents=True, exist_ok=True) | |
| os.system(f"chmod -R a+rwX {p}") | |
| PY | |
| COPY app.py /app/app.py | |
| # entrypoint แบบชัด ๆ (เช็ค xvfb-run, echo แล้ว exec ด้วย set -x ให้เห็นคำสั่ง) | |
| COPY start.sh /app/start.sh | |
| RUN chmod +x /app/start.sh | |
| # สำคัญ: ใส่ access/error logfile เป็น "-" เพื่อให้ไป stdout/stderr แล้ว HF เก็บ log ให้ | |
| CMD ["/app/start.sh"] | |