# Use Python 3.9 as base image FROM python:3.9-slim # Create a non-root user (Hugging Face best practice) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Install system dependencies (must be done as root) USER root RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ git \ git-lfs \ && rm -rf /var/lib/apt/lists/* USER user # Copy requirements and install COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the entire project with proper ownership COPY --chown=user:user . . # Create outputs directory and set permissions RUN mkdir -p outputs && chmod 777 outputs # Expose the standard Hugging Face port EXPOSE 7860 # Command to run the application # Points to your real backend in backend/app.py CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860"]