forked from fluent/fluentd-docker-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template.erb
193 lines (178 loc) · 6.18 KB
/
Dockerfile.template.erb
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<% fluentd_ver = version.split("-").first[1..-1] %>
<% is_onbuild = (version.split("-").last == "onbuild") %>
<% is_alpine = (dockerfile.split("/").last.split("-").first == "alpine") %>
<% is_armhf = (dockerfile.split("/")[1] == "armhf") %>
<% is_windows = (dockerfile.split("/").last.split("-").first == "windows") %>
# AUTOMATICALLY GENERATED
# DO NOT EDIT THIS FILE DIRECTLY, USE /Dockerfile.template.erb
<% if is_windows %>
FROM microsoft/windowsservercore:1803
<% else %>
<% if is_alpine %>
<% if is_armhf %>
FROM resin/armhf-alpine:3.7
<% else %>
FROM alpine:3.7
<% end %>
<% else %>
<% if is_armhf %>
FROM resin/armv7hf-debian:stretch
<% else %>
FROM debian:stretch-slim
<% end %>
<% end %>
<% end %>
LABEL maintainer "TAGOMORI Satoshi <tagomoris@gmail.com>"
LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version="1.1"
<% if is_armhf %>
ARG CROSS_BUILD_START="cross-build-start"
ARG CROSS_BUILD_END="cross-build-end"
RUN [ ${CROSS_BUILD_START} ]
<% end %>
<% if is_alpine %>
ENV DUMB_INIT_VERSION=1.2.0
ENV SU_EXEC_VERSION=0.2
<% else %>
<% if is_armhf %>
ENV DUMB_INIT_VERSION=1.2.0-1
ENV GOSU_VERSION=1.10-1+b2
<% else %>
<% if not is_windows %>
ENV DUMB_INIT_VERSION=1.2.1
ENV GOSU_VERSION=1.10
<% end %>
<% end %>
<% end %>
<% if not is_windows %>
ARG DEBIAN_FRONTEND=noninteractive
<% end %>
# 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; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
# Fluentd depends on cool.io which is only available for Ruby < 2.5, so need to install Ruby < 2.5 and install msys2 to get dev tools
RUN choco install -y ruby --version 2.4.2.2 --params "'/InstallDir:C:\'" \
&& choco install -y msys2 --params "'/NoPath /NoUpdate /InstallDir:C:\ruby24\msys64'" \
&& refreshenv \
&& ridk install 2 3 \
&& echo gem: --no-document >> C:\ProgramData\gemrc \
&& gem install cool.io -v 1.5.3 \
<% if fluentd_ver.start_with?('1') %>
&& gem install oj -v 3.3.10 \
<% else %>
&& gem install oj -v 2.18.3 \
<% end %>
&& gem install json -v 2.1.0 \
&& gem install fluentd -v <%= fluentd_ver %> \
&& gem install win32-service -v 1.0.1 \
&& gem install win32-ipc -v 0.7.0 \
&& gem install win32-event -v 0.6.3 \
&& gem install windows-pr -v 1.2.6 \
&& gem sources --clear-all
# Remove gem cache and chocolatey
RUN powershell -Command "del C:\ruby24\lib\ruby\gems\2.4.0\cache\*.gem; Remove-Item -Recurse -Force C:\ProgramData\chocolatey"
COPY fluent.conf /fluent/conf/fluent.conf
<% else %>
<% if is_alpine %>
# therefore an 'apk delete' has no effect
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
ca-certificates \
ruby ruby-irb \
su-exec==${SU_EXEC_VERSION}-r0 \
dumb-init==${DUMB_INIT_VERSION}-r0 \
&& apk add --no-cache --virtual .build-deps \
build-base \
ruby-dev wget gnupg \
<% else %>
# therefore an 'apt-get purge' has no effect
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
ca-certificates \
ruby \
<% if is_armhf %>
dumb-init=${DUMB_INIT_VERSION} \
gosu=${GOSU_VERSION} \
<% end %>
&& buildDeps=" \
make gcc g++ libc-dev \
ruby-dev \
wget bzip2 gnupg dirmngr \
" \
&& apt-get install -y --no-install-recommends $buildDeps \
<% end %>
&& update-ca-certificates \
&& echo 'gem: --no-document' >> /etc/gemrc \
<% if fluentd_ver.start_with?('1') %>
&& gem install oj -v 3.3.10 \
<% else %>
&& gem install oj -v 2.18.3 \
<% end %>
&& gem install json -v 2.1.0 \
&& gem install fluentd -v <%= fluentd_ver %> \
<% if is_alpine %>
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* \
<% else %>
<% if not is_armhf %>
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_$dpkgArch \
&& chmod +x /usr/bin/dumb-init \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
<% end %>
&& gosu nobody true \
<% if fluentd_ver.start_with?('1') %>
&& wget -O /tmp/jemalloc-4.5.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/4.5.0/jemalloc-4.5.0.tar.bz2 \
&& cd /tmp && tar -xjf jemalloc-4.5.0.tar.bz2 && cd jemalloc-4.5.0/ \
<% else %>
&& wget -O /tmp/jemalloc-4.4.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/4.4.0/jemalloc-4.4.0.tar.bz2 \
&& cd /tmp && tar -xjf jemalloc-4.4.0.tar.bz2 && cd jemalloc-4.4.0/ \
<% end %>
&& ./configure && make \
&& mv lib/libjemalloc.so.2 /usr/lib \
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$buildDeps \
&& rm -rf /var/lib/apt/lists/* \
<% end %>
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
# for log storage (maybe shared with host)
RUN mkdir -p /fluentd/log
# configuration/plugins path (default: copied from .)
RUN mkdir -p /fluentd/etc /fluentd/plugins
COPY fluent.conf /fluentd/etc/
COPY entrypoint.sh /bin/
RUN chmod +x /bin/entrypoint.sh
<% end %>
<% if is_onbuild %>
ONBUILD COPY fluent.conf /fluentd/etc/
ONBUILD COPY plugins /fluentd/plugins/
<% end %>
ENV FLUENTD_OPT=""
ENV FLUENTD_CONF="fluent.conf"
<% if not is_windows %>
<% if is_alpine %>
ENV LD_PRELOAD=""
<% else %>
ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2"
<% end %>
ENV DUMB_INIT_SETSID 0
<% end %>
EXPOSE 24224 5140
<% if is_windows %>
ENTRYPOINT ["cmd", "/k", "fluentd", "-c", "C:\\fluent\\conf\\fluent.conf"]
<% else %>
ENTRYPOINT ["/bin/entrypoint.sh"]
CMD exec fluentd -c /fluentd/etc/${FLUENTD_CONF} -p /fluentd/plugins $FLUENTD_OPT
<% if is_armhf %>
RUN [ ${CROSS_BUILD_END} ]
<% end %>
<% end %>