1+ ############ escape=`
2+
3+ ARG WIN_TAG=ltsc2019
4+
5+ FROM mcr.microsoft.com/windows/servercore:$WIN_TAG as ruby-base
6+ LABEL maintainer "Fluentd developers <
[email protected] >"
7+ LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version="1.13.1"
8+
9+
10+ # Do not split this into multiple RUN!
11+ # Docker creates a layer for every RUN-Statement
12+ RUN powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
13+
14+ # Fluentd depends on cool.io whose fat gem is only available for Ruby < 2.5, so need to specify --platform ruby when install Ruby > 2.5 and install msys2 to get dev tools
15+ # NOTE: For avoiding stalling with docker build on windows, we must use latest version of msys2.
16+ RUN choco install -y ruby --version=2.7.2.1 --params "'/InstallDir:C:\ruby27'" \
17+ && MD C:\Users\ContainerUser\.gem \
18+ && MD C:\fluentd \
19+ && refreshenv \
20+ && echo gem: --user-install --no-document >> c:/Users/ContainerUser/.gemrc \
21+ && gem update --system
22+
23+ USER ContainerAdministrator
24+ RUN setx /m PATH "C:\Users\ContainerUser\.gem\bin;%PATH%" \
25+ && setx /m GEM_HOME c:/Users/ContainerUser/.gem
26+ USER ContainerUser
27+
28+
29+
30+ FROM ruby-base as ruby-build
31+
32+ USER ContainerAdministrator
33+ RUN choco install -y msys2 --version 20210604.0.0 --params "'/NoPath /NoUpdate /InstallDir:C:\msys64'" \
34+ && setx /m PATH "C:\msys64\usr\bin;%PATH%" \
35+ && setx /m MSYS winsymlinks:nativestrict \
36+ && ridk install 3 \
37+ && mklink /J C:\msys64\fluentd C:\fluentd
38+ USER ContainerUser
39+
40+ SHELL ["bash", "-lc"]
41+ RUN "echo 'PATH=$PATH:/mingw64/bin:/c/ruby27/bin:/c/users/containeruser/.gem/ruby/2.7.0/bin' >> /etc/profile.d/000-mingw64.sh \
42+ && pacman -Suu --noconfirm && pacman -S --needed --noconfirm git \
43+ "
44+
45+ # RUN "pacman -Suu --noconfirm && pacman -S --needed --noconfirm git"
46+
47+ COPY basegems/Gemfile /fluentd/Gemfile.basegems
48+ COPY basegems/Gemfile.lock /fluentd/Gemfile.basegems.lock
49+
50+ COPY Gemfile /fluentd/Gemfile
51+ COPY Gemfile.lock /fluentd/Gemfile.lock
52+
53+ RUN "\
54+ gem install bundler:'>= 2.2.27' rexml:'>= 3.2.5' rdoc:'>= 6.3.2' json:'>= 2.5.1' webrick:'>= 1.7.0' bigdecimal \
55+ && cd /fluentd \
56+ && bundler config --global jobs 4 \
57+ && bundler config set --global without \"development test\" \
58+ && bundler config set --global cache_all 'false' \
59+ && bundler install --no-cache --gemfile=Gemfile.basegems \
60+ && bundler install --no-cache --gemfile=Gemfile \
61+ && git clone https://github.com/Cryptophobia/fluent-plugin-google-cloud.git fluent-plugin-google-cloud \
62+ && gem build -C fluent-plugin-google-cloud fluent-plugin-google-cloud.gemspec \
63+ && gem install --no-document fluent-plugin-google-cloud/fluent-plugin-google-cloud-*.gem \
64+ && git clone https://github.com/Cryptophobia/fluent-plugin-loggly.git fluent-plugin-loggly \
65+ && gem build -C fluent-plugin-loggly fluent-plugin-loggly.gemspec \
66+ && gem install fluent-plugin-loggly/fluent-plugin-loggly-*.gem \
67+ && rm -rf $GEM_HOME/cache/* $GEM_HOME/doc/* \
68+ "
69+ # RUN "cd /fluentd && bundle config list && du -h --max-depth 1 $GEM_HOME"
70+
71+ FROM ruby-base as ruby-runtime
72+ COPY --from=ruby-build /Users/ContainerUser/.gem /Users/ContainerUser/.gem
73+ COPY plugins /etc/fluent-plugin
74+
75+ USER ContainerAdministrator
76+ RUN tzutil /s UTC \
77+ && (if not exist C:\etc\fluent-conf (MD C:\etc\fluent-conf)) \
78+ && (if not exist C:\etc\fluent-plugin (MD C:\etc\fluent-plugin)) \
79+ && (if not exist C:\var\run\secrets\kubernetes.io\serviceaccount (MD C:\var\run\secrets\kubernetes.io\serviceaccount)) \
80+ && (if not exist C:\var\log (MD C:\var\log)) \
81+ && (if not exist C:\var\lib\kubelet (MD C:\var\lib\kubelet))
82+ USER ContainerUser
83+ RUN powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/fluent/fluentd-kubernetes-daemonset/master/docker-image/v1.13/debian-elasticsearch7/plugins/parser_kubernetes.rb -OutFile C:\etc\fluent-plugin\parser_kubernetes.rb \
84+ ; Invoke-WebRequest https://raw.githubusercontent.com/fluent/fluentd-kubernetes-daemonset/master/docker-image/v1.13/debian-elasticsearch7/plugins/parser_multiline_kubernetes.rb -OutFile C:\etc\fluent-plugin\parser_multiline_kubernetes.rb \
85+ "
86+
87+ COPY failsafe.conf /etc/fluent-conf/failsafe.conf
88+ COPY entrypoint.ps1 /entrypoint.ps1
89+ ENTRYPOINT ["powershell", "/entrypoint.ps1"]
0 commit comments