Spaces:
Sleeping
Sleeping
| # 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"] |