1-
2- # Total laptop build 626 seconds
3- # FROM python:3.7-slim-buster
4-
5- # FROM python:3.10.8-slim-buster - Failed to install scipy/numpy
6- # FROM python:3.9.15-slim-buster - failed to install scipy/numpy
7- FROM --platform=linux/amd64 python:3.8.15-slim-buster
8-
9- RUN apt-get update
10- RUN apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg
11-
12- # Build stuff for tesseract
13- # Based on https://medium.com/quantrium-tech/installing-tesseract-4-on-ubuntu-18-04-b6fcd0cbd78f
14- # RUN apt-get install -y automake pkg-config libsdl-pango-dev libicu-dev libcairo2-dev bc libleptonica-dev
15- # RUN curl -L https://github.com/tesseract-ocr/tesseract/archive/refs/tags/4.1.1.tar.gz | tar xvz
16-
17- # WORKDIR /tesseract-4.1.1
18- # RUN ./autogen.sh && ./configure && make -j && make install && ldconfig
19- # Slow! The above line takes 435 seconds on my laptop
20- # RUN make training && make training-install
21- # The above line takes 59 seconds on my laptop
22-
23- # RUN curl -L -o tessdata/eng.traineddata https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata
24- # RUN curl -L -o tessdata/osd.traineddata https://github.com/tesseract-ocr/tessdata/raw/main/osd.traineddata
25-
26- # ENV TESSDATA_PREFIX=/tesseract-4.1.1/tessdata
27- # Disable multi-threading
28- ENV OMP_THREAD_LIMIT=1
29-
30- WORKDIR /PythonRpcServer
31-
32-
33- COPY ./PythonRpcServer/requirements.txt requirements.txt
34- RUN pip install --no-cache-dir --upgrade pip
35- RUN pip install --no-cache-dir -r requirements.txt
36-
37- COPY ct.proto ct.proto
38- RUN python -m grpc_tools.protoc -I . --python_out=./ --grpc_python_out=./ ct.proto
39-
40- COPY ./PythonRpcServer .
41-
42- # Old:Downloaded tgz from https://github.com/nficano/pytube and renamed to include version
43- # New: Grab link directly from https://github.com/pytube/pytube/tags (-L => follow redirect)
44- # Uncomment to pull pytube tar.gz directly from github, if version unavailable on pypi (remember to comment out in PythonRpcServer/requirements.txt)
45- ARG PYTUBE_VERSION=""
46- RUN if [ "${PYTUBE_VERSION}" != "" ]; then curl -L https://github.com/pytube/pytube/archive/refs/tags/v${PYTUBE_VERSION}.tar.gz -o pytube.tar.gz && pip install --no-cache-dir --force-reinstall pytube.tar.gz && rm pytube.tar.gz; fi
47-
48- # RUN python -m nltk.downloader stopwords brown
49-
50-
51- # Nice:Very low priority but not lowest priority (18 out of 19)
52- # ionice: Best effort class but second lowest priory (6 out of 7)
53- CMD [ "nice" ,"-n" ,"18" , "ionice" ,"-c" ,"2" ,"-n" ,"6" , "python3" , "-u" , "/PythonRpcServer/server.py" ]
1+ # # ------------------------------
2+ # # Stage 1: Build Whisper.cpp
3+ # # ------------------------------
4+ FROM --platform=linux/amd64 python:3.8.15-slim-buster AS whisperbuild
5+ RUN apt-get update && \
6+ apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg git
7+
8+ WORKDIR /whisper.cpp
9+ RUN git clone https://github.com/ggerganov/whisper.cpp . && make
10+ RUN bash ./models/download-ggml-model.sh base.en
11+
12+ # ------------------------------
13+ # Stage 2: Setup Python RPC Server
14+ # ------------------------------
15+ FROM --platform=linux/amd64 python:3.8.15-slim-buster AS rpcserver
16+ RUN apt-get update && \
17+ apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg
18+
19+ ENV OMP_THREAD_LIMIT=1
20+ COPY --from=whisperbuild /whisper.cpp/main /usr/local/bin/whisper
21+ COPY --from=whisperbuild /whisper.cpp/models/ggml-base.en.bin /usr/local/bin/models/ggml-base.en.bin
22+ WORKDIR /PythonRpcServer
23+
24+ COPY ./PythonRpcServer/requirements.txt requirements.txt
25+ RUN pip install --no-cache-dir --upgrade pip && \
26+ pip install --no-cache-dir -r requirements.txt
27+
28+ COPY ct.proto ct.proto
29+ RUN python -m grpc_tools.protoc -I . --python_out=./ --grpc_python_out=./ ct.proto
30+
31+ COPY ./PythonRpcServer .
32+
33+ CMD [ "nice" , "-n" , "18" , "ionice" , "-c" , "2" , "-n" , "6" , "python3" , "-u" , "/PythonRpcServer/server.py" ]
34+
35+
36+
0 commit comments