File size: 1,855 Bytes
76be54d
 
 
 
 
 
c01c425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76be54d
 
 
 
 
 
 
c01c425
 
 
 
 
76be54d
 
 
cb5c3f1
 
 
76be54d
 
 
c01c425
 
76be54d
5999508
c01c425
 
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
# Use an official Python runtime as a parent image
FROM python:3.10-slim

# Set the working directory in the container
WORKDIR /app

# Install system dependencies needed by Playwright browsers
# Reference: https://playwright.dev/docs/docker#python
# Using apt-get update before install and cleaning up reduces image size
RUN apt-get update && apt-get install -y --no-install-recommends \
    libnss3 \
    libnspr4 \
    libdbus-glib-1-2 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdrm2 \
    libatspi2.0-0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libpango-1.0-0 \
    libcairo2 \
    libasound2 \
    libxshmfence1 \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements file into the container at /app
COPY requirements.txt .

# Install Python dependencies
# Using --no-cache-dir reduces image size slightly
RUN pip install --no-cache-dir -r requirements.txt

# Install Playwright browsers system-wide WITH dependencies
# This needs to happen *after* pip install crawl4ai (which depends on playwright)
# Using --with-deps installs necessary OS libraries if needed (though we added common ones above)
RUN playwright install --with-deps chromium firefox webkit

# Copy the rest of the application code into the container at /app
COPY . .

# Make port 7860 available to the world outside this container
# Hugging Face Spaces typically expect apps to run on port 7860
EXPOSE 7860

# Define environment variable to ensure Python output is sent straight to logs
ENV PYTHONUNBUFFERED=1
# Set PLAYWRIGHT_BROWSERS_PATH to use the system-wide install
ENV PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright

# Command to run the application using Gunicorn
# Use the gunicorn config file for settings like port, workers, timeout
CMD ["gunicorn", "-c", "gunicorn.conf.py", "main:app"]