Spaces:
Sleeping
Sleeping
File size: 1,217 Bytes
cb87df1 852aecc cb87df1 852aecc cb87df1 852aecc cb87df1 852aecc cb87df1 852aecc cb87df1 852aecc cb87df1 852aecc cb87df1 852aecc cb87df1 |
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 |
# Start from an official Python image
FROM python:3.9-slim
# Create a non-root user
RUN useradd -m -u 1000 appuser
# Install system dependencies needed by Playwright
RUN apt-get update && apt-get install -y \
wget \
gnupg \
unzip \
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libgtk-3-0 \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip
RUN pip install --upgrade pip
# Install Python packages
RUN pip install playwright==1.32.0 gradio==3.23.0 requests beautifulsoup4
# Install Playwright browsers
RUN playwright install
# Set up directories with proper permissions
WORKDIR /app
COPY app.py /app/
# Create and set permissions for matplotlib cache directory
ENV MPLCONFIGDIR=/tmp/matplotlib
RUN mkdir -p /tmp/matplotlib && \
chown -R appuser:appuser /tmp/matplotlib
# Create and set permissions for fontconfig cache
RUN mkdir -p /home/appuser/.cache/fontconfig && \
chown -R appuser:appuser /home/appuser/.cache
# Switch to non-root user
USER appuser
# Expose port 7860 for Gradio
EXPOSE 7860
# Run Gradio app
CMD ["python", "app.py"] |