Skip to content

Commit b63b5bb

Browse files
committed
Cleanup large unused files
Reduces the alpine image from 46M to 36M, and debian image from 210M to 195M. yajl parts can be removed if/when brianmario/yajl-ruby#228 is merged and released. Signed-off-by: Orgad Shaneh <[email protected]>
1 parent 5fb50cd commit b63b5bb

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

Dockerfile.template.erb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ RUN apt-get update \
120120
&& gem install async -v 1.32.1 \
121121
&& gem install async-http -v 0.64.2 \
122122
&& gem install fluentd -v <%= fluentd_ver %> \
123+
&& export GEM_DIR=$(ruby -e 'puts Gem.dir') \
124+
&& echo GEM_DIR=$GEM_DIR \
125+
&& rm -rf $GEM_DIR/cache/*.gem \
126+
&& find $GEM_DIR -type d -name test -or -name ext -or -name spec -or -name benchmark | xargs -r rm -rf \
127+
&& find $GEM_DIR -name "*.so" | xargs -r strip \
123128
<% if is_alpine %>
124129
&& gem install bigdecimal -v 1.4.4 \
125130
&& apk del .build-deps \
@@ -146,7 +151,7 @@ RUN apt-get update \
146151
'*-dev' \
147152
&& rm -rf /var/lib/apt/lists/* \
148153
<% end %>
149-
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem /usr/lib/ruby/gems/3.*/gems/fluentd-*/test
154+
&& rm -rf /tmp/* /var/tmp/*
150155

151156
<% if is_alpine %>
152157
RUN addgroup -S fluent && adduser -S -G fluent fluent \

v1.17/alpine/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ RUN apk update \
2323
&& gem install async -v 1.32.1 \
2424
&& gem install async-http -v 0.64.2 \
2525
&& gem install fluentd -v 1.17.1 \
26+
&& export GEM_DIR=$(ruby -e 'puts Gem.dir') \
27+
&& echo GEM_DIR=$GEM_DIR \
28+
&& rm -rf $GEM_DIR/cache/*.gem \
29+
&& find $GEM_DIR -type d -name test -or -name ext -or -name spec -or -name benchmark | xargs -r rm -rf \
30+
&& find $GEM_DIR -name "*.so" | xargs -r strip \
2631
&& gem install bigdecimal -v 1.4.4 \
2732
&& apk del .build-deps \
2833
&& rm -rf /var/cache/apk/* \
29-
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem /usr/lib/ruby/gems/3.*/gems/fluentd-*/test
34+
&& rm -rf /tmp/* /var/tmp/*
3035

3136
RUN addgroup -S fluent && adduser -S -G fluent fluent \
3237
# for log storage (maybe shared with host)

v1.17/arm64/debian/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ RUN apt-get update \
3535
&& gem install async -v 1.32.1 \
3636
&& gem install async-http -v 0.64.2 \
3737
&& gem install fluentd -v 1.17.1 \
38+
&& export GEM_DIR=$(ruby -e 'puts Gem.dir') \
39+
&& echo GEM_DIR=$GEM_DIR \
40+
&& rm -rf $GEM_DIR/cache/*.gem \
41+
&& find $GEM_DIR -type d -name test -or -name ext -or -name spec -or -name benchmark | xargs -r rm -rf \
42+
&& find $GEM_DIR -name "*.so" | xargs -r strip \
3843
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
3944
&& wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch" \
4045
&& wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch.asc" \
@@ -55,7 +60,7 @@ RUN apt-get update \
5560
$buildDeps \
5661
'*-dev' \
5762
&& rm -rf /var/lib/apt/lists/* \
58-
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem /usr/lib/ruby/gems/3.*/gems/fluentd-*/test
63+
&& rm -rf /tmp/* /var/tmp/*
5964

6065
RUN groupadd -r fluent && useradd -r -g fluent fluent \
6166
# for log storage (maybe shared with host)

v1.17/armhf/debian/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ RUN apt-get update \
3535
&& gem install async -v 1.32.1 \
3636
&& gem install async-http -v 0.64.2 \
3737
&& gem install fluentd -v 1.17.1 \
38+
&& export GEM_DIR=$(ruby -e 'puts Gem.dir') \
39+
&& echo GEM_DIR=$GEM_DIR \
40+
&& rm -rf $GEM_DIR/cache/*.gem \
41+
&& find $GEM_DIR -type d -name test -or -name ext -or -name spec -or -name benchmark | xargs -r rm -rf \
42+
&& find $GEM_DIR -name "*.so" | xargs -r strip \
3843
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
3944
&& wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch" \
4045
&& wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch.asc" \
@@ -55,7 +60,7 @@ RUN apt-get update \
5560
$buildDeps \
5661
'*-dev' \
5762
&& rm -rf /var/lib/apt/lists/* \
58-
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem /usr/lib/ruby/gems/3.*/gems/fluentd-*/test
63+
&& rm -rf /tmp/* /var/tmp/*
5964

6065
RUN groupadd -r fluent && useradd -r -g fluent fluent \
6166
# for log storage (maybe shared with host)

v1.17/debian/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ RUN apt-get update \
2424
&& gem install async -v 1.32.1 \
2525
&& gem install async-http -v 0.64.2 \
2626
&& gem install fluentd -v 1.17.1 \
27+
&& export GEM_DIR=$(ruby -e 'puts Gem.dir') \
28+
&& echo GEM_DIR=$GEM_DIR \
29+
&& rm -rf $GEM_DIR/cache/*.gem \
30+
&& find $GEM_DIR -type d -name test -or -name ext -or -name spec -or -name benchmark | xargs -r rm -rf \
31+
&& find $GEM_DIR -name "*.so" | xargs -r strip \
2732
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
2833
&& wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch" \
2934
&& wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch.asc" \
@@ -44,7 +49,7 @@ RUN apt-get update \
4449
$buildDeps \
4550
'*-dev' \
4651
&& rm -rf /var/lib/apt/lists/* \
47-
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem /usr/lib/ruby/gems/3.*/gems/fluentd-*/test
52+
&& rm -rf /tmp/* /var/tmp/*
4853

4954
RUN groupadd -r fluent && useradd -r -g fluent fluent \
5055
# for log storage (maybe shared with host)

0 commit comments

Comments
 (0)