From 8ec08d20b1f34ee777bfbbb5501ab1c7e194d61a Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Sun, 4 Oct 2026 17:30:07 -0400 Subject: [PATCH] perf: prune build toolchains and static libs to reduce image size shrink image size by ~3GB: ``` [ahze@saturn ~/src/daemonless/paperless-ngx]$ doas podman images --filter reference="*paperless-ngx*" REPOSITORY TAG IMAGE ID CREATED SIZE ghcr.io/daemonless/paperless-ngx build-latest 26555c2c626e 15 minutes ago 6.53 GB ghcr.io/daemonless/paperless-ngx latest 447d560112a0 13 days ago 9.77 GB [ahze@saturn ~/src/daemonless/paperless-ngx]$ ``` --- Containerfile | 17 ++++++++--------- Containerfile.j2 | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Containerfile b/Containerfile index a3cefcf..5210220 100644 --- a/Containerfile +++ b/Containerfile @@ -194,7 +194,7 @@ pkg update && pkg install -y uv git zip yq \ py312-llama-index-core \ py312-nltk \ py312-Babel \ - yq libxslt \ + libxslt \ mariadb118-client postgresql18-client openblas libheif poppler-utils \ py312-psycopg-pool \ py312-redis5 \ @@ -223,8 +223,6 @@ pkg update && pkg install -y uv git zip yq \ py312-scikit-learn \ py312-hatchling \ py312-prek \ - py312-scipy \ - py312-numpy \ py312-pillow \ py312-rapidfuzz \ py312-zensical \ @@ -250,6 +248,11 @@ pkg update && pkg install -y uv git zip yq \ pngquant pkg clean -ay rm -rf /var/cache/pkg/* /var/db/pkg/repos/* +find /usr/local -name '*.a' -delete +rm -rf /usr/local/share/doc /usr/local/share/man /usr/local/include /usr/local/llvm19/include /usr/local/llvm19/bin +rm -rf /usr/local/libexec/gcc14 /usr/local/bin/*-portbld-freebsd* /usr/local/*-portbld-freebsd* +rm -f /usr/local/bin/gcc* /usr/local/bin/g++* /usr/local/bin/gfortran* /usr/local/bin/cpp* /usr/local/bin/c++* +rm -f /usr/local/lib/libopcodes* /usr/local/lib/libbfd* CMD_EOF # Copy artifacts from build stage @@ -259,6 +262,7 @@ COPY --from=builder /wheels /app/wheels RUN <