# Use a slim, official Python 3.11 image as the base FROM python:3.11-slim # Set environment variables to prevent Python from writing .pyc files # and to ensure stdout/stderr are unbuffered (important for logs) ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Set the working directory inside the container WORKDIR /app # Copy only requirements first to leverage Docker layer caching. # If requirements don't change, this layer won't be rebuilt. COPY requirements.txt . # Install dependencies # --no-cache-dir keeps the image smaller RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application source code into the container COPY . . # Expose port 7860 — Hugging Face Spaces expects this port EXPOSE 7860 # The command to run when the container starts CMD ["python", "main.py"]