Skip to content

Commit 8472f82

Browse files
committed
Updates to custom docker image instruction
1 parent 71bafc3 commit 8472f82

File tree

9 files changed

+398
-25
lines changed

9 files changed

+398
-25
lines changed

docs/custom-images.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ By default, pre-built images by Oracle are used.
1212
##### Fluentd Container Image
1313

1414
- Download all the files from the below mentioned dir into a local machine having access to internet and docker installed.
15-
- [OL8](logan/docker-images/v1.0/oraclelinux/8/)
15+
- [OL8-Slim](logan/docker-images/v1.0/oraclelinux/8-slim/)
1616
- Run the following command to build the image.
1717
- `docker build -t oci-la-fluentd-collector-custom -f Dockerfile .`
1818
- The docker image built from the above step, can either be pushed to Docker Hub or OCI Container Registry (OCIR) or to a Local Docker Registry depending on the requirements.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
### Build the docker image using multi-stage build
2+
3+
## To build/install all the dependencies
4+
5+
FROM container-registry.oracle.com/os/oraclelinux:8-slim AS builder
6+
7+
USER root
8+
WORKDIR /fluentd
9+
10+
# Environment variables
11+
ENV PATH /fluentd/vendor/bundle/ruby/2.7.0/bin:$PATH
12+
ENV GEM_PATH /fluentd/vendor/bundle/ruby/2.7.0:$GEM_PATH
13+
ENV GEM_HOME /fluentd/vendor/bundle/ruby/2.7.0
14+
# skip runtime bundler installation
15+
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
16+
17+
COPY Gemfile* /fluentd/
18+
19+
# Install ruby, ruby-libs along with rubygems and bundler.
20+
RUN microdnf -y module enable ruby:2.7 \
21+
# Install ruby (it's dependencies gdbm-libs) and ruby-libs, disabling week dependencies
22+
&& microdnf -y install --setopt=install_weak_deps=0 --nodocs ruby-2.7.6 ruby-libs-2.7.6 gdbm-libs \
23+
# Install rubygems (it's dependencies rubygem-openssl rubygem-psych), disabling week dependencies
24+
&& microdnf -y install --setopt=install_weak_deps=0 --nodocs rubygems-3.1.6 \
25+
&& gem install bundler -v 2.3.25 \
26+
# Install development dependent packages for gems native installation
27+
&& microdnf -y install --nodocs gcc make redhat-rpm-config openssl ruby-devel gcc-c++ libtool libffi-devel bzip2 git \
28+
# Install Fluentd, it's dependencies along with other run time dependencies for OCI Logging Analytics Solution
29+
&& bundle config silence_root_warning true \
30+
&& bundle config --local path /fluentd/vendor/bundle \
31+
&& bundle config --global jobs 9 \
32+
&& bundle install --gemfile=/fluentd/Gemfile \
33+
# Install tini, init for containers (from EPEL repo)
34+
&& microdnf -y install oracle-epel-release-el8 \
35+
&& microdnf -y install tini-0.19.0 \
36+
# Install jemalloc (custom make with no docs)
37+
&& cd /tmp && ls /tmp \
38+
&& git clone -b 5.3.0 https://github.com/jemalloc/jemalloc.git && cd jemalloc/ \
39+
&& ./autogen.sh && make && make install_bin install_include install_lib \
40+
&& mv lib/libjemalloc.so.2 /usr/lib
41+
42+
## To build the final docker image
43+
44+
FROM container-registry.oracle.com/os/oraclelinux:8-slim
45+
46+
USER root
47+
WORKDIR /fluentd
48+
49+
# Environment variables
50+
ENV PATH /fluentd/vendor/bundle/ruby/2.7.0/bin:$PATH
51+
ENV GEM_PATH /fluentd/vendor/bundle/ruby/2.7.0:$GEM_PATH
52+
ENV GEM_HOME /fluentd/vendor/bundle/ruby/2.7.0
53+
# skip runtime bundler installation
54+
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
55+
56+
# Install ruby, ruby-libs along with rubygems and bundler.
57+
RUN microdnf -y module enable ruby:2.7 \
58+
# Install ruby (it's dependencies gdbm-libs) and ruby-libs, disabling week dependencies
59+
&& microdnf -y install --setopt=install_weak_deps=0 --nodocs ruby-2.7.6 ruby-libs-2.7.6 gdbm-libs \
60+
# Install rubygems (it's dependencies rubygem-openssl rubygem-psych), disabling week dependencies
61+
&& microdnf -y install --setopt=install_weak_deps=0 --nodocs rubygems-3.1.6 \
62+
&& gem install bundler -v 2.3.25 \
63+
&& bundle config --local path /fluentd/vendor/bundle \
64+
# clear caches
65+
&& microdnf clean all \
66+
&& rm -rf /var/cache/dnf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
67+
68+
# Copy binaries (tini & jemallco) and rubygems bundler environment from build stage
69+
COPY --from=builder /fluentd /fluentd
70+
COPY --from=builder /usr/bin/tini /usr/bin/tini
71+
COPY --from=builder /usr/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.2
72+
73+
RUN mkdir -p /fluentd/etc /fluentd/plugins \
74+
&& touch /fluentd/etc/disable.conf
75+
76+
# Environment variables
77+
ENV FLUENTD_CONF="/fluentd/etc/fluent.conf"
78+
ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2"
79+
80+
COPY entrypoint.sh /fluentd/entrypoint.sh
81+
# Give execution permission to entrypoint.sh
82+
RUN ["chmod", "+x", "/fluentd/entrypoint.sh"]
83+
84+
# Overwrite ENTRYPOINT to run fluentd as root for /var/log / /var/lib
85+
ENTRYPOINT ["tini", "--", "/fluentd/entrypoint.sh"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
source "https://rubygems.org"
5+
6+
gem "oj", "3.14.1"
7+
gem "json", "2.6.3"
8+
gem "ext_monitor", "0.1.2"
9+
gem "fluentd", "1.15.3"
10+
gem "fluent-plugin-oci-logging-analytics", "2.0.5"
11+
gem "fluent-plugin-concat", "~> 2.5.0"
12+
gem "fluent-plugin-rewrite-tag-filter", "~> 2.4.0"
13+
gem "fluent-plugin-parser-cri", "~> 0.1.1"
14+
gem "fluent-plugin-kubernetes_metadata_filter", "2.13.0"
15+
gem "fluent-plugin-kubernetes-objects", "1.2.1"
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.8.1)
5+
public_suffix (>= 2.0.2, < 6.0)
6+
concurrent-ruby (1.2.0)
7+
cool.io (1.7.1)
8+
domain_name (0.5.20190701)
9+
unf (>= 0.0.5, < 1.0.0)
10+
ext_monitor (0.1.2)
11+
ffi (1.15.5)
12+
ffi-compiler (1.0.1)
13+
ffi (>= 1.0.0)
14+
rake
15+
fluent-config-regexp-type (1.0.0)
16+
fluentd (> 1.0.0, < 2)
17+
fluent-plugin-concat (2.5.0)
18+
fluentd (>= 0.14.0, < 2)
19+
fluent-plugin-kubernetes-objects (1.2.1)
20+
fluentd (>= 1.9.1)
21+
http_parser.rb (= 0.8.0)
22+
kubeclient (~> 4.9.3)
23+
fluent-plugin-kubernetes_metadata_filter (2.13.0)
24+
fluentd (>= 0.14.0, < 1.16)
25+
kubeclient (>= 4.0.0, < 5.0.0)
26+
lru_redux
27+
fluent-plugin-oci-logging-analytics (2.0.5)
28+
fluentd (>= 0.14.10, < 2)
29+
oci (~> 2.16)
30+
prometheus-client (~> 4.0.0)
31+
rubyzip (~> 2.3.2)
32+
yajl-ruby (~> 1.4, >= 1.4.3)
33+
fluent-plugin-parser-cri (0.1.1)
34+
fluentd (>= 1)
35+
fluent-plugin-rewrite-tag-filter (2.4.0)
36+
fluent-config-regexp-type
37+
fluentd (>= 0.14.2, < 2)
38+
fluentd (1.15.3)
39+
bundler
40+
cool.io (>= 1.4.5, < 2.0.0)
41+
http_parser.rb (>= 0.5.1, < 0.9.0)
42+
msgpack (>= 1.3.1, < 2.0.0)
43+
serverengine (>= 2.3.0, < 3.0.0)
44+
sigdump (~> 0.2.2)
45+
strptime (>= 0.2.4, < 1.0.0)
46+
tzinfo (>= 1.0, < 3.0)
47+
tzinfo-data (~> 1.0)
48+
webrick (>= 1.4.2, < 1.8.0)
49+
yajl-ruby (~> 1.0)
50+
http (4.4.1)
51+
addressable (~> 2.3)
52+
http-cookie (~> 1.0)
53+
http-form_data (~> 2.2)
54+
http-parser (~> 1.2.0)
55+
http-accept (1.7.0)
56+
http-cookie (1.0.5)
57+
domain_name (~> 0.5)
58+
http-form_data (2.3.0)
59+
http-parser (1.2.3)
60+
ffi-compiler (>= 1.0, < 2.0)
61+
http_parser.rb (0.8.0)
62+
inifile (3.0.0)
63+
json (2.6.3)
64+
jsonpath (1.1.2)
65+
multi_json
66+
jwt (2.7.0)
67+
kubeclient (4.9.3)
68+
http (>= 3.0, < 5.0)
69+
jsonpath (~> 1.0)
70+
recursive-open-struct (~> 1.1, >= 1.1.1)
71+
rest-client (~> 2.0)
72+
lru_redux (1.1.0)
73+
mime-types (3.4.1)
74+
mime-types-data (~> 3.2015)
75+
mime-types-data (3.2022.0105)
76+
msgpack (1.7.1)
77+
multi_json (1.15.0)
78+
netrc (0.11.0)
79+
oci (2.18.0)
80+
inifile (~> 3.0, >= 3.0.0)
81+
json (>= 1.4.6, < 3.0.0)
82+
jwt (~> 2.1)
83+
oj (3.14.1)
84+
prometheus-client (4.0.0)
85+
public_suffix (5.0.1)
86+
rake (13.0.6)
87+
recursive-open-struct (1.1.3)
88+
rest-client (2.1.0)
89+
http-accept (>= 1.7.0, < 2.0)
90+
http-cookie (>= 1.0.2, < 2.0)
91+
mime-types (>= 1.16, < 4.0)
92+
netrc (~> 0.8)
93+
rubyzip (2.3.2)
94+
serverengine (2.3.1)
95+
sigdump (~> 0.2.2)
96+
sigdump (0.2.4)
97+
strptime (0.2.5)
98+
tzinfo (2.0.6)
99+
concurrent-ruby (~> 1.0)
100+
tzinfo-data (1.2022.7)
101+
tzinfo (>= 1.0.0)
102+
unf (0.1.4)
103+
unf_ext
104+
unf_ext (0.0.8.2)
105+
webrick (1.7.0)
106+
yajl-ruby (1.4.3)
107+
108+
PLATFORMS
109+
x86_64-linux
110+
111+
DEPENDENCIES
112+
ext_monitor (= 0.1.2)
113+
fluent-plugin-concat (~> 2.5.0)
114+
fluent-plugin-kubernetes-objects (= 1.2.1)
115+
fluent-plugin-kubernetes_metadata_filter (= 2.13.0)
116+
fluent-plugin-oci-logging-analytics (= 2.0.5)
117+
fluent-plugin-parser-cri (~> 0.1.1)
118+
fluent-plugin-rewrite-tag-filter (~> 2.4.0)
119+
fluentd (= 1.15.3)
120+
json (= 2.6.3)
121+
oj (= 3.14.1)
122+
123+
BUNDLED WITH
124+
2.3.25
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
bundle exec fluentd -c ${FLUENTD_CONF} -p /fluentd/plugins --gemfile /fluentd/Gemfile ${FLUENTD_OPT}

