build: reduce cpu and vulkan docker image size

Signed-off-by: rare-magma <rare-magma@posteo.eu>
This commit is contained in:
rare-magma 2026-02-09 22:12:18 +01:00
parent 764482c317
commit 115143de08
No known key found for this signature in database
3 changed files with 56 additions and 18 deletions

View File

@ -5,16 +5,28 @@ RUN apt-get update && \
apt-get install -y build-essential wget cmake git libvulkan-dev glslc \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
COPY .. .
RUN make base.en CMAKE_ARGS="-DGGML_VULKAN=1"
COPY . .
RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_VULKAN=ON -DWHISPER_BUILD_TESTS=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON \
&& cmake --build build --config Release -j $(nproc)
RUN mkdir -p /app/lib && \
find build -name "*.so*" -exec cp -P {} /app/lib \;
FROM ubuntu:24.04 AS runtime
WORKDIR /app
RUN apt-get update && \
apt-get install -y curl ffmpeg libsdl2-dev wget cmake git libvulkan1 mesa-vulkan-drivers \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
RUN apt-get update \
&& apt-get install -y curl ffmpeg wget libvulkan1 mesa-vulkan-drivers \
&& apt autoremove -y \
&& apt clean -y \
&& rm -rf /tmp/* /var/tmp/* \
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
&& find /var/cache -type f -delete
COPY --from=build /app /app
ENV PATH=/app/build/bin:$PATH
COPY --from=build /app/build/bin /app
COPY --from=build /app/lib /app
COPY --from=build /app/models /app/models
ENV PATH=/app:$PATH
ENTRYPOINT [ "bash", "-c" ]

View File

@ -1,20 +1,32 @@
FROM ubuntu:22.04 AS build
FROM ubuntu:24.04 AS build
WORKDIR /app
RUN apt-get update && \
apt-get install -y build-essential wget cmake git \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
COPY .. .
RUN make base.en
COPY . .
FROM ubuntu:22.04 AS runtime
RUN cmake -B build -DGGML_NATIVE=OFF -DWHISPER_BUILD_TESTS=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON \
&& cmake --build build --config Release -j $(nproc)
RUN mkdir -p /app/lib && \
find build -name "*.so*" -exec cp -P {} /app/lib \;
FROM ubuntu:24.04 AS runtime
WORKDIR /app
RUN apt-get update && \
apt-get install -y curl ffmpeg libsdl2-dev wget cmake git \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
RUN apt-get update \
&& apt-get install -y curl ffmpeg wget \
&& apt autoremove -y \
&& apt clean -y \
&& rm -rf /tmp/* /var/tmp/* \
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
&& find /var/cache -type f -delete
COPY --from=build /app /app
ENV PATH=/app/build/bin:$PATH
COPY --from=build /app/build/bin /app
COPY --from=build /app/lib /app
COPY --from=build /app/models /app/models
ENV PATH=/app:$PATH
ENTRYPOINT [ "bash", "-c" ]

View File

@ -1,3 +1,17 @@
build*/
*.o
*.a
.cache/
# Do not ignore .git directory, otherwise the reported build number will always be 0
.github/
.devops/
.gitignore
.vs/
.vscode/
.DS_Store
*.md
*.cmd
build*/
.devops/
models/*.bin
samples/
tests/