FROM python:3.12-slim # Avoid Python writing .pyc files and enable unbuffered logs ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PORT=7860 # Install build essentials (needed for some pandas/numpy wheels) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python dependencies first (better Docker layer caching) COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy the rest of the project COPY . . # Hugging Face Spaces requires the app to listen on port 7860 EXPOSE 7860 # Start the Flask app via gunicorn (already in requirements.txt) CMD ["gunicorn", "app:app", \ "--bind", "0.0.0.0:7860", \ "--workers", "2", \ "--threads", "4", \ "--timeout", "120", \ "--access-logfile", "-"]