File size: 1,149 Bytes
ff23105
 
 
 
 
 
 
 
 
 
18a0b89
ff23105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use Python 3.11 slim image (stable for Playwright/Agno)
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies required for building python packages and playwright
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements file
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Install Playwright browsers and dependencies
# We set the path to a location accessible by the non-root user or install globally
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright && \
    playwright install --with-deps chromium && \
    chmod -R 777 /ms-playwright

# Create a non-root user for security (HF Spaces requirement)
RUN useradd -m -u 1000 user

# Copy application code and set ownership
COPY --chown=user:user . .

# Switch to non-root user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Expose port 7860 (standard for HF Spaces)
EXPOSE 7860

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