Skip to content

Commit c9838b6

Browse files
committed
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).
1 parent 076a28b commit c9838b6

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

2.2/alpine3.4/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ RUN set -ex \
7575
&& make install \
7676
\
7777
&& runDeps="$( \
78-
scanelf --needed --nobanner --recursive /usr/local \
79-
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
80-
| sort -u \
81-
| xargs -r apk info --installed \
78+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
79+
| tr ',' '\n' \
8280
| sort -u \
81+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
8382
)" \
8483
&& apk add --virtual .ruby-rundeps $runDeps \
8584
bzip2 \

2.3/alpine3.4/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ RUN set -ex \
7575
&& make install \
7676
\
7777
&& runDeps="$( \
78-
scanelf --needed --nobanner --recursive /usr/local \
79-
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
80-
| sort -u \
81-
| xargs -r apk info --installed \
78+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
79+
| tr ',' '\n' \
8280
| sort -u \
81+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
8382
)" \
8483
&& apk add --virtual .ruby-rundeps $runDeps \
8584
bzip2 \

2.4/alpine3.4/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ RUN set -ex \
7575
&& make install \
7676
\
7777
&& runDeps="$( \
78-
scanelf --needed --nobanner --recursive /usr/local \
79-
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
80-
| sort -u \
81-
| xargs -r apk info --installed \
78+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
79+
| tr ',' '\n' \
8280
| sort -u \
81+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
8382
)" \
8483
&& apk add --virtual .ruby-rundeps $runDeps \
8584
bzip2 \

2.4/alpine3.6/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ RUN set -ex \
7575
&& make install \
7676
\
7777
&& runDeps="$( \
78-
scanelf --needed --nobanner --recursive /usr/local \
79-
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
80-
| sort -u \
81-
| xargs -r apk info --installed \
78+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
79+
| tr ',' '\n' \
8280
| sort -u \
81+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
8382
)" \
8483
&& apk add --virtual .ruby-rundeps $runDeps \
8584
bzip2 \

Dockerfile-alpine.template

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ RUN set -ex \
7575
&& make install \
7676
\
7777
&& runDeps="$( \
78-
scanelf --needed --nobanner --recursive /usr/local \
79-
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
80-
| sort -u \
81-
| xargs -r apk info --installed \
78+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
79+
| tr ',' '\n' \
8280
| sort -u \
81+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
8382
)" \
8483
&& apk add --virtual .ruby-rundeps $runDeps \
8584
bzip2 \

0 commit comments

Comments
 (0)