FROM python:3.11-slim

RUN apt-get update && apt-get install -y \
    libsndfile1 \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Pre-download faster-whisper medium model at build time
RUN python -c "\
from faster_whisper import WhisperModel; \
WhisperModel('medium', device='cpu', compute_type='int8'); \
print('Whisper model downloaded.')"

COPY . .

HEALTHCHECK --interval=30s --timeout=10s --start-period=30s \
    CMD python -c "print('pipeline process alive')" || exit 1

CMD ["python", "main.py"]
