File size: 1,890 Bytes
0959d97
 
e043ddb
8ac4e47
440bec8
18d116e
0959d97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af658c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f5a6c9
0959d97
af658c7
c2ff1e7
0959d97
 
 
 
 
 
 
c2ff1e7
18d116e
0eeba1b
 
 
 
 
 
 
 
 
 
1f5a6c9
9323725
0eeba1b
 
 
c95c0e2
 
2db03a9
9323725
e258575
 
9323725
1f5a6c9
 
2ef966b
0d18af6
1f5a6c9
0959d97
 
6c40988
af658c7
1f5a6c9
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

# Base stage with system dependencies
FROM python:3.11

# Thiết lập thư mục làm việc
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    curl \
    wget \
    gnupg \
    git \
    cmake \
    pkg-config \
    python3-dev \
    libjpeg-dev \
    libpng-dev \
    && rm -rf /var/lib/apt/lists/*

# Playwright system dependencies for Linux
RUN apt-get update && apt-get install -y --no-install-recommends \
    libglib2.0-0 \
    libnss3 \
    libnspr4 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdrm2 \
    libdbus-1-3 \
    libxcb1 \
    libxkbcommon0 \
    libx11-6 \
    libxcomposite1 \
    libxdamage1 \
    libxext6 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libpango-1.0-0 \
    libcairo2 \
    libasound2 \
    libatspi2.0-0 \
    && rm -rf /var/lib/apt/lists/*
    
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PIP_DEFAULT_TIMEOUT=100 \
    DEBIAN_FRONTEND=noninteractive


# Cài đ?t các bi?n môi trư?ng
ENV HOME=/code
ENV XDG_CACHE_HOME=/code/.cache


USER root
ENV PATH="/home/user/.local/bin:$PATH"

# T?o thư m?c cache và c?p quy?n
RUN mkdir -p /code/.cache && chmod -R 777 /code
# Cài đặt môi trường ảo Python

# Sao chép mã nguồn
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
RUN pip install playwright
RUN playwright install
RUN playwright install-deps
RUN playwright install chromium
RUN pip install --upgrade --ignore-installed playwright
RUN playwright install --with-deps chromium


# Sao chép mã nguồn vào container
COPY . .
RUN pip install crawl4ai

EXPOSE 7860 9222


# Khởi động ứng dụng
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]