1
0

image: cleanup layers a bit more

mostly Python-related cleanup
This commit is contained in:
Konstantin Demin 2024-10-10 00:23:55 +03:00
parent 283f61e866
commit c4feaf9f83
Signed by: krd
GPG Key ID: 4D56F87A8BA65FD0
2 changed files with 23 additions and 1 deletions

View File

@ -211,14 +211,29 @@ RUN pip-env.sh pip list --format freeze \
RUN libpython="${PYTHON_SITE_PACKAGES%/*}" ; \ RUN libpython="${PYTHON_SITE_PACKAGES%/*}" ; \
rm -rfv \ rm -rfv \
/usr/local/bin/idle* \ /usr/local/bin/idle* \
/usr/local/bin/pydoc* \
"${libpython}/ensurepip/_bundled" \ "${libpython}/ensurepip/_bundled" \
"${libpython}/idlelib" \ "${libpython}/idlelib" \
"${libpython}/pydoc.py" \
"${libpython}/pydoc_data" \
"${libpython}/tkinter" \ "${libpython}/tkinter" \
"${libpython}/turtle.py" \ "${libpython}/turtle.py" \
"${libpython}/turtledemo" \ "${libpython}/turtledemo" \
; \ ; \
rm -rfv \
"${PYTHON_SITE_PACKAGES}/pkg_resources/tests" \
"${PYTHON_SITE_PACKAGES}/setuptools/tests" \
"${PYTHON_SITE_PACKAGES}/setuptools/_distutils/tests" \
"${PYTHON_SITE_PACKAGES}/setuptools/_vendor/importlib_resources/tests" \
; \
find "${PYTHON_SITE_PACKAGES}/" -iname '*.exe' -ls -delete ; \
python-rm-cache.sh /usr/local python-rm-cache.sh /usr/local
## adjust pip/certifi
RUN certifi_pem="${PYTHON_SITE_PACKAGES}/pip/_vendor/certifi/cacert.pem" ; \
rm -f "${certifi_pem}" ; \
ln -s /etc/ssl/certs/ca-certificates.crt "${certifi_pem}"
RUN find /usr/local/sbin/ ! -type d -ls -delete ; \ RUN find /usr/local/sbin/ ! -type d -ls -delete ; \
find /run/ -mindepth 1 -ls -delete || : ; \ find /run/ -mindepth 1 -ls -delete || : ; \
install -d -m 01777 /run/lock install -d -m 01777 /run/lock

View File

@ -41,12 +41,19 @@ RUN w=$(mktemp -d) ; : "${w:?}" ; \
echo ; \ echo ; \
find "${PYTHON_SITE_PACKAGES}/" -type f -name '*.so*' -printf '%p\0' \ find "${PYTHON_SITE_PACKAGES}/" -type f -name '*.so*' -printf '%p\0' \
| sed -zE '/rust/d' \ | sed -zE '/rust/d' \
| xargs -0r strip --verbose --strip-debug ; \ | xargs -0r strip --verbose --strip-debug --strip-unneeded ; \
echo ; \ echo ; \
find "${PYTHON_SITE_PACKAGES}/" -type f -name '*.so*' -exec ls -l {} + ; \ find "${PYTHON_SITE_PACKAGES}/" -type f -name '*.so*' -exec ls -l {} + ; \
apt-remove.sh build-essential ; \ apt-remove.sh build-essential ; \
apt-clean.sh apt-clean.sh
## avoid changing already present packages
RUN find "${PYTHON_SITE_PACKAGES}/" -mindepth 1 -maxdepth 1 -printf '%P\0' \
| sed -zEn \
-e '/^((pip|setuptools|wheel)-.+\.dist-info|distutils-precedence\.pth|_distutils_hack|pip|pkg_resources|setuptools|wheel)$/p' \
| env -C "${PYTHON_SITE_PACKAGES}" xargs -0r \
rm -rf
## --- ## ---
FROM base AS deps FROM base AS deps