File size: 1,197 Bytes
7ea9978
419258c
7ea9978
 
 
 
 
 
419258c
7ea9978
419258c
7ea9978
 
 
 
 
419258c
 
7ea9978
 
 
 
419258c
7ea9978
419258c
7ea9978
 
 
419258c
7ea9978
 
 
419258c
7ea9978
419258c
 
 
7ea9978
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
FROM python:3.11-slim

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    PORT=7860 \
    HOME=/home/user \
    PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright \
    PATH="/home/user/.local/bin:${PATH}"

# Install all Linux libraries required by Chromium
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget curl ca-certificates libglib2.0-0 libnss3 libnspr4 \
    libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxcb1 \
    libxkbcommon0 libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 \
    libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 \
    fonts-liberation fonts-noto-color-emoji \
    && rm -rf /var/lib/apt/lists/*

# Create non-root Hugging Face user (UID 1000)
RUN useradd -m -u 1000 user && \
    mkdir -p /home/user/app /home/user/.cache/ms-playwright && \
    chown -R user:user /home/user

WORKDIR /home/user/app

# Install Python requirements
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Switch to user and download Patchright Chromium
USER user
RUN python -m patchright install chromium

COPY --chown=user:user . .

EXPOSE 7860

CMD ["python", "app.py"]