Spaces:
Running
Running
# Use Python 3.10 slim for ML workloads | |
FROM python:3.10-slim | |
# Set working directory | |
WORKDIR /app | |
# Set environment variables | |
ENV PYTHONUNBUFFERED=1 \ | |
PYTHONDONTWRITEBYTECODE=1 \ | |
DEBIAN_FRONTEND=noninteractive \ | |
PORT=7860 | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
ffmpeg \ | |
libsndfile1 \ | |
libasound2-dev \ | |
portaudio19-dev \ | |
wget \ | |
curl \ | |
git \ | |
build-essential \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy requirements first for better caching | |
COPY requirements-hf.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir -r requirements-hf.txt | |
# Install PyTorch CPU (before copying app code) | |
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu | |
# Copy app source code | |
COPY . . | |
# Create necessary directories | |
RUN mkdir -p vector_store logs | |
# Expose port | |
EXPOSE 7860 | |
# Health check | |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | |
CMD curl -f http://localhost:7860/ || exit 1 | |
# Run FastAPI app | |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |