Trisha Tomy
Update Dockerfile to Python 3.11 to meet proxy-lite requirements
f19a4ca
raw
history blame
2.98 kB
# Dockerfile
# Use a Python base image that is compatible with Playwright's system dependencies
FROM python:3.11-slim-buster
# Set the working directory inside the container
WORKDIR /app
# Install system dependencies required by Playwright's Chromium browser
# These are common dependencies for running headless Chrome/Chromium.
# This list might need minor adjustments based on specific runtime errors.
RUN apt-get update && apt-get install -y \
# Core libraries for graphics/rendering
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libpangocairo-1.0-0 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
# Specific to Chromium/GPU (even if not using GPU, these are for display stack)
libgbm-dev \
libasound2-dev \
# xvfb provides a virtual display server, often necessary for headless browsers
xvfb \
# Ensure Chromium is installed on the system (Playwright uses its own, but sometimes useful)
chromium \
git \
# Clean up apt caches to reduce image size
&& rm -rf /var/lib/apt/lists/*
# Copy Python dependencies (now only common ones, proxy-lite will be handled separately)
COPY requirements.txt .
# --- NEW/MODIFIED INSTALLATION BLOCK ---
# Upgrade pip, setuptools, and wheel for a robust build environment
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Install proxy-lite in editable mode directly from its Git repository
# This explicitly tells pip to clone and "install" it by linking directly,
# which can sometimes bypass wheel build issues for complex projects.
RUN pip install --no-cache-dir -e git+https://github.com/convergence-ai/proxy-lite.git#egg=proxy-lite
# Install the rest of the dependencies from requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# --- END NEW/MODIFIED INSTALLATION BLOCK ---
# Copy your application code into the container
COPY . .
# Install Playwright browser binaries within the container
# This downloads Chromium into the container's Playwright-managed location.
RUN playwright install chromium
# Set environment variables for Playwright
# PLAYWRIGHT_BROWSERS_PATH: Tells Playwright where to find the installed browsers.
# DISPLAY, XDG_RUNTIME_DIR: Often needed for headless browser environments.
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright/
ENV DISPLAY=:99
ENV XDG_RUNTIME_DIR=/tmp
# Expose the port your Flask app will listen on. Hugging Face Spaces expects 7860.
EXPOSE 7860
# Define the command to run your Flask application using Gunicorn for production
# Hugging Face Spaces will execute this command to start your web service.
CMD exec gunicorn --bind 0.0.0.0:7860 --workers 2 --worker-class gevent app:app --timeout 300