File size: 1,512 Bytes
59bbc6d
 
 
 
e521b70
59bbc6d
 
 
e521b70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60904ca
 
 
59bbc6d
 
 
 
01421d9
 
 
caa5c39
 
 
 
59bbc6d
 
 
 
e521b70
4389e63
e521b70
59bbc6d
 
 
 
f300b39
 
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
FROM python:3.10-slim

WORKDIR /code

# Install system dependencies and playwright dependencies as root
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    xvfb \
    libgbm1 \
    libnss3 \
    libnspr4 \
    libxss1 \
    libasound2 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libdrm2 \
    libgtk-3-0 \
    libxkbcommon0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    libpango-1.0-0 \
    libcairo2 \
    && mkdir -p /etc/apt/sources.list.d \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google.gpg \
    && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
    && apt-get update \
    && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

# Create crawl4ai directory with proper permissions
RUN mkdir -p /.crawl4ai && chmod 777 /.crawl4ai

# Create non-root user early
RUN useradd -m myuser
USER myuser

# Copy requirements and install Python packages
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Install playwright and chromium browser only (no system dependencies)
RUN pip install --user playwright && \
    python -m playwright install chromium

# Copy application code
COPY app.py .

# Run the application using python -m
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]