kltn20133118 commited on
Commit
c95c0e2
·
verified ·
1 Parent(s): fbc563c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -43
Dockerfile CHANGED
@@ -1,63 +1,48 @@
1
  FROM mcr.microsoft.com/playwright:v1.49.0-noble
2
 
3
- RUN apt install python3.12-venv
4
- # Cài đặt thư viện hệ thống cần thiết
5
- RUN apt-get update && apt-get install -y --no-install-recommends \
6
- libglib2.0-0 \
7
- libnss3 \
8
- libnspr4 \
 
 
 
 
 
9
  libatk1.0-0 \
10
  libatk-bridge2.0-0 \
11
  libcups2 \
12
- libdrm2 \
13
- libdbus-1-3 \
14
- libxcb1 \
15
- libxkbcommon0 \
16
- libx11-6 \
17
  libxcomposite1 \
18
  libxdamage1 \
19
- libxext6 \
20
- libxfixes3 \
21
- libxrandr2 \
22
- libgbm1 \
23
- libpango-1.0-0 \
24
- libcairo2 \
25
  libatspi2.0-0 \
26
- ffmpeg \
27
- libsm6 \
28
- poppler-utils \
29
  chromium \
 
30
  && rm -rf /var/lib/apt/lists/*
31
 
32
- # Đảm bảo quyền truy cập cho thư mục /code
33
- RUN mkdir /code && \
34
- chown -R pwuser:pwuser /code
35
-
36
- # Chuyển sang người dùng pwuser (đã tồn tại trong base image)
37
- USER pwuser
38
-
39
- # Thiết lập thư mục làm việc
40
- WORKDIR /code
41
 
42
- # Cài đặt môi trường ảo Python và các gói yêu cầu
43
- RUN python3 -m venv /code/venv && \
44
- /code/venv/bin/pip install --no-cache-dir --upgrade pip setuptools wheel
45
 
46
- # Cài đặt Playwright và các thư viện Python
47
- RUN /code/venv/bin/pip install playwright && \
48
- /code/venv/bin/playwright install && \
49
- /code/venv/bin/playwright install-deps
 
50
 
51
- # Cài đặt các thư viện yêu cầu từ requirements.txt
52
  COPY ./requirements.txt /code/requirements.txt
53
- RUN /code/venv/bin/pip install --no-cache-dir --upgrade -r /code/requirements.txt
54
 
55
- # Sao chép mã nguồn vào container
56
  COPY . .
57
 
58
- # Mở các cổng cần thiết cho ứng dụng
59
  EXPOSE 7860
60
- EXPOSE 9222
61
 
62
- # Khởi động ứng dụng khi container chạy
63
- CMD ["/code/venv/bin/uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM mcr.microsoft.com/playwright:v1.49.0-noble
2
 
3
+ WORKDIR /code
4
+
5
+
6
+ # Cài đặt các gói phụ thuộc cho Python, Playwright và Chromium
7
+ RUN apt-get update && apt-get install -y \
8
+ python3-pip \
9
+ python3-venv \
10
+ ffmpeg \
11
+ libsm6 \
12
+ libxext6 \
13
+ poppler-utils \
14
  libatk1.0-0 \
15
  libatk-bridge2.0-0 \
16
  libcups2 \
 
 
 
 
 
17
  libxcomposite1 \
18
  libxdamage1 \
 
 
 
 
 
 
19
  libatspi2.0-0 \
 
 
 
20
  chromium \
21
+ && apt-get clean \
22
  && rm -rf /var/lib/apt/lists/*
23
 
24
+ # Tạo môi trường ảo Python
25
+ RUN python3 -m venv /code/venv
26
+ ENV PATH="/code/venv/bin:$PATH"
 
 
 
 
 
 
27
 
28
+ # Cập nhật pip trong môi trường ảo
29
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel
 
30
 
31
+ # Cài đặt Playwright và các thư viện Playwright cần thiết
32
+ RUN pip install playwright
33
+ RUN playwright install
34
+ RUN playwright install-deps
35
+ RUN playwright install chromium
36
 
37
+ # Sao chép mã nguồn và cài đặt các thư viện Python từ requirements.txt
38
  COPY ./requirements.txt /code/requirements.txt
39
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
40
 
41
+ # Sao chép toàn bộ mã nguồn vào container
42
  COPY . .
43
 
44
+ # Mở các cổng cần thiết
45
  EXPOSE 7860
 
46
 
47
+ # Khởi động ứng dụng với Uvicorn
48
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]