| # Use an official Python runtime as the base image | |
| FROM python:3.9-slim | |
| # Set the working directory inside the container | |
| WORKDIR /app | |
| # Install system dependencies for ML and data processing libraries | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| libopenblas-dev \ | |
| libomp-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Upgrade pip to avoid dependency issues | |
| RUN pip install --upgrade pip | |
| # Copy the dependencies file first for caching efficiency | |
| COPY requirements.txt /app/requirements.txt | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY . /app | |
| # Expose port 7860 (required by Hugging Face Spaces) | |
| EXPOSE 7860 | |
| # Command to run the Flask app | |
| CMD ["python", "main.py"] | |