logan/docker-images/v1.0/oraclelinux/8/Dockerfile

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Copyright (c) 2023, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl.
33

4-
FROM container-registry.oracle.com/os/oraclelinux:8
4+
## To build/install all the dependencies
5+
6+
FROM container-registry.oracle.com/os/oraclelinux:8 AS builder
57

68
USER root
79
WORKDIR /fluentd
@@ -14,15 +16,15 @@ ENV GEM_HOME /fluentd/vendor/bundle/ruby/2.7.0
1416
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
1517
ENV TINI_VERSION=0.19.0
1618

17-
COPY Gemfile /fluentd/
19+
COPY Gemfile* /fluentd/
1820

1921
# Install ruby 2.7 along with rubygems and bundler.
2022
RUN dnf -y module enable ruby:2.7 \
21-
&& dnf -y install --nodocs ruby ruby-libs \
22-
&& dnf -y install --nodocs rubygems rubygem-openssl rubygem-psych \
23-
&& dnf -y install --nodocs rubygem-bundler rubygem-io-console \
23+
&& dnf -y install --setopt=install_weak_deps=False --nodocs ruby-2.7.6 ruby-libs-2.7.6 gdbm-libs \
24+
&& dnf -y install --setopt=install_weak_deps=False --nodocs rubygems-3.1.6 \
25+
&& gem install bundler -v 2.3.25 \
2426
# Install development dependent packages for gems native installation
25-
&& dnf -y install --nodocs gcc make redhat-rpm-config openssl ruby-devel gcc-c++ libtool libffi-devel bzip2 \
27+
&& dnf -y install --nodocs gcc make redhat-rpm-config openssl ruby-devel-2.7.6 gcc-c++ libtool libffi-devel bzip2 \
2628
# Install Fluentd, it's dependencies along with other run time dependencies for OCI Logging Analytics Solution
2729
&& bundle config silence_root_warning true \
2830
&& bundle config --local path /fluentd/vendor/bundle \
@@ -31,20 +33,43 @@ RUN dnf -y module enable ruby:2.7 \
3133
&& curl -L -o /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini" \
3234
&& curl -L -o /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini.asc" \
3335
&& export GNUPGHOME="$(mktemp -d)" \
34-
&& gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
36+
&& gpg --batch --keyserver keyserver.ubuntu.com \
37+
--recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
3538
&& gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
3639
&& chmod +x /usr/local/bin/tini \
3740
# Install jemalloc
38-
&& curl -L -o /tmp/jemalloc-4.5.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/4.5.0/jemalloc-4.5.0.tar.bz2 \
39-
&& cd /tmp && tar -xjf jemalloc-4.5.0.tar.bz2 && cd jemalloc-4.5.0/ \
41+
&& curl -L -o /tmp/jemalloc-5.3.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 \
42+
&& cd /tmp && tar -xjf jemalloc-5.3.0.tar.bz2 && cd jemalloc-5.3.0/ \
4043
&& ./configure && make \
41-
&& mv lib/libjemalloc.so.2 /usr/lib \
42-
# Install hostname, required by fluent-plugin-rewrite-tag-filter
43-
&& dnf -y install hostname \
44-
# Remove all the development dependent packages
45-
&& dnf -y remove gcc make redhat-rpm-config openssl ruby-devel gcc-c++ libtool libffi-devel bzip2 \
44+
&& mv lib/libjemalloc.so.2 /usr/lib
45+
46+
## To build the final docker image
47+
48+
FROM container-registry.oracle.com/os/oraclelinux:8
49+
50+
USER root
51+
WORKDIR /fluentd
52+
53+
# Environment variables
54+
ENV PATH /fluentd/vendor/bundle/ruby/2.7.0/bin:$PATH
55+
ENV GEM_PATH /fluentd/vendor/bundle/ruby/2.7.0:$GEM_PATH
56+
ENV GEM_HOME /fluentd/vendor/bundle/ruby/2.7.0
57+
# skip runtime bundler installation
58+
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
59+
60+
# Install ruby 2.7 along with rubygems and bundler.
61+
RUN dnf -y module enable ruby:2.7 \
62+
&& dnf -y install --setopt=install_weak_deps=False --nodocs ruby-2.7.6 ruby-libs-2.7.6 gdbm-libs \
63+
&& dnf -y install --setopt=install_weak_deps=False --nodocs rubygems-3.1.6 \
64+
&& gem install bundler -v 2.3.25 \
65+
# clear cache
4666
&& dnf clean all \
4767
&& rm -rf /var/cache/dnf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
68+
69+
# Copy binaries (tini & jemallco) and rubygems bundler environment from build stage
70+
COPY --from=builder /fluentd /fluentd
71+
COPY --from=builder /usr/local/bin/tini /usr/bin/tini
72+
COPY --from=builder /usr/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.2
4873

