File size: 1,257 Bytes
e51e040
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71a5f23
 
f0805e2
e51e040
 
 
 
 
 
 
 
 
 
71a5f23
 
 
 
 
e51e040
 
71a5f23
 
 
 
e51e040
 
c53a149
e51e040
 
c53a149
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
# Use Python 3.11 as the base image
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    libglib2.0-0 \
    libnss3 \
    libnspr4 \
    libdbus-1-3 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdrm2 \
    libxkbcommon0 \
    libatspi2.0-0 \
    libxcomposite1 \
    libxdamage1 \
    libxext6 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libpango-1.0-0 \
    libcairo2 \
    libasound2 \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -u 1000 appuser

# Copy pyproject.toml and install Python dependencies
COPY pyproject.toml .
RUN pip install -e .

# Copy the application code
COPY . .

# Install playwright
RUN playwright install

# Create directory for crawl4ai and set permissions
RUN mkdir -p /home/appuser/.crawl4ai && \
    chown -R appuser:appuser /home/appuser/.crawl4ai && \
    chown -R appuser:appuser /app

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV HOME=/home/appuser

# Switch to non-root user
USER appuser

# Expose the port the app runs on
EXPOSE 7860

# Command to run the FastAPI application with uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]