FROM python:3.12.6 # Install OpenGL dependencies and PortAudio USER root RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ portaudio19-dev # Create non-root user RUN useradd -m -u 1000 user WORKDIR /app # Set PATH for the non-root user ENV PATH="/home/user/.local/bin:$PATH" # Switch to non-root user USER user # Copy and install Python dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy application files COPY --chown=user . /app # Expose the Hugging Face Spaces default port EXPOSE 7860 # Set the command to run the app CMD ["python", "webapp.py"]