Created
August 19, 2016 19:26
-
-
Save shoaibi/755f7d05570e54c266401a53917f658a to your computer and use it in GitHub Desktop.
Reducing Docker alpine container size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find /usr/local \ | |
\( -type d -a -name test -o -name tests \) \ | |
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ | |
-exec rm -rf '{}' + \ | |
&& runDeps="$( \ | |
scanelf --needed --nobanner --recursive /usr/local \ | |
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ | |
| sort -u \ | |
| xargs -r apk info --installed \ | |
| sort -u \ | |
)" \ | |
&& apk add --virtual .rundeps $runDeps \ | |
&& apk del .build-deps | |
&& apk del build-base && rm -rf /var/cache/apk/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment