FROM python:3.11-slim # Install system dependencies RUN apt-get update && apt-get install -y \ git \ curl \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Install uv for fast dependency management COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/ # Copy requirements first for better caching COPY requirements.txt . COPY pyproject.toml . # Install dependencies RUN uv pip install --system -r requirements.txt RUN uv pip install --system -e . # Copy the rest of the application COPY . . # Install Playwright browsers RUN playwright install chromium RUN playwright install-deps chromium # Create non-root user RUN useradd -m -u 1000 user && \ chown -R user:user /app USER user # Expose port EXPOSE 7860 # Set environment variables ENV PYTHONUNBUFFERED=1 \ PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright # Start the FastAPI server with Gradio UI CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]