Spaces:
No application file
No application file
| FROM python:3.9-slim | |
| # Create required user | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environment | |
| ENV PATH="/home/user/.local/bin:$PATH" \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 | |
| WORKDIR /app | |
| # Install system dependencies (as root, then switch back) | |
| USER root | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| USER user | |
| # Copy requirements first (better caching) | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy application | |
| COPY --chown=user app.py . | |
| # Hugging Face requires port 7860 | |
| ENV PORT=7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ | |
| CMD curl apt-get -f http://localhost:${PORT}/health || exit 1 | |
| # Run the application | |
| CMD uvicorn app:app --host 0.0.0.0 --port ${PORT} |