4974
RUN mkdir -p /fluentd/etc /fluentd/plugins \
5075
&& touch /fluentd/etc/disable.conf

logan/docker-images/v1.0/oraclelinux/8/Gemfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
source "https://rubygems.org"
55

6-
gem "oj", "3.10.18"
7-
gem "json", "2.4.1"
6+
gem "oj", "3.14.1"
7+
gem "json", "2.6.3"
88
gem "ext_monitor", "0.1.2"
9-
gem "fluentd", "1.14.3"
10-
gem "fluent-plugin-oci-logging-analytics", "2.0.3"
9+
gem "fluentd", "1.15.3"
10+
gem "fluent-plugin-oci-logging-analytics", "2.0.5"
1111
gem "fluent-plugin-concat", "~> 2.5.0"
1212
gem "fluent-plugin-rewrite-tag-filter", "~> 2.4.0"
1313
gem "fluent-plugin-parser-cri", "~> 0.1.1"
14-
gem "fluent-plugin-kubernetes_metadata_filter", "2.9.5"
15-
gem "fluent-plugin-kubernetes-objects", "1.1.12"
14+
gem "fluent-plugin-kubernetes_metadata_filter", "2.13.0"
15+
gem "fluent-plugin-kubernetes-objects", "1.2.1"

0 commit comments

Comments
 (0)