# Use a lightweight Python image FROM python:3.9-slim # Create a non-root user for security (required by Hugging Face) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:${PATH}" # Set the working directory WORKDIR /app # Copy requirements first to leverage Docker cache COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of your files (app.py and model.joblib) COPY --chown=user . . # Expose the port Hugging Face expects EXPOSE 7860 # Start the script CMD ["python", "app.py"]