From c9838b69af941637d68bbbaff70fee4402b715cb Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 22 Sep 2017 13:23:58 -0700 Subject: [PATCH] Adjust scanelf to properly remove "ruby-libs" in the "2.4-alpine3.6" image This saves ~11MB of final image size (~79.4MB down to ~68.5MB). --- 2.2/alpine3.4/Dockerfile | 7 +++---- 2.3/alpine3.4/Dockerfile | 7 +++---- 2.4/alpine3.4/Dockerfile | 7 +++---- 2.4/alpine3.6/Dockerfile | 7 +++---- Dockerfile-alpine.template | 7 +++---- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/2.2/alpine3.4/Dockerfile b/2.2/alpine3.4/Dockerfile index 5c019e558a..a25c71e58a 100644 --- a/2.2/alpine3.4/Dockerfile +++ b/2.2/alpine3.4/Dockerfile @@ -75,11 +75,10 @@ RUN set -ex \ && make install \ \ && runDeps="$( \ - scanelf --needed --nobanner --recursive /usr/local \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )" \ && apk add --virtual .ruby-rundeps $runDeps \ bzip2 \ diff --git a/2.3/alpine3.4/Dockerfile b/2.3/alpine3.4/Dockerfile index 2096297936..3132595c67 100644 --- a/2.3/alpine3.4/Dockerfile +++ b/2.3/alpine3.4/Dockerfile @@ -75,11 +75,10 @@ RUN set -ex \ && make install \ \ && runDeps="$( \ - scanelf --needed --nobanner --recursive /usr/local \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )" \ && apk add --virtual .ruby-rundeps $runDeps \ bzip2 \ diff --git a/2.4/alpine3.4/Dockerfile b/2.4/alpine3.4/Dockerfile index be255fa956..2d2de017dc 100644 --- a/2.4/alpine3.4/Dockerfile +++ b/2.4/alpine3.4/Dockerfile @@ -75,11 +75,10 @@ RUN set -ex \ && make install \ \ && runDeps="$( \ - scanelf --needed --nobanner --recursive /usr/local \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )" \ && apk add --virtual .ruby-rundeps $runDeps \ bzip2 \ diff --git a/2.4/alpine3.6/Dockerfile b/2.4/alpine3.6/Dockerfile index 16a22a6455..9d5e8ce4d2 100644 --- a/2.4/alpine3.6/Dockerfile +++ b/2.4/alpine3.6/Dockerfile @@ -75,11 +75,10 @@ RUN set -ex \ && make install \ \ && runDeps="$( \ - scanelf --needed --nobanner --recursive /usr/local \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )" \ && apk add --virtual .ruby-rundeps $runDeps \ bzip2 \ diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index aacd95d1f9..9eccd7b431 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -75,11 +75,10 @@ RUN set -ex \ && make install \ \ && runDeps="$( \ - scanelf --needed --nobanner --recursive /usr/local \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )" \ && apk add --virtual .ruby-rundeps $runDeps \ bzip2 \