Spaces:
Runtime error
Runtime error
File size: 1,582 Bytes
36e2bdd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # Use Python 3.11 slim image as base
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
wget \
curl \
build-essential \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Install PyTorch CPU version first (to avoid CUDA dependencies)
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir torch torchaudio --index-url https://download.pytorch.org/whl/cpu
# Copy requirements (excluding torch/torchaudio since we installed them above)
COPY requirements.txt ./
RUN pip install --no-cache-dir fastapi uvicorn[standard] python-dotenv python-multipart requests psutil chatterbox-tts
# Copy application code
COPY app/ ./app/
COPY main.py ./
# Copy voice sample if it exists (optional, can be mounted)
COPY voice-sample.mp3 ./voice-sample.mp3
# Create directory for model cache (separate from source code)
RUN mkdir -p /cache
# Set default environment variables (force CPU)
ENV PORT=4123
ENV EXAGGERATION=0.5
ENV CFG_WEIGHT=0.5
ENV TEMPERATURE=0.8
ENV VOICE_SAMPLE_PATH=/app/voice-sample.mp3
ENV MAX_CHUNK_LENGTH=280
ENV MAX_TOTAL_LENGTH=3000
ENV DEVICE=cpu
ENV MODEL_CACHE_DIR=/cache
ENV HOST=0.0.0.0
# Expose port
EXPOSE ${PORT}
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5m --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
# Run the application with the new entry point
CMD ["python", "main.py"] |