68 lines
3.0 KiB
Docker
68 lines
3.0 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# ============================================================================
|
|
# stt-server containerizzato (whisper.cpp Vulkan ASR + pyannote diarization)
|
|
# ----------------------------------------------------------------------------
|
|
# GPU: AMD/Intel via Mesa RADV (/dev/dri/renderD128). Il driver kernel resta
|
|
# sull'host; il container monta solo il device node.
|
|
#
|
|
# Build: docker build -t stt-server:vulkan .
|
|
# Run: docker compose up -d (vedi docker-compose.yml)
|
|
# ============================================================================
|
|
|
|
# ------------------------------------------------------------- Vulkan build
|
|
# glslc (shader compiler) è impacchettato solo dal repo LunarG su Ubuntu 22.04
|
|
FROM ubuntu:22.04 AS build-vulkan
|
|
|
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
git ca-certificates cmake g++ make wget gnupg \
|
|
> /dev/null && rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | gpg --dearmor -o /usr/share/keyrings/lunarg.gpg && \
|
|
echo "deb [signed-by=/usr/share/keyrings/lunarg.gpg] https://packages.lunarg.com/vulkan/1.3.296 jammy main" \
|
|
> /etc/apt/sources.list.d/lunarg-vulkan.list && \
|
|
apt-get update -qq && apt-get install -y -qq --no-install-recommends vulkan-sdk \
|
|
> /dev/null && rm -rf /var/lib/apt/lists/*
|
|
|
|
# whisper.cpp: commit verificato con build Vulkan su Radeon 780M
|
|
RUN git clone https://github.com/ggerganov/whisper.cpp.git /build/whisper.cpp && \
|
|
cd /build/whisper.cpp && git checkout 592feef
|
|
|
|
WORKDIR /build/whisper.cpp
|
|
# GGML_NATIVE=OFF: binario portabile tra CPU diverse
|
|
RUN cmake -B build -DGGML_VULKAN=ON -DGGML_NATIVE=OFF -DCMAKE_BUILD_TYPE=Release && \
|
|
cmake --build build --config Release -j"$(nproc)" --target whisper-cli
|
|
|
|
# ------------------------------------------------------------------ runtime
|
|
FROM python:3.11-slim AS runtime
|
|
|
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
libgomp1 libvulkan1 mesa-vulkan-drivers libsndfile1 curl ca-certificates \
|
|
> /dev/null && rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
COPY --from=build-vulkan /build/whisper.cpp/build/bin/whisper-cli /build/whisper.cpp/build/bin/*.so* ./
|
|
|
|
# torch + torchaudio CPU (niente CUDA) prima di requirements, per evitare il
|
|
# wheel CUDA e il mismatch torchaudio (pyannote tira su torchaudio da PyPI
|
|
# standard, che richiede una versione di torch diversa)
|
|
RUN pip install --no-cache-dir torch==2.9.1 torchaudio==2.9.1 --index-url https://download.pytorch.org/whl/cpu
|
|
|
|
COPY requirements.txt ./requirements.txt
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
COPY server.py transcribe.py entrypoint.sh ./
|
|
RUN chmod +x ./entrypoint.sh
|
|
|
|
# Le librerie ggml copiate fuori dall'albero di build hanno RPATH interno:
|
|
# serve il path esplicito.
|
|
ENV LD_LIBRARY_PATH=/app
|
|
ENV GGML_BACKEND=Vulkan0
|
|
ENV WHISPER_CLI=/app/whisper-cli
|
|
ENV MODELS_DIR=/models
|
|
ENV STT_PYTHON=python3
|
|
ENV HF_HOME=/hf-cache
|
|
ENV GLOSSARY_FILE=/glossary/glossary.json
|
|
|
|
EXPOSE 8883
|
|
ENTRYPOINT ["./entrypoint.sh"]
|