fix(image): drop the unused libpython shared libraries from the ci image
The ci 0.2.26 build succeeded but its push got HTTP 413 from Cloudflare: the /opt/python layer, now three baked interpreters (3.11, 3.13, 3.14), was 99.1 MB compressed (the registry stores about 9% more), over the 95 MiB limit. Each python-build-standalone interpreter ships a ~33 MB lib/libpython<MINOR>.so next to a statically linked python binary that does not use it. Remove it unless the binary links it. /opt/python goes from 95.8 to 67.7 MB compressed in a local run; all three interpreters still import ssl, sqlite3 and venv. ci image 0.2.26 (never published) -> 0.2.27. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
This commit is contained in:
1 parent
8239ba2bd4
commit
cf5f4b596c
3 files changed
+20
-2
No files matched your search
@@ -75,6 +75,21 @@ RUN python3 -m venv /opt/uv-venv \
|
||||
&& /opt/uv-venv/bin/pip install uv==0.13.8 \
|
||||
&& /opt/uv-venv/bin/uv python install 3.11 3.13 ${PYTHON_VERSION}
|
||||
|
||||
# python-build-standalone ships lib/libpython<MINOR>.so (about 33 MB, 10 MB compressed) next to a statically
|
||||
# linked python binary; nothing in this image links it, and with it the /opt/python layer of three interpreters
|
||||
# was 99.1 MB compressed, which Cloudflare refused with HTTP 413 (ci 0.2.26 failed to push). A copy is kept when
|
||||
# the binary does link it, so a change of build flavour cannot break the interpreter.
|
||||
RUN set -eu; \
|
||||
for v in $(printf '%s\n' 3.11 3.13 "${PYTHON_VERSION}" | sort -u); do \
|
||||
d="$(echo /opt/python/cpython-${v}.*/)"; \
|
||||
if ldd "${d}bin/python${v}" | grep -q libpython; then \
|
||||
echo "python${v} links libpython: keeping it"; \
|
||||
else \
|
||||
rm -f "${d}"lib/libpython*.so*; \
|
||||
fi; \
|
||||
done; \
|
||||
du -sh /opt/python
|
||||
|
||||
# The real path under /opt/python, which the final stage copies (/opt/python-bin does not exist there):
|
||||
# the venv's python is a symlink to the interpreter it was created from.
|
||||
RUN "$(echo /opt/python/cpython-${PYTHON_VERSION}.*/bin/python${PYTHON_VERSION})" -m venv /opt/venv \
|
||||
|
||||
Reference in new issue
Block a user