Hana Celeste commited on
Commit
7f79414
·
verified ·
1 Parent(s): efc71b3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -14
Dockerfile CHANGED
@@ -2,25 +2,20 @@ FROM mcr.microsoft.com/playwright/python:v1.40.0-jammy
2
 
3
  WORKDIR /app
4
 
 
5
  RUN apt-get update && apt-get install -y \
6
- fonts-liberation \
7
  libgbm-dev \
 
 
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  COPY requirements.txt .
11
  RUN pip install --no-cache-dir -r requirements.txt
12
-
13
- # --- CHIÊU CUỐI: Cài browser vào đúng đường dẫn nó yêu cầu ---
14
- # Chúng ta không set PLAYWRIGHT_BROWSERS_PATH nữa để nó dùng mặc định của thư viện
15
- RUN python3 -m playwright install chromium
16
-
17
- # Copy ngược browser từ chỗ mặc định sang chỗ nó đang đòi (nếu cần)
18
- RUN mkdir -p /usr/local/lib/python3.10/dist-packages/playwright/driver/package/.local-browsers/ && \
19
- cp -R /root/.cache/ms-playwright/* /usr/local/lib/python3.10/dist-packages/playwright/driver/package/.local-browsers/ || true
20
-
21
- # Cấp quyền thực thi dứt điểm
22
- RUN chmod -R +x /usr/local/lib/python3.10/dist-packages/undetected_playwright/driver/ || true
23
 
24
  COPY . .
25
- ENV PYTHONUNBUFFERED=1
26
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Cài đặt Xvfb và các thư viện đồ họa
6
  RUN apt-get update && apt-get install -y \
7
+ xvfb \
8
  libgbm-dev \
9
+ libnss3 \
10
+ libasound2 \
11
+ fonts-liberation \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
  COPY requirements.txt .
15
  RUN pip install --no-cache-dir -r requirements.txt
16
+ RUN playwright install chromium
 
 
 
 
 
 
 
 
 
 
17
 
18
  COPY . .
19
+
20
+ # Script để chạy Xvfb trước khi chạy Uvicorn
21
+ CMD ["sh", "-c", "Xvfb :99 -screen 0 1920x1080x24 & export DISPLAY=:99 && uvicorn main:app --host 0.0.0.0 --port 7860"]