Spaces:
Runtime error
Runtime error
| # Dockerfile for FastAPI Hugging Face app | |
| FROM python:3.10-slim | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV PYTHONUNBUFFERED=1 | |
| # Install essential system dependencies | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends \ | |
| build-essential git curl libgl1 libglib2.0-0 libsndfile1 ffmpeg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user (required for Spaces) | |
| RUN useradd -m -u 1000 user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # Copy dependency list and install | |
| COPY requirements.txt . | |
| RUN python -m pip install --upgrade pip \ | |
| && python -m pip install --no-cache-dir -r requirements.txt | |
| # Copy source code | |
| COPY . . | |
| # Set ownership for non-root user | |
| RUN chown -R user:user $HOME | |
| # Switch to non-root user | |
| USER user | |
| # Expose port | |
| EXPOSE 7860 | |
| ENV PORT=7860 | |
| # Run FastAPI app | |
| CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT} --workers 1"] |