Files
pikasTech-unidesk/deploy/selfmedia-voice/Containerfile
T
Lyon 58b82fe009
Pipelines as Code CI / hwlab-web-probe-sentinel-nc01- Success
Pipelines as Code CI / platform-infra-gitea-nc01- Failed
Pipelines as Code CI / unidesk-host- Success
feat: 固化 SelfMedia 语音服务 YAML 控制面 (#2150)
* feat: 固化 SelfMedia 语音服务 YAML 控制面

* fix: 参数化 torchaudio ABI 身份

* feat: 切换 SelfMedia 语音服务到 CosyVoice3

---------

Co-authored-by: Codex <codex@local>
2026-07-15 17:17:44 +08:00

59 lines
2.5 KiB
Docker

ARG BASE_IMAGE
FROM ${BASE_IMAGE}
ARG SOURCE_REPOSITORY
ARG SOURCE_REF
ARG SOURCE_SUBMODULES
ARG REFERENCE_WAV_PATH
ARG REFERENCE_WAV_SHA256
ARG PIP_VERSION
ARG PIP_INDEX_URL
ARG SETUPTOOLS_INSTALL_SPEC
ARG TORCH_VERSION_IDENTITY
ARG TORCH_LIBRARY_PATH
ARG TORCHAUDIO_VERSION_IDENTITY
ARG OPENAI_WHISPER_INSTALL_SPEC
ARG ONNXRUNTIME_GPU_INSTALL_SPEC
ARG ONNXRUNTIME_GPU_INDEX_URL
ENV DEBIAN_FRONTEND=noninteractive \
PIP_INDEX_URL=${PIP_INDEX_URL} \
PYTHONPATH=/opt/CosyVoice:/opt/CosyVoice/third_party/Matcha-TTS \
PYTHONUNBUFFERED=1
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl ffmpeg git git-lfs libsox-dev sox \
&& rm -rf /var/lib/apt/lists/* \
&& python -m pip install "pip==${PIP_VERSION}" "${SETUPTOOLS_INSTALL_SPEC}" wheel
RUN git clone --no-checkout "${SOURCE_REPOSITORY}" /opt/CosyVoice \
&& git -C /opt/CosyVoice fetch --depth 1 origin "${SOURCE_REF}" \
&& git -C /opt/CosyVoice checkout --detach "${SOURCE_REF}" \
&& test "$(git -C /opt/CosyVoice rev-parse HEAD)" = "${SOURCE_REF}" \
&& if [ "${SOURCE_SUBMODULES}" = recursive ]; then git -C /opt/CosyVoice submodule update --init --recursive --depth 1; fi \
&& printf '%s %s\n' "${REFERENCE_WAV_SHA256}" "/opt/CosyVoice/${REFERENCE_WAV_PATH}" | sha256sum -c -
RUN sed -e '/^torch==/d' \
-e '/^deepspeed==/d' \
-e '/^tensorrt-cu12/d' \
-e '/^openai-whisper==/d' \
-e '/^onnxruntime-gpu==/d' \
/opt/CosyVoice/requirements.txt > /tmp/runtime-requirements.txt \
&& python -m pip install "${OPENAI_WHISPER_INSTALL_SPEC}" --no-build-isolation
RUN python -m pip install --index-url "${ONNXRUNTIME_GPU_INDEX_URL}" "${ONNXRUNTIME_GPU_INSTALL_SPEC}"
RUN python -m pip install -r /tmp/runtime-requirements.txt \
&& test -d "${TORCH_LIBRARY_PATH}" \
&& python -c 'import sys, torch, torchaudio; expected_torch=sys.argv[1]; expected_audio=sys.argv[2]; assert torch.__version__.split("+")[0] == expected_torch, f"torch identity mismatch: expected={expected_torch} actual={torch.__version__}"; assert torchaudio.__version__.split("+")[0] == expected_audio, f"torchaudio identity mismatch: expected={expected_audio} actual={torchaudio.__version__}"; from cosyvoice.cli.cosyvoice import AutoModel' "${TORCH_VERSION_IDENTITY}" "${TORCHAUDIO_VERSION_IDENTITY}"
LABEL ai.unidesk.source.ref="${SOURCE_REF}"
LABEL ai.unidesk.torchaudio.version-identity="${TORCHAUDIO_VERSION_IDENTITY}"
WORKDIR /app
COPY api.py /app/api.py
COPY model-init.sh /app/model-init.sh
EXPOSE 18327
CMD ["python", "/app/api.py"]