# Base image FROM python:3.10-slim # Set env to avoid interactive prompts and ensure models cache to /tmp ENV HF_HOME=/tmp \ XDG_CACHE_HOME=/tmp \ TRANSFORMERS_CACHE=/tmp \ PYTHONUNBUFFERED=1 # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libsm6 \ libxext6 \ libxrender-dev \ libglib2.0-0 \ libblas-dev \ liblapack-dev \ gfortran \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy requirements first for better caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the application code COPY . . # Expose port (for local or HF Spaces) EXPOSE 7860 # Start the Flask app CMD ["python", "app.py"]