Repository navigation
Expand file tree
/
Copy pathDockerfile.template.erb
More file actions
129 lines (115 loc) · 5.36 KB
/
Copy pathDockerfile.template.erb
File metadata and controls
129 lines (115 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<% fluentd_ver = version.split("-").first[1..-1] %>
<% fluentd_tag = version.dup; fluentd_tag.slice!('-onbuild') %>
<% is_onbuild = (version.include?("onbuild")) %>
<% is_debian = (dockerfile.split("/").last.split("-").first == "debian") %>
<% is_armhf = (dockerfile.split("/")[1] == "armhf") %>
<% is_arm64 = (dockerfile.split("/")[1] == "arm64") %>
<% is_windows = (dockerfile.split("/").last.split("-").first == "windows") %>
<% windows_ver = dockerfile.split("/").last.split("-").last %>
# AUTOMATICALLY GENERATED
# DO NOT EDIT THIS FILE DIRECTLY, USE /Dockerfile.template.erb
<% if is_windows %>
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-<%= windows_ver %>
<% else %>
<% if is_armhf %>
FROM --platform=linux/arm/v7 arm32v7/ruby:3.4-slim
<% elsif is_arm64 %>
FROM --platform=linux/arm64 arm64v8/ruby:3.4-slim
<% else %>
FROM ruby:3.4-slim
<% end %>
<% end %>
LABEL maintainer "Fluentd developers <cncf-fluentd-maintainers@lists.cncf.io>"
LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version="<%= fluentd_ver %>"
# Do not split this into multiple RUN!
# Docker creates a layer for every RUN-Statement
<% if is_windows %>
RUN powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"
RUN choco install -y ruby --version 3.4.9.1 --params "'/InstallDir:C:\ruby34'" \
&& choco install -y msys2 --version 20260611.0.0 --params "'/NoPath /NoUpdate /InstallDir:C:\ruby34\msys64'"
RUN refreshenv \
&& ridk install 3 \
&& type "c:\ProgramData\gemrc" \
&& c:\ruby34\bin\ruby -r yaml -e "path = 'c:/ProgramData/gemrc'; yaml = YAML.safe_load(File.read(path)); yaml['install'] = '--no-document'; yaml['update'] = '--no-document'; File.write(path, YAML.dump(yaml))" \
&& type "c:\ProgramData\gemrc" \
&& gem install oj -v 3.17.3 \
&& gem install json -v 2.19.9 \
&& gem install rexml -v 3.4.4 \
&& gem install fluentd -v <%= fluentd_ver %> \
&& gem install win32-service -v 2.3.2 \
&& gem install win32-ipc -v 0.7.0 \
&& gem install win32-event -v 0.6.3 \
&& gem sources --clear-all
# Remove gem cache and chocolatey
RUN powershell -Command "Remove-Item -Force C:\ruby34\lib\ruby\gems\3.4.0\cache\*.gem; Remove-Item -Recurse -Force 'C:\ProgramData\chocolatey'"
COPY fluent.conf /fluent/conf/fluent.conf
<% else %>
# therefore an 'apt-get purge' has no effect
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates tini \
&& buildDeps=" \
make gcc g++ libc-dev \
wget bzip2 gnupg dirmngr \
" \
&& apt-get install -y --no-install-recommends $buildDeps \
&& echo 'gem: --no-document' >> /etc/gemrc \
&& export MAKEFLAGS=-j$(nproc) \
&& gem install oj -v 3.17.3 \
&& gem install json -v 2.19.9 \
&& gem install rexml -v 3.4.4 \
&& gem install async -v 2.24.0 \
&& gem install async-http -v 0.89.0 \
&& gem install fluentd -v <%= fluentd_ver %> \
&& unset MAKEFLAGS \
&& export GEM_DIR=$(ruby -e 'puts Gem.dir') \
&& echo GEM_DIR=$GEM_DIR \
&& rm -rf $GEM_DIR/cache/*.gem \
# Don't purge $GEM_DIR/gems/GEM/lib/GEM/ext because it might contain runtime .so (e.g json)
&& find $GEM_DIR -maxdepth 3 -type d -name test -or -name ext -or -name spec -or -name benchmark | xargs -r rm -rfv \
&& find $GEM_DIR -name "*.so" | xargs -r strip \
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /tmp/jemalloc-5.4.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/5.4.0/jemalloc-5.4.0.tar.bz2 \
&& cd /tmp && tar -xjf jemalloc-5.4.0.tar.bz2 --no-same-owner && cd jemalloc-5.4.0/ \
# Don't use MADV_FREE to reduce memory usage and improve stability
# https://github.com/fluent/fluentd-docker-image/pull/350
&& (echo "je_cv_madv_free=no" > config.cache) && ./configure -C --with-lg-page=16 --disable-cxx --disable-static && make -j$(nproc) \
&& mv lib/libjemalloc.so.2 /usr/lib \
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$buildDeps \
'*-dev' \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* /var/tmp/*
RUN groupadd -r fluent && useradd -r -g fluent fluent \
# for log storage (maybe shared with host)
&& mkdir -p /fluentd/log \
# configuration/plugins path (default: copied from .)
&& mkdir -p /fluentd/etc /fluentd/plugins \
&& chown -R fluent /fluentd && chgrp -R fluent /fluentd
COPY fluent.conf /fluentd/etc/
COPY entrypoint.sh /bin/
<% end %>
<% if is_onbuild %>
ONBUILD COPY fluent.conf /fluentd/etc/
ONBUILD COPY plugins /fluentd/plugins/
<% end %>
ENV FLUENTD_CONF="fluent.conf"
<% if not is_windows %>
ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2"
<% if is_armhf %>
# Don't set thp:never because jemalloc has no THP support on 32-bit ARM,
# and abort_conf:true makes every process abort with it.
ENV MALLOC_CONF="dirty_decay_ms:400,muzzy_decay_ms:0,narenas:2,background_thread:true,abort_conf:true"
<% else %>
ENV MALLOC_CONF="dirty_decay_ms:400,muzzy_decay_ms:0,narenas:2,background_thread:true,thp:never,abort_conf:true"
<% end %>
<% end %>
EXPOSE 24224 5140
<% if is_windows %>
ENTRYPOINT ["cmd", "/k", "fluentd", "--config", "C:\\fluent\\conf\\fluent.conf"]
<% else %>
USER fluent
ENTRYPOINT ["tini", "--", "/bin/entrypoint.sh"]
CMD ["fluentd"]
<% end %>