# Inference sidecar for tts-gateway (TTS_GATEWAY_PLAN.md Phase 3). Base image
# matches nik-gpu's driver 570.211.01 / CUDA 12.8 - only meaningfully runnable
# on a CUDA host, even though it builds fine anywhere. Does NOT bake in model
# weights: CHECKPOINT_PATH/CONFIG_PATH must point at a mounted G_790000.pth +
# uma.json at runtime (model artifact distribution is still an open decision,
# TTS_GATEWAY_PLAN.md Phase 5 - for now this means a bind mount, see the repo
# README/CLAUDE.md for the exact nik-gpu run command).
FROM pytorch/pytorch:2.9.1-cuda12.8-cudnn9-runtime

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

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

COPY . .

# models/models.py does a module-level `import monotonic_align`, even though
# this sidecar's infer()-only path never calls it (only the training-time
# forward() does) - the extension still has to build for the import itself to
# succeed. See tmp/reference/uma-tts-api/spike/FINDINGS.md for the identical
# issue hit during the Phase 0 spike.
RUN cd monotonic_align && python setup.py build_ext --inplace

EXPOSE 50054
CMD ["python", "server.py"]
