This commit is contained in:
Kar
2025-06-15 22:21:26 +05:30
parent 301b58b644
commit be2296e442
2 changed files with 69 additions and 63 deletions

View File

@@ -1,51 +1,55 @@
FROM ubuntu:22.04
FROM ubuntu:22.04 AS build
# Install system dependencies
# Install build dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
git \
cmake \
make \
g++ \
python3 \
python3-pip \
ffmpeg \
curl \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
RUN mkdir -p /app && chmod 777 /app
WORKDIR /app
# Clone whisper.cpp
RUN git clone https://github.com/ggerganov/whisper.cpp.git /whisper.cpp
WORKDIR /whisper.cpp
# Clone whisper.cpp (shallow clone)
RUN git clone --depth 1 https://github.com/ggerganov/whisper.cpp.git
RUN chmod -R 777 whisper.cpp
# Build whisper.cpp
RUN make
# Build whisper.cpp properly
RUN cd whisper.cpp && \
pwd && \
make
# Download a model (base.en in this example)
RUN ./models/download-ggml-model.sh base.en
# Verify the binary was built
RUN ls -lh /app/whisper.cpp
FROM ubuntu:22.04 AS runtime
# Download the small.en model
RUN mkdir -p /app/whisper.cpp/models && \
cd /app/whisper.cpp/models && \
curl -L "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin" --output ggml-small.en.bin
# 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 built whisper.cpp and model
COPY --from=build /whisper.cpp /whisper.cpp
WORKDIR /whisper.cpp
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip3 install flask flask-cors
# Copy API code
# Copy API server script
COPY app.py .
# Create uploads directory
RUN mkdir -p uploads
# Expose port
EXPOSE 5000
# Set environment variables
ENV WHISPER_CPP_PATH="/app/whisper.cpp"
ENV MODEL_PATH="/app/whisper.cpp/models/ggml-small.en.bin"
EXPOSE 4002
# Run the server
CMD ["python3", "app.py"]