FROM python:3.9-slim # Create a non-root user RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory to the user's home WORKDIR $HOME/app # Copy requirements first for better caching COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --user -r requirements.txt # Copy the rest of the application COPY --chown=user . . # Set environment variables ENV PYTHONUNBUFFERED=1 # Expose the port Hugging Face Spaces expects EXPOSE 7860 # Run the application CMD ["python", "home.py"]