File size: 1,623 Bytes
64d2302
479d477
64d2302
36b1c99
 
 
 
 
8bff7be
29596c9
81d504c
29596c9
72f50ec
29596c9
 
 
039d66a
36b1c99
 
0ac42ac
d1a58fa
36b1c99
 
 
29596c9
3c9b666
 
 
 
 
 
36b1c99
 
ab0112d
29596c9
 
 
 
 
 
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
39
40
41
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"]