File size: 866 Bytes
52bcf81
 
face1f8
52bcf81
face1f8
52bcf81
 
face1f8
 
 
52bcf81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512c804
52bcf81
 
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
# Use a compatible Python base image
FROM python:3.9-slim-bookworm

# Set the working directory inside the container
WORKDIR /app

# First, copy and install Python packages to leverage Docker layer caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Now, install Playwright's system dependencies and the Chromium browser
# This is much cleaner and more reliable than the wkhtmltopdf process.
RUN playwright install-deps
RUN playwright install chromium

# Create non-root user as required by HF Spaces
RUN useradd -m -u 1000 user

# Copy application files (before switching user)
COPY --chown=1000:1000 app.py .

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

# Expose the port
EXPOSE 7860

# Run with gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]