Spaces:
Building
Building
# Use a lightweight Python image | |
FROM python:3.10-slim | |
# Set working directory | |
WORKDIR /app | |
RUN git config user.email "[email protected]" && \ | |
git config user.name "peace2024" | |
# Install system-level dependencies | |
RUN apt-get update && \ | |
apt-get install -y ffmpeg libsndfile1 wget curl git && \ | |
rm -rf /var/lib/apt/lists/* | |
# Copy requirements first to leverage Docker layer caching | |
COPY requirements.txt . | |
# Upgrade pip and install dependencies | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir -r requirements.txt | |
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 | |
# Copy the entire app source code | |
COPY . . | |
# Expose port 7860 (used by Hugging Face Spaces) | |
EXPOSE 7860 | |
# Set environment variables (if needed) | |
ENV PYTHONUNBUFFERED=1 | |
# Run the FastAPI app via Uvicorn | |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |