kltn20133118 commited on
Commit
2ef966b
·
verified ·
1 Parent(s): d46d417

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -81
Dockerfile CHANGED
@@ -1,97 +1,46 @@
1
- # syntax=docker/dockerfile:1.4
2
 
3
- ARG TARGETPLATFORM
4
- ARG BUILDPLATFORM
5
 
6
- # Other build arguments
7
- ARG PYTHON_VERSION=3.10
8
-
9
- # Base stage with system dependencies
10
- FROM python:${PYTHON_VERSION}-slim as base
11
-
12
- # Declare ARG variables again within the build stage
13
- ARG INSTALL_TYPE=all
14
- ARG ENABLE_GPU=false
15
-
16
-
17
- # Install system dependencies
18
- RUN apt-get update && apt-get install -y --no-install-recommends \
19
- build-essential \
20
- curl \
21
- wget \
22
- gnupg \
23
- git \
24
- cmake \
25
- pkg-config \
26
- python3-dev \
27
- libjpeg-dev \
28
- libpng-dev \
29
- && rm -rf /var/lib/apt/lists/*
30
-
31
- # Playwright system dependencies for Linux
32
- RUN apt-get update && apt-get install -y --no-install-recommends \
33
- libglib2.0-0 \
34
- libnss3 \
35
- libnspr4 \
36
  libatk1.0-0 \
37
  libatk-bridge2.0-0 \
38
  libcups2 \
39
- libdrm2 \
40
- libdbus-1-3 \
41
- libxcb1 \
42
- libxkbcommon0 \
43
- libx11-6 \
44
  libxcomposite1 \
45
  libxdamage1 \
46
- libxext6 \
47
- libxfixes3 \
48
- libxrandr2 \
49
- libgbm1 \
50
- libpango-1.0-0 \
51
- libcairo2 \
52
- libasound2 \
53
  libatspi2.0-0 \
 
 
54
  && rm -rf /var/lib/apt/lists/*
55
 
56
- # GPU support if enabled and architecture is supported
57
- RUN if [ "$ENABLE_GPU" = "true" ] && [ "$TARGETPLATFORM" = "linux/amd64" ] ; then \
58
- apt-get update && apt-get install -y --no-install-recommends \
59
- nvidia-cuda-toolkit \
60
- && rm -rf /var/lib/apt/lists/* ; \
61
- else \
62
- echo "Skipping NVIDIA CUDA Toolkit installation (unsupported platform or GPU disabled)"; \
63
- fi
64
 
65
- # Create and set working directory
66
- WORKDIR /app
67
-
68
- # Copy the entire project
69
- COPY . .
70
-
71
-
72
- RUN pip install --no-cache-dir -r requirements.txt
73
-
74
- # Install required library for FastAPI
75
- RUN pip install fastapi uvicorn psutil
76
-
77
- # Install ML dependencies first for better layer caching
78
- RUN if [ "$INSTALL_TYPE" = "all" ] ; then \
79
- pip install --no-cache-dir \
80
- torch \
81
- torchvision \
82
- torchaudio \
83
- scikit-learn \
84
- nltk \
85
- transformers \
86
- tokenizers && \
87
- python -m nltk.downloader punkt stopwords ; \
88
- fi
89
 
 
 
 
 
90
 
91
- # Install Playwright and browsers
 
 
92
  RUN playwright install chromium
 
93
 
94
- EXPOSE 8000 11235 9222 8080
 
 
95
 
96
- # Start the FastAPI server
97
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "11235"]
 
1
+ FROM mcr.microsoft.com/playwright:v1.49.0-noble
2
 
3
+ WORKDIR /code
 
4
 
5
+ # Cài đặt các gói phụ thuộc cần thiết
6
+ RUN apt-get update && apt-get install -y \
7
+ python3-pip \
8
+ python3-venv \
9
+ ffmpeg \
10
+ libsm6 \
11
+ libxext6 \
12
+ poppler-utils \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  libatk1.0-0 \
14
  libatk-bridge2.0-0 \
15
  libcups2 \
 
 
 
 
 
16
  libxcomposite1 \
17
  libxdamage1 \
 
 
 
 
 
 
 
18
  libatspi2.0-0 \
19
+ chromium \
20
+ && apt-get clean \
21
  && rm -rf /var/lib/apt/lists/*
22
 
23
+ # Tạo môi trường ảo
24
+ RUN python3 -m venv /code/venv
25
+ ENV PATH="/code/venv/bin:$PATH"
 
 
 
 
 
26
 
27
+ # Cập nhật pip trong môi trường ảo
28
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ # Cài đặt Playwright và các thư viện
31
+ RUN pip install playwright
32
+ RUN playwright install-deps
33
+ RUN playwright install chromium
34
 
35
+ # Sao chép nguồn
36
+ COPY ./requirements.txt /code/requirements.txt
37
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
38
  RUN playwright install chromium
39
+ COPY . .
40
 
41
+ # Mở cổng
42
+ EXPOSE 7860
43
+ EXPOSE 9222
44
 
45
+ # Khởi động ứng dụng
46
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]