FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PYTHONUNBUFFERED=1 \
    VENV_PATH=/opt/venv

ENV PATH="${VENV_PATH}/bin:${PATH}"

WORKDIR /piper

RUN apt-get update \
 && apt-get install -y --no-install-recommends \
      build-essential \
      cmake \
      espeak-ng \
      git \
      ninja-build \
      pkg-config \
      python3 \
      python3-dev \
      python3-venv \
 && rm -rf /var/lib/apt/lists/*

RUN git clone --depth 1 https://github.com/OHF-voice/piper1-gpl.git .

RUN python3 -m venv ${VENV_PATH}

RUN pip install --upgrade pip wheel setuptools \
 && pip install --no-cache-dir cmake scikit-build \
 && pip install --no-cache-dir -e '.[train]'

RUN ./build_monotonic_align.sh \
 && python3 setup.py build_ext --inplace

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
