| # Use a lightweight Python base image | |
| FROM python:3.9-slim | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Copy the requirements file into the container | |
| COPY requirements.txt . | |
| # Install the Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application files into the container | |
| # This includes app.py, the model files, and the templates directory | |
| COPY . /app | |
| # Expose the port that the Flask app will listen on (required by Hugging Face Spaces) | |
| EXPOSE 7860 | |
| # Command to run the application using Gunicorn | |
| # -w: number of worker processes | |
| # -b: bind to all interfaces on port 7860 | |
| # app:app refers to the 'app' object within the 'app.py' file | |
| CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:app"] | |