# Use the official Python base image | |
FROM python:3.9-slim | |
# Set a working directory | |
WORKDIR /app | |
# Install dependencies | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the Flask application to the container | |
COPY . . | |
# Expose the port that the app will run on (Hugging Face Spaces typically uses port 7860) | |
EXPOSE 7860 | |
# Set environment variables for Flask and Gunicorn | |
ENV FLASK_APP=app.py | |
ENV FLASK_RUN_HOST=0.0.0.0 | |
ENV FLASK_RUN_PORT=7860 | |
# Command to run the Flask app with gunicorn | |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"] | |