55 lines
1.4 KiB
Docker
55 lines
1.4 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 \
|
|
libavcodec-dev \
|
|
libavformat-dev \
|
|
libavutil-dev \
|
|
libswresample-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Clone whisper.cpp
|
|
RUN git clone https://github.com/ggerganov/whisper.cpp.git /whisper_src
|
|
WORKDIR /whisper_src
|
|
RUN make
|
|
|
|
FROM ubuntu:22.04 AS runtime
|
|
|
|
# Install runtime dependencies with correct package names for Ubuntu 22.04
|
|
RUN apt-get update && apt-get install -y \
|
|
python3 \
|
|
python3-pip \
|
|
ffmpeg \
|
|
libavcodec-extra \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user and directory structure
|
|
RUN useradd -m whisperuser && \
|
|
mkdir -p /app/whisper.cpp && \
|
|
chown whisperuser:whisperuser /app
|
|
|
|
# Copy only necessary files from builder
|
|
COPY --from=builder --chown=whisperuser:whisperuser /whisper_src/main /app/whisper.cpp/main
|
|
COPY --from=builder --chown=whisperuser:whisperuser /whisper_src/libwhisper.a /app/whisper.cpp/
|
|
COPY --from=builder --chown=whisperuser:whisperuser /whisper_src/include /app/whisper.cpp/include
|
|
|
|
# Copy model and application files
|
|
COPY --chown=whisperuser:whisperuser models/ggml-tiny.en.bin /app/whisper.cpp/models/
|
|
COPY --chown=whisperuser:whisperuser app.py /app/
|
|
|
|
# Install Python dependencies
|
|
RUN pip3 install flask flask-cors
|
|
|
|
WORKDIR /app
|
|
USER whisperuser
|
|
|
|
EXPOSE 4002
|
|
|
|
CMD ["python3", "app.py"] |