FROM python:3.9-slim WORKDIR /app # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PORT=7860 # Install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy project files COPY . . # Ensure templates directory exists RUN mkdir -p templates # Expose the port Hugging Face Spaces expects EXPOSE 7860 # Run the application with gunicorn for better performance CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]