# Using 3.12-slim is safer as many AI wheels for 3.13 are still unstable FROM python:3.12-slim # 1. Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # 2. Install essential system/audio libraries RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ ffmpeg \ libsndfile1 \ && rm -rf /var/lib/apt/lists/* # 3. Create the mandatory HF non-root user RUN useradd -m -u 1000 user USER user WORKDIR $HOME/app # 4. Install requirements # Copy requirements first for better caching COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # 5. Copy the code (Keeping your src/ structure) COPY --chown=user src/ ./src/ # 6. Expose the CORRECT Hugging Face port EXPOSE 7860 # 7. Entrypoint with Port 7860 and XSRF fixes # Note: We call src/streamlit_app.py because we copied the folder itself ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", \ "--server.port=7860", \ "--server.address=0.0.0.0", \ "--server.enableXsrfProtection=false", \ "--server.enableCORS=false", \ "--server.headless=true", \ "--browser.gatherUsageStats=false"]