stt-whisper-cpp-ap/Dockerfile

57 lines
1.2 KiB
Docker

FROM ubuntu:22.04 AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
git \
cmake \
make \
g++ \
python3 \
python3-pip \
ffmpeg \
wget \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
&& rm -rf /var/lib/apt/lists/*
# Clone and build whisper.cpp
RUN git clone https://github.com/ggerganov/whisper.cpp.git /whisper.cpp
WORKDIR /whisper.cpp
RUN make
# Download model
RUN mkdir -p models && \
wget https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin -O models/ggml-base.en.bin
FROM ubuntu:22.04 AS runtime
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
ffmpeg \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy only necessary files from builder
COPY --from=builder /whisper.cpp/main /whisper.cpp/main
COPY --from=builder /whisper.cpp/models /whisper.cpp/models
WORKDIR /whisper.cpp
# Install Python dependencies
RUN pip3 install flask flask-cors
# Copy API server script
COPY app.py .
# Expose port
EXPOSE 4002
# Run the server
CMD ["python3", "app.py"]