From 5ad9f275eff0847e0ba47d59d623b3bb10ef0de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 7 Mar 2017 23:01:19 +0100 Subject: [PATCH] Strip Python install, saves roughly 90 MB in final image size. --- docker/2_buildpy/build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker/2_buildpy/build.sh b/docker/2_buildpy/build.sh index 665385d..9c119e7 100755 --- a/docker/2_buildpy/build.sh +++ b/docker/2_buildpy/build.sh @@ -33,6 +33,15 @@ make -j8 install chown -R $UID:$GID /opt/python/* EOT +# Strip some stuff we don't need from the Python install. +rm -rf $PYTHONTARGET/lib/python3.*/test +rm -rf $PYTHONTARGET/lib/python3.*/config-3.*/libpython3.*.a +find $PYTHONTARGET/lib -name '*.so.*' -o -name '*.so' | while read libname; do + chmod u+w "$libname" + strip "$libname" +done + + # Create another docker image which contains the actual Python. # This one will serve as base for the Wheel builder and the # production image.