FROM python:3.12-slim

RUN apt-get update \
 && apt-get install -y --no-install-recommends openssh-client curl ca-certificates \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY pyproject.toml /app/
COPY app /app/app
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

COPY models.yaml /app/models.yaml

# Parakeet container wrapper patches (diarizer.py + main.py overlay).
# Shipped inside spark-control so the "Reapply speech-model patches" action
# can copy these into the parakeet-asr container on Spark 2 over SSH at any
# time — survives docker rm + redeploy of the parakeet container.
COPY parakeet_patches /app/parakeet_patches

# WhisperX container build context (Dockerfile + requirements.txt + app/).
# The "Install WhisperX" action in spark-control ships these files to Spark 2
# over SSH, then runs `docker build` + `docker run` there. The container
# becomes a managed always-on service alongside parakeet-asr and magpie-tts.
COPY whisperx_container /app/whisperx_container

RUN pip install --no-cache-dir -e .

ENV BIND_PORT=9999
EXPOSE 9999
ENTRYPOINT ["/app/entrypoint.sh"]
