| # Use an official Python runtime as a parent image | |
| FROM python:3.10-slim | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Install minimal system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the requirements file into the container at /app | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the entire project into the container | |
| COPY . . | |
| # Create a non-root user to run the app (required by Hugging Face Spaces) | |
| RUN useradd -m -u 1000 user | |
| # Switch to the new user | |
| USER user | |
| # Set home directory env | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Expose port 7860 for Hugging Face | |
| EXPOSE 7860 | |
| # Healthcheck to ensure the app is running | |
| HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1 | |
| # Run the Flask application | |
| CMD ["python", "apps/flask_server.py"] | |