# Use Python 3.11.7 slim image as base FROM python:3.11.7-slim # Set working directory WORKDIR /app # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ FLASK_APP=app.py \ FLASK_ENV=production # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ wget \ git \ && rm -rf /var/lib/apt/lists/* # Create a non-root user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Copy requirements first to leverage Docker cache COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy project files COPY --chown=user . /app # Expose port (Hugging Face Spaces uses 7860) EXPOSE 7860 # Run the application CMD ["python", "app.py"]