# Multi-Voice Speech Platform: VocoLoom
FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    VOCOLOOM_PORT=7860 \
    VOCOLOOM_HOST=0.0.0.0

WORKDIR /app

# Install system dependencies for audio processing
RUN apt-get update && apt-get install -y --no-install-recommends \
    libsndfile1 \
    ffmpeg \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY vocoloom/ ./vocoloom/
COPY vocoloom.py webui.py speak_juergen.py ./
COPY models/ ./models/
COPY voices/ ./voices/

RUN groupadd --gid 1000 appgroup \
    && useradd --uid 1000 --gid appgroup -m -s /bin/sh appuser \
    && chown -R appuser:appgroup /app

EXPOSE 7860

USER appuser

HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

CMD ["python", "-u", "webui.py"]
