v1.6.0 container image grew 78MiB → 113MiB after pip-based Containerfile switch #29
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Switching the Containerfile from the uv multi-stage build (distroless final image) to a single-stage
python:3.14-slim+pip installbuild (part of #the python-packages PR / v1.6.0) grew the shipped image from 78MiB to 113MiB. Likely causes, roughly in order of impact:Base image is bigger.
gcr.io/distroless/cc-debian13:nonrootis just libc + minimal C runtime libs (no shell/package manager).python:3.14-slimis a full slim Debian install (apt/dpkg, full Python stdlib, libssl/libsqlite/zlib, etc.) — typically ~45-55MiB before installing anything. Probably the single biggest contributor.Lost the multi-stage build. The old Containerfile built with uv in a throwaway stage and copied only
/usr/share/uv(managed Python) +/app(locked,--no-editable,--no-devvenv) into the distroless final image — no pip/setuptools/wheel/build backend ever reached the final layer. The new Containerfile installs directly with pip in the image that ships, so pip/setuptools/wheel and any build-time deps now stay resident insite-packages.pip cache isn't cleared.
pip downloadandpip installpopulate~/.cache/pip(/root/.cache/pip) by default. The Containerfile only removes/tmp/pkg(the downloaded wheel dir) — the pip cache itself persists in the layer. Adding--no-cache-dirto both pip calls (orENV PIP_NO_CACHE_DIR=1) should trim this.Suggested fix: go back to a multi-stage build —
pip install/pip downloadinto apython:3.14-slim(or similar) builder stage, thenCOPY --from=build /app /app(or--target=/app) into a slim/distroless runtime stage, dropping pip/setuptools/apt metadata/cache from the final image. Should claw back most of the ~35MiB delta while keeping the simpler Forgejo-PyPI-based install flow.Revisiting later — filing for tracking.