FROM python:3.12-slim WORKDIR /app # Install system dependencies for Playwright and Chromium RUN apt-get update && apt-get install -y \ # Build tools build-essential \ git \ # Chromium browser and driver chromium \ chromium-driver \ # Playwright dependencies libnss3 \ libnspr4 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libcups2 \ libdrm2 \ libdbus-1-3 \ libxkbcommon0 \ libxcomposite1 \ libxdamage1 \ libxfixes3 \ libxrandr2 \ libgbm1 \ libasound2 \ libatspi2.0-0 \ libxshmfence1 \ # Utilities curl \ wget \ ca-certificates \ fonts-liberation \ && rm -rf /var/lib/apt/lists/* # Copy and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Find Chromium installation and create symlink if needed RUN if [ -f /usr/bin/chromium-browser ]; then \ ln -sf /usr/bin/chromium-browser /usr/bin/chromium; \ elif [ -f /usr/lib/chromium/chromium ]; then \ ln -sf /usr/lib/chromium/chromium /usr/bin/chromium; \ fi # Verify Chromium is accessible RUN which chromium || (echo "ERROR: Chromium not found!" && exit 1) # Set Playwright to use system Chromium ENV PLAYWRIGHT_BROWSERS_PATH=0 ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium # Copy application code COPY . . # Set Streamlit configuration for HuggingFace Spaces ENV STREAMLIT_SERVER_PORT=7860 ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 ENV STREAMLIT_SERVER_HEADLESS=true ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false # Expose Streamlit port EXPOSE 7860 # Health check HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1 # Run Streamlit (corrected app file path from main.py to app.py) CMD ["streamlit", "run", "app/app.py", "--server.port=7860", "--server.address=0.0.0.0"]