Spaces:
Runtime error
Runtime error
| # Use Python 3.10 for better package compatibility | |
| FROM python:3.10-slim | |
| # Install system dependencies (including ffmpeg for audio processing) | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create user for HF Spaces (required) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environment variables | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| ENV PYTHONPATH="/app:$PYTHONPATH" | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set work directory | |
| WORKDIR /app | |
| # Install system dependencies (as user, limited packages) | |
| # Note: HF Spaces has restrictions on system packages | |
| COPY --chown=user ./requirements_hf.txt requirements.txt | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy application files (essential files only) | |
| COPY --chown=user ./app.py ./app.py | |
| COPY --chown=user ./audio_processors ./audio_processors | |
| COPY --chown=user ./utils ./utils | |
| COPY --chown=user ./models ./models | |
| COPY --chown=user ./ml_training ./ml_training | |
| # Copy environment template (users can set their own HF_TOKEN) | |
| COPY --chown=user ./.env.example ./.env | |
| # Create log directory | |
| RUN mkdir -p /app/logs | |
| # Expose port (HF Spaces requires 7860) | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ | |
| CMD python -c "import requests; requests.get('http://localhost:7860/api/health').raise_for_status()" || exit 1 | |
| # Run the application | |
| CMD ["python", "app.py"] |