Spaces:
Paused
Paused
| FROM python:3.12-slim | |
| # Install system dependencies, including Google Chrome for undetected-chromedriver | |
| RUN apt-get update && apt-get install -y \ | |
| wget \ | |
| gnupg \ | |
| xvfb \ | |
| && mkdir -p /etc/apt/keyrings \ | |
| && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg \ | |
| && sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | |
| && apt-get update \ | |
| && apt-get install -y google-chrome-stable \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install uv for fast dependency resolution | |
| RUN pip install --no-cache-dir uv | |
| # Copy dependency definition files | |
| COPY pyproject.toml uv.lock* ./ | |
| # Install python dependencies system-wide | |
| RUN uv pip install --system -r pyproject.toml | |
| # Set Playwright browsers path to a shared location accessible by all users | |
| ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | |
| # Install Playwright browsers and their system dependencies | |
| RUN playwright install chromium \ | |
| && playwright install-deps chromium \ | |
| && chmod -R 755 /ms-playwright | |
| # Set up non-root user for Hugging Face Spaces (required by HF) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # Copy the rest of the application files setting the owner to the non-root user | |
| COPY --chown=user . $HOME/app | |
| # Expose the port Hugging Face Spaces expects | |
| EXPOSE 7860 | |
| ENV PORT=7860 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Command to run the backend application | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |