From 115143de08f2b4bfed81f74862ee26d566d3455a Mon Sep 17 00:00:00 2001 From: rare-magma Date: Mon, 9 Feb 2026 22:12:18 +0100 Subject: [PATCH] build: reduce cpu and vulkan docker image size Signed-off-by: rare-magma --- .devops/main-vulkan.Dockerfile | 26 +++++++++++++++++++------- .devops/main.Dockerfile | 30 +++++++++++++++++++++--------- .dockerignore | 18 ++++++++++++++++-- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/.devops/main-vulkan.Dockerfile b/.devops/main-vulkan.Dockerfile index 2be22e4d..8bdf02e2 100644 --- a/.devops/main-vulkan.Dockerfile +++ b/.devops/main-vulkan.Dockerfile @@ -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" ] diff --git a/.devops/main.Dockerfile b/.devops/main.Dockerfile index e1eb9b33..8a8878ef 100644 --- a/.devops/main.Dockerfile +++ b/.devops/main.Dockerfile @@ -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" ] diff --git a/.dockerignore b/.dockerignore index 7c5e2438..a006abdf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,17 @@ -build*/ +*.o +*.a +.cache/ +# Do not ignore .git directory, otherwise the reported build number will always be 0 .github/ -.devops/ \ No newline at end of file +.gitignore +.vs/ +.vscode/ +.DS_Store +*.md +*.cmd + +build*/ +.devops/ +models/*.bin +samples/ +tests/ \ No newline at end of file