# Use Python 3.13 slim image FROM python:3.13-slim # Set working directory WORKDIR /app # Install uv for faster dependency management COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv # Copy all files (needed for package install) COPY . . # Install dependencies system-wide from pyproject.toml RUN uv pip install --system --no-cache . # Expose port (7860 for HF Spaces, 5000 for local) EXPOSE 7860 # Set environment variables ENV FLASK_APP=app.py ENV PYTHONUNBUFFERED=1 ENV PORT=7860 # Run the app with gunicorn for production # --preload loads models once before forking workers (saves memory) CMD gunicorn --preload --bind 0.0.0.0:$PORT --workers 2 --timeout 120 app:app