Skip to content

Commit 3e30d83

Browse files
authored
feat: improve dockerfile (#386)
Signed-off-by: jcriadomarco <[email protected]>
1 parent 7f0d822 commit 3e30d83

File tree

5 files changed

+85
-263
lines changed

5 files changed

+85
-263
lines changed

base-image/Dockerfile

Lines changed: 49 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,54 @@
22
# SPDX-License-Identifier: BSD-2-Clause
33
# Similar to https://github.com/drecom/docker-centos-ruby/blob/2.6.5-slim/Dockerfile
44

5+
FROM photon:4.0
6+
57
ARG RVM_PATH=/usr/local/rvm
68
ARG RUBY_VERSION=ruby-3.1.4
79
ARG RUBY_PATH=/usr/local/rvm/rubies/$RUBY_VERSION
810
ARG RUBYOPT='-W:no-deprecated -W:no-experimental'
911

10-
FROM photon:3.0 AS rubybuild
11-
ARG RVM_PATH
12-
ARG RUBY_PATH
13-
ARG RUBY_VERSION
14-
ARG RUBYOPT
12+
ENV PATH $RUBY_PATH/bin:$PATH
13+
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
14+
ENV BUILDDEPS="\
15+
gmp-devel \
16+
libffi-devel \
17+
bzip2 \
18+
shadow \
19+
wget \
20+
which \
21+
vim \
22+
git \
23+
less \
24+
tar \
25+
gzip \
26+
sed \
27+
gcc \
28+
build-essential \
29+
zlib-devel \
30+
libedit \
31+
libedit-devel \
32+
gdbm \
33+
gdbm-devel \
34+
openssl-devel"
35+
1536
RUN tdnf clean all && \
1637
tdnf upgrade -y && \
1738
tdnf erase -y toybox && \
1839
tdnf install -y \
1940
findutils \
2041
procps-ng \
21-
bzip2 \
22-
shadow \
23-
wget \
24-
which \
25-
vim \
26-
less \
27-
tar \
28-
gzip \
2942
util-linux \
30-
sed \
31-
gcc \
32-
build-essential \
33-
zlib-devel \
34-
libedit \
35-
libedit-devel \
36-
gdbm \
37-
gdbm-devel \
38-
openssl-devel \
3943
systemd \
4044
net-tools \
41-
git \
4245
gpg && \
46+
tdnf install -y $BUILDDEPS && \
4347
tdnf clean all
4448

45-
# Copy Gemfile.lock to pin versions further:
46-
COPY basegems/Gemfile Gemfile
47-
COPY basegems/Gemfile.lock Gemfile.lock
48-
4949
SHELL [ "/bin/bash", "-l", "-c" ]
5050

51+
COPY failsafe.conf entrypoint.sh Gemfile Gemfile.lock /fluentd/
52+
5153
# Install the gems with bundler is better practice:
5254
RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import \
5355
&& curl -sSL https://rvm.io/pkuczynski.asc | gpg --import \
@@ -57,63 +59,17 @@ RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import \
5759
&& rvm requirements \
5860
&& rvm install --disable-binary $RUBY_VERSION --default \
5961
&& gem update --system --no-document \
60-
&& gem install bundler -v '>= 2.3.26' --default --no-document \
61-
&& bundler install
62-
63-
FROM photon:3.0
64-
ARG RUBY_PATH
65-
ARG RUBYOPT
66-
ENV PATH $RUBY_PATH/bin:$PATH
67-
COPY --from=rubybuild $RUBY_PATH $RUBY_PATH
68-
# Not sure why this is needed: see https://github.com/fluent/fluentd-kubernetes-daemonset/blob/master/docker-image/v1.13/debian-elasticsearch7/Dockerfile
69-
# skip runtime bundler installation
70-
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
71-
72-
COPY failsafe.conf entrypoint.sh Gemfile Gemfile.lock /fluentd/
73-
74-
USER root
75-
76-
ENTRYPOINT ["/fluentd/entrypoint.sh"]
62+
&& gem install bundler -v '>= 2.4.13' --default --no-document
7763

64+
## Install dependencies which are not up to date and we need a fork or local download
7865
RUN mkdir -p /fluentd/log /fluentd/etc /fluentd/plugins /usr/local/bundle/bin/ \
79-
&& tdnf clean all \
80-
&& tdnf upgrade -y \
81-
&& tdnf erase -y toybox \
82-
&& buildDeps="\
83-
gmp-devel \
84-
libffi-devel \
85-
bzip2 \
86-
shadow \
87-
wget \
88-
which \
89-
vim \
90-
git \
91-
less \
92-
tar \
93-
gzip \
94-
sed \
95-
gcc \
96-
build-essential \
97-
zlib-devel \
98-
libedit \
99-
libedit-devel \
100-
gdbm \
101-
gdbm-devel \
102-
openssl-devel" \
103-
&& tdnf install -y $buildDeps util-linux systemd net-tools findutils \
10466
&& wget https://raw.githubusercontent.com/fluent/fluentd-kubernetes-daemonset/master/docker-image/v1.15/debian-elasticsearch7/plugins/parser_kubernetes.rb -P /fluentd/plugins \
10567
&& wget https://raw.githubusercontent.com/fluent/fluentd-kubernetes-daemonset/master/docker-image/v1.15/debian-elasticsearch7/plugins/parser_multiline_kubernetes.rb -P /fluentd/plugins \
10668
&& echo 'gem: --no-document' >> /etc/gemrc \
10769
&& bundle config silence_root_warning true \
10870
&& cd /fluentd \
10971
&& bundle install \
11072
&& cd /fluentd \
111-
&& git clone https://github.com/slimm609/fluent-plugin-detect-exceptions.git fluent-plugin-detect-exceptions \
112-
&& cd fluent-plugin-detect-exceptions \
113-
&& gem build fluent-plugin-detect-exceptions.gemspec \
114-
&& gem install fluent-plugin-detect-exceptions-*.gem \
115-
&& rm -rf /fluentd/fluent-plugin-detect-exceptions \
116-
&& cd /fluentd \
11773
&& git clone https://github.com/javiercri/fluent-plugin-google-cloud.git fluent-plugin-google-cloud \
11874
&& cd fluent-plugin-google-cloud \
11975
&& gem build fluent-plugin-google-cloud.gemspec \
@@ -124,25 +80,32 @@ RUN mkdir -p /fluentd/log /fluentd/etc /fluentd/plugins /usr/local/bundle/bin/ \
12480
&& cd fluent-plugin-loggly \
12581
&& gem build fluent-plugin-loggly.gemspec \
12682
&& gem install fluent-plugin-loggly-*.gem \
127-
&& rm -rf /fluentd/fluent-plugin-loggly \
128-
&& wget https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 -P /tmp \
83+
&& rm -rf /fluentd/fluent-plugin-loggly
84+
85+
COPY plugins /fluentd/plugins
86+
87+
## Install jemalloc
88+
RUN wget https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 -P /tmp \
12989
&& tar -C /tmp/ -xjvf /tmp/jemalloc-5.3.0.tar.bz2 \
13090
&& cd /tmp/jemalloc-5.3.0 \
13191
&& ./configure && make \
13292
&& mv -v lib/libjemalloc.so* /usr/lib \
133-
&& rm -rf /tmp/jemalloc-5.3.0 /tmp/jemalloc-5.3.0.tar.bz2 \
134-
&& cd /fluentd \
93+
&& rm -rf /tmp/jemalloc-5.3.0 /tmp/jemalloc-5.3.0.tar.bz2
94+
# Make sure fluentd picks jemalloc 5.3.0 lib as default
95+
ENV LD_PRELOAD="/usr/lib/libjemalloc.so"
96+
97+
## Remove all fluentd build deps and non needit configs
98+
RUN cd /fluentd \
13599
&& gem sources --clear-all \
136100
&& ln -s $(which fluentd) /usr/local/bundle/bin/fluentd \
137-
&& tdnf remove -y $buildDeps \
101+
&& tdnf remove -y $BUILDDEPS \
138102
&& tdnf clean all \
139-
&& gem uninstall google-protobuf --version 3.17.3 --force \
140103
&& gem uninstall bundler \
141104
&& gem cleanup \
142-
&& rm -rf $RUBY_PATH/lib/ruby/gems/2.7.0/cache $RUBY_PATH/lib/ruby/gems/2.7.0/doc/ /usr/share/doc /root/.bundle/cache
143-
144-
# Make sure fluentd picks jemalloc 5.3.0 lib as default
145-
ENV LD_PRELOAD="/usr/lib/libjemalloc.so"
105+
&& rm -rf $RUBY_PATH/lib/ruby/gems/3.1.4/cache $RUBY_PATH/lib/ruby/gems/3.1.4/doc/ /usr/share/doc /root/.bundle/cache
146106

147107
EXPOSE 24444 5140
148-
COPY plugins /fluentd/plugins
108+
109+
USER root
110+
111+
ENTRYPOINT ["/fluentd/entrypoint.sh"]

base-image/Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ gem 'fluent-plugin-azure-loganalytics', "0.7.0"
1010
gem 'fluent-plugin-cloudwatch-logs', "0.14.3"
1111
gem 'fluent-plugin-concat', "2.5.0"
1212
gem 'fluent-plugin-datadog', "0.14.2"
13-
gem 'fluent-plugin-elasticsearch', "5.2.4"
14-
gem 'fluent-plugin-opensearch', "1.0.9"
13+
gem 'fluent-plugin-elasticsearch', "5.3.0"
14+
gem 'fluent-plugin-opensearch', "1.1.0"
1515
gem 'fluent-plugin-gelf-hs', "1.0.8"
1616
gem 'fluent-plugin-grafana-loki', "1.2.20"
1717
gem 'fluent-plugin-grok-parser', "2.6.2"
@@ -51,5 +51,6 @@ gem 'gelf', "3.1.0"
5151
gem 'logfmt', "0.0.10"
5252
gem 'kubeclient', "~> 4.9.3"
5353
gem 'fluent-plugin-webhdfs', '1.5.0'
54+
gem 'fluent-plugin-detect-exceptions', '~> 0.0.15'
5455
# webhdfs requires gssapi plugin to work
5556
gem 'gssapi', '1.3.1'

base-image/Gemfile.lock

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ GEM
1414
amq-protocol (2.3.2)
1515
attr_required (1.0.1)
1616
aws-eventstream (1.2.0)
17-
aws-partitions (1.668.0)
17+
aws-partitions (1.777.0)
1818
aws-sdk-cloudwatchlogs (1.57.0)
1919
aws-sdk-core (~> 3, >= 3.165.0)
2020
aws-sigv4 (~> 1.1)
21-
aws-sdk-core (3.168.2)
21+
aws-sdk-core (3.174.0)
2222
aws-eventstream (~> 1, >= 1.0.2)
2323
aws-partitions (~> 1, >= 1.651.0)
2424
aws-sigv4 (~> 1.5)
@@ -66,35 +66,19 @@ GEM
6666
elasticsearch-api (= 8.5.2)
6767
elasticsearch-api (8.5.2)
6868
multi_json
69-
excon (0.94.0)
70-
faraday (1.10.2)
71-
faraday-em_http (~> 1.0)
72-
faraday-em_synchrony (~> 1.0)
73-
faraday-excon (~> 1.1)
74-
faraday-httpclient (~> 1.0)
75-
faraday-multipart (~> 1.0)
76-
faraday-net_http (~> 1.0)
77-
faraday-net_http_persistent (~> 1.0)
78-
faraday-patron (~> 1.0)
79-
faraday-rack (~> 1.0)
80-
faraday-retry (~> 1.0)
69+
excon (0.100.0)
70+
faraday (2.7.6)
71+
faraday-net_http (>= 2.0, < 3.1)
8172
ruby2_keywords (>= 0.0.4)
82-
faraday-em_http (1.0.0)
83-
faraday-em_synchrony (1.0.0)
84-
faraday-excon (1.1.0)
85-
faraday-httpclient (1.0.1)
86-
faraday-multipart (1.0.4)
87-
multipart-post (~> 2)
88-
faraday-net_http (1.0.1)
89-
faraday-net_http_persistent (1.2.0)
90-
faraday-patron (1.0.0)
91-
faraday-rack (1.0.0)
92-
faraday-retry (1.0.3)
93-
faraday_middleware (1.2.0)
94-
faraday (~> 1.0)
95-
faraday_middleware-aws-sigv4 (0.6.1)
73+
faraday-excon (2.1.0)
74+
excon (>= 0.27.4)
75+
faraday (~> 2.0)
76+
faraday-follow_redirects (0.3.0)
77+
faraday (>= 1, < 3)
78+
faraday-net_http (3.0.2)
79+
faraday_middleware-aws-sigv4 (1.0.1)
9680
aws-sigv4 (~> 1.0)
97-
faraday (>= 1.8, < 2)
81+
faraday (>= 2.0, < 3)
9882
ffi (1.15.5)
9983
ffi-compiler (1.0.1)
10084
ffi (>= 1.0.0)
@@ -120,10 +104,13 @@ GEM
120104
fluent-plugin-datadog (0.14.2)
121105
fluentd (>= 1, < 2)
122106
net-http-persistent (~> 4.0.1)
123-
fluent-plugin-elasticsearch (5.2.4)
107+
fluent-plugin-detect-exceptions (0.0.15)
108+
fluentd (>= 0.10)
109+
fluent-plugin-elasticsearch (5.3.0)
124110
elasticsearch
125111
excon
126-
faraday (~> 1.10)
112+
faraday (>= 2.0.0)
113+
faraday-excon (>= 2.0.0)
127114
fluentd (>= 0.14.22)
128115
fluent-plugin-gelf-hs (1.0.8)
129116
fluentd
@@ -168,11 +155,12 @@ GEM
168155
fluent-plugin-mysqlslowquery (0.0.9)
169156
fluentd (>= 0.12.0, < 2)
170157
myslog (~> 0.0)
171-
fluent-plugin-opensearch (1.0.9)
158+
fluent-plugin-opensearch (1.1.0)
172159
aws-sdk-core (~> 3)
173160
excon
174-
faraday (~> 1.10)
175-
faraday_middleware-aws-sigv4
161+
faraday (>= 2.0.0)
162+
faraday-excon (>= 2.0.0)
163+
faraday_middleware-aws-sigv4 (~> 1.0.1)
176164
fluentd (>= 0.14.22)
177165
opensearch-ruby
178166
fluent-plugin-out-http (1.3.3)
@@ -299,7 +287,6 @@ GEM
299287
bson (>= 4.3.0, < 5.0.0)
300288
msgpack (1.7.1)
301289
multi_json (1.15.0)
302-
multipart-post (2.2.3)
303290
myslog (0.1.1)
304291
net-http-persistent (4.0.1)
305292
connection_pool (~> 2.2)
@@ -315,12 +302,12 @@ GEM
315302
validate_email
316303
validate_url
317304
webfinger (>= 1.0.1)
318-
opensearch-api (2.0.2)
305+
opensearch-api (2.2.0)
319306
multi_json
320-
opensearch-ruby (2.0.3)
321-
opensearch-api (= 2.0.2)
322-
opensearch-transport (~> 2.0.0)
323-
opensearch-transport (2.0.1)
307+
opensearch-ruby (2.1.0)
308+
opensearch-api (~> 2.1)
309+
opensearch-transport (~> 2.0)
310+
opensearch-transport (2.1.0)
324311
faraday (>= 1.0, < 3)
325312
multi_json
326313
prometheus-client (4.0.0)
@@ -376,10 +363,10 @@ GEM
376363
activemodel (>= 3.0.0)
377364
public_suffix
378365
vertica (1.0.3)
379-
webfinger (2.0.0)
366+
webfinger (2.1.2)
380367
activesupport
381-
faraday (~> 1.7)
382-
faraday_middleware (~> 1.1)
368+
faraday (~> 2.0)
369+
faraday-follow_redirects
383370
webhdfs (0.10.2)
384371
addressable
385372
webrick (1.8.1)
@@ -397,7 +384,8 @@ DEPENDENCIES
397384
fluent-plugin-cloudwatch-logs (= 0.14.3)
398385
fluent-plugin-concat (= 2.5.0)
399386
fluent-plugin-datadog (= 0.14.2)
400-
fluent-plugin-elasticsearch (= 5.2.4)
387+
fluent-plugin-detect-exceptions (~> 0.0.15)
388+
fluent-plugin-elasticsearch (= 5.3.0)
401389
fluent-plugin-gelf-hs (= 1.0.8)
402390
fluent-plugin-grafana-loki (= 1.2.20)
403391
fluent-plugin-grok-parser (= 2.6.2)
@@ -413,7 +401,7 @@ DEPENDENCIES
413401
fluent-plugin-mongo (= 1.5.0)
414402
fluent-plugin-multi-format-parser (= 1.0.0)
415403
fluent-plugin-mysqlslowquery (= 0.0.9)
416-
fluent-plugin-opensearch (= 1.0.9)
404+
fluent-plugin-opensearch (= 1.1.0)
417405
fluent-plugin-out-http (= 1.3.3)
418406
fluent-plugin-papertrail (= 0.2.8)
419407
fluent-plugin-prometheus (= 2.0.3)

base-image/basegems/Gemfile

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)