File size: 1,859 Bytes
e0a76c8
 
3855d36
e0a76c8
 
 
 
 
 
 
 
 
 
f7954c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e0a76c8
 
 
 
 
 
3855d36
 
 
 
e879951
e0a76c8
 
 
 
 
4346c22
 
 
 
 
e0a76c8
 
 
 
85dc94a
 
 
 
 
 
e0a76c8
 
4346c22
e0a76c8
3855d36
 
d4bd95e
3855d36
 
 
e879951
4346c22
e879951
 
 
3855d36
e0a76c8
d4bd95e
e0a76c8
85dc94a
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
FROM python:3.10-slim

# Install system dependencies for Playwright and other packages
RUN apt-get update && apt-get install -y \
    libnss3 \
    libnspr4 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libxcomposite1 \
    libxdamage1 \
    libatspi2.0-0 \
    libxrandr2 \
    libgbm1 \
    libasound2 \
    libpango-1.0-0 \
    libpangocairo-1.0-0 \
    libgdk-pixbuf2.0-0 \
    libgtk-3-0 \
    libgl1-mesa-glx \
    libsm6 \
    libxext6 \
    libx11-xcb1 \
    libxcb-dri3-0 \
    libdrm2 \
    libxkbcommon0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libasound2 \
    libpango-1.0-0 \
    libpangocairo-1.0-0 \
    libgdk-pixbuf2.0-0 \
    libgtk-3-0 \
    libgl1-mesa-glx \
    libsm6 \
    libxext6 \
    ffmpeg \
    xvfb \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Create a non-root user
RUN useradd -m -u 1000 user && \
    mkdir -p /home/user/.cache && \
    chown -R user:user /home/user/.cache

# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Install Playwright browsers as root
RUN mkdir -p /home/user/.cache/ms-playwright && \
    playwright install chromium && \
    playwright install-deps && \
    chown -R user:user /home/user/.cache/ms-playwright

# Copy the rest of the application
COPY . .
RUN chown -R user:user /app

# Set environment variables
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
ENV GRADIO_ANALYTICS_ENABLED=false
ENV GRADIO_ALLOW_FLAGGING=false
ENV GRADIO_QUEUE_ENABLED=false
ENV DISPLAY=:99
ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright

# Switch to non-root user
USER user

# Expose the port
EXPOSE 7860

# Run the application with Xvfb
CMD Xvfb :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & python app.py