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
@@ -88,7 +88,7 @@ jobs:
|
||||
dockerfile: Dockerfile
|
||||
job_image: ubuntu:26.04@sha256:065aa8626841f16057b78b027b464cd59c4fac36c204c72dcbf48d66f5fa8a96
|
||||
- name: ci
|
||||
version: 0.2.26
|
||||
version: 0.2.27
|
||||
subpath: ""
|
||||
dockerfile: images/ci/Dockerfile
|
||||
job_image: ubuntu:26.04@sha256:065aa8626841f16057b78b027b464cd59c4fac36c204c72dcbf48d66f5fa8a96
|
||||
|
||||
@@ -118,7 +118,10 @@ Single-context: `GLOSSARY.md` and `docs/adr/` at the root, both created lazily.
|
||||
The docs sit outside the image directories on purpose: editing them is not an image input, so it needs no
|
||||
new version. Editing a label in a Dockerfile is an input and does.
|
||||
- Each pushed layer must stay below 100 MB: Cloudflare rejects larger request bodies with
|
||||
HTTP 413. That is why the `ci` image deletes the Go toolchains from the hook cache.
|
||||
HTTP 413. That is why the `ci` image deletes the Go toolchains from the hook cache and the unused
|
||||
`libpython*.so` of its three baked interpreters (the `/opt/python` layer was 99 MB compressed with them,
|
||||
ci 0.2.26 failed to push). The build prints the compressed size of each layer directory; the registry
|
||||
stores about 9% more, so read that line before adding an interpreter or a hook environment.
|
||||
- `image.yml` is the only workflow that may reference the org Actions secrets (the registry push credential). Never print or use them anywhere else.
|
||||
|
||||
## Dependency automation (Renovate)
|
||||
|
||||
@@ -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