| # Use an official lightweight Python image | |
| FROM python:3.9-slim | |
| # Set working directory | |
| WORKDIR /code | |
| # Install system dependencies for audio processing | |
| RUN apt-get update && apt-get install -y \ | |
| libsndfile1 \ | |
| ffmpeg \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first to leverage Docker cache | |
| COPY ./requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Copy the application code and model | |
| COPY . . | |
| # Expose the port FastAPI runs on | |
| EXPOSE 7860 | |
| # Run with 1 worker to maximize RAM availability per request | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] |