| FROM python:3.9-slim | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| git \ | |
| build-essential \ | |
| python3-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create non-root user | |
| RUN useradd -m -u 1000 user | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first (for better caching) | |
| COPY --chown=user:user requirements.txt ./ | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the app | |
| COPY --chown=user:user . . | |
| # Switch to non-root user | |
| USER user | |
| # Expose port (for Gradio/Streamlit) | |
| EXPOSE 7860 | |
| # Run command | |
| CMD ["python", "app.py"] |