This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
forked from fluent/fluentd-docker-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template.erb
176 lines (163 loc) · 5.72 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
<% fluentd_ver = version.split("-").first[1..-1] %>
<% fluentd_tag = version.dup; fluentd_tag.slice!('-onbuild') %>
<% is_onbuild = (version.include?("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.8
<% end %>
<% else %>
<% if is_armhf %>
FROM resin/armv7hf-debian:stretch
<% else %>
FROM debian:stretch-slim
<% end %>
<% end %>
<% end %>
LABEL maintainer "Fluentd developers <[email protected]>"
LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version="<%= fluentd_ver %>"
<% if is_armhf %>
ARG CROSS_BUILD_START="cross-build-start"
ARG CROSS_BUILD_END="cross-build-end"
RUN [ ${CROSS_BUILD_START} ]
<% end %>
<% if not is_alpine %>
<% if is_armhf %>
ENV TINI_VERSION=0.18.0
<% else %>
<% if not is_windows %>
ENV TINI_VERSION=0.18.0
<% end %>
<% end %>
<% 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 add --no-cache \
ca-certificates \
ruby ruby-irb ruby-etc ruby-webrick \
tini \
&& apk add --no-cache --virtual .build-deps \
build-base \
ruby-dev gnupg \
<% else %>
# therefore an 'apt-get purge' has no effect
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
ruby \
&& buildDeps=" \
make gcc g++ libc-dev \
ruby-dev \
wget bzip2 gnupg dirmngr \
" \
&& apt-get install -y --no-install-recommends $buildDeps \
<% end %>
&& 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 %>
&& gem install bigdecimal -v 1.3.5 \
&& apk del .build-deps \
<% else %>
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch" \
&& wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-$dpkgArch.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
&& gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
&& rm -r /usr/local/bin/tini.asc \
&& chmod +x /usr/local/bin/tini \
&& tini -h \
<% 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
<% if is_alpine %>
RUN addgroup -S fluent && adduser -S -g fluent fluent
<% else %>
RUN groupadd -r fluent && useradd -r -g fluent fluent
<% end %>
RUN 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 %>
<% if is_alpine %>
ENV LD_PRELOAD=""
<% else %>
ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2"
<% end %>
<% end %>
EXPOSE 24224 5140
<% if is_windows %>
ENTRYPOINT ["cmd", "/k", "fluentd", "-c", "C:\\fluent\\conf\\fluent.conf"]
<% else %>
USER fluent
ENTRYPOINT ["tini", "--", "/bin/entrypoint.sh"]
CMD ["fluentd"]
<% if is_armhf %>
RUN [ ${CROSS_BUILD_END} ]
<% end %>
<% end %>