11# ------------------------------
22# Stage 1: Build Whisper.cpp
33# ------------------------------
4- FROM --platform=linux/amd64 python:3.8.15-slim-buster AS whisperbuild
4+ FROM --platform=linux/amd64 python:3.13.3-bookworm AS whisperbuild
55RUN apt-get update && \
6- apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg git && \
7- apt-get install -y wget && \
6+ apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg git wget && \
87 wget https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7-linux-x86_64.sh -O /tmp/cmake-install.sh && \
98 chmod +x /tmp/cmake-install.sh && \
109 /tmp/cmake-install.sh --skip-license --prefix=/usr/local && \
@@ -19,27 +18,38 @@ RUN bash ./models/download-ggml-model.sh tiny.en
1918RUN bash ./models/download-ggml-model.sh large-v3
2019
2120# ------------------------------
22- # Stage 2: Setup Python RPC Server
21+ # Stage 2: Build Python Dependencies
2322# ------------------------------
24- FROM --platform=linux/amd64 python:3.8.15-slim-buster AS rpcserver
23+ FROM --platform=linux/amd64 python:3.13.3-bookworm AS builder
24+ RUN apt-get update && apt-get install -y build-essential libxml2-dev libxslt1-dev zlib1g-dev libssl-dev libffi-dev python3-dev
25+
26+ COPY ./PythonRpcServer/requirements.txt .
27+ RUN pip install --no-cache-dir --upgrade pip && \
28+ pip wheel --wheel-dir=/wheels -r requirements.txt
29+
30+ # ------------------------------
31+ # Stage 3: Setup Python RPC Server
32+ # ------------------------------
33+ FROM --platform=linux/amd64 python:3.13.3-slim-bookworm AS rpcserver
2534RUN apt-get update && \
26- apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg
35+ apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg libxml2-dev libxslt1-dev zlib1g-dev libssl-dev libffi-dev python3-dev
2736
2837ENV OMP_THREAD_LIMIT=1
2938COPY --from=whisperbuild /whisper.cpp/build/bin/whisper-cli /usr/local/bin/whisper
3039COPY --from=whisperbuild /whisper.cpp/models /PythonRpcServer/models
31- WORKDIR /PythonRpcServer
3240
41+ # copy pre-built wheels from builder stage
42+ COPY --from=builder /wheels /wheels
43+ COPY ./PythonRpcServer/requirements.txt .
44+ RUN pip install --no-cache-dir --upgrade pip && \
45+ pip install --no-cache-dir --find-links=/wheels -r requirements.txt
46+
47+ WORKDIR /PythonRpcServer
3348COPY ./PythonRpcServer/transcribe_hellohellohello.wav .
3449RUN whisper -ojf -f transcribe_hellohellohello.wav
3550
36- COPY ./PythonRpcServer/requirements.txt requirements.txt
37- RUN pip install --no-cache-dir --upgrade pip && \
38- pip install --no-cache-dir -r requirements.txt
39-
4051COPY ct.proto ct.proto
4152RUN python -m grpc_tools.protoc -I . --python_out=./ --grpc_python_out=./ ct.proto
4253
4354COPY ./PythonRpcServer .
44-
45- CMD [ "nice" , "-n" , "18" , "ionice" , "-c" , "2" , "-n" , "6" , "python3" , "-u" , "/PythonRpcServer/server.py" ]
55+ CMD ["nice" , "-n" , "18" , "ionice" , "-c" , "2" , "-n" , "6" , "python3" , "-u" , "/PythonRpcServer/server.py" ]
0 commit comments