-
Notifications
You must be signed in to change notification settings - Fork 102
/
Dockerfile
130 lines (111 loc) · 3.84 KB
/
Dockerfile
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
# Copyright © 2023 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: BSD-2-Clause
# Similar to https://github.com/drecom/docker-centos-ruby/blob/2.6.5-slim/Dockerfile
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
WORKDIR /go/src/github.com/vmware/kube-fluentd-operator/config-reloader
COPY config-reloader .
COPY Makefile .
# Speed up local builds where vendor is populated
ARG VERSION
RUN make build VERSION=$VERSION TARGETARCH=$TARGETARCH TARGETOS=$TARGETOS
FROM --platform=${TARGETPLATFORM:-linux/amd64} photon:4.0
ARG RVM_PATH=/usr/local/rvm
ARG RUBY_VERSION=ruby-3.1.4
ARG RUBY_PATH=/usr/local/rvm/rubies/$RUBY_VERSION
ARG RUBYOPT='-W:no-deprecated -W:no-experimental'
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
ENV PATH $RUBY_PATH/bin:$PATH
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
ENV BUILDDEPS="\
gmp-devel \
libffi-devel \
bzip2 \
shadow \
which \
wget \
vim \
git \
less \
tar \
gzip \
sed \
gcc \
build-essential \
zlib-devel \
libedit \
libedit-devel \
gdbm \
gdbm-devel \
openssl-devel \
gpg"
RUN tdnf clean all && \
tdnf upgrade -y && \
tdnf erase -y toybox && \
tdnf install -y \
findutils \
procps-ng \
util-linux \
systemd \
net-tools && \
tdnf clean all
SHELL [ "/bin/bash", "-l", "-c" ]
COPY image/failsafe.conf image/entrypoint.sh image/Gemfile image/Gemfile.lock /fluentd/
# Install the gems with bundler is better practice
# We need to keep this as a single layer because of the builddeps
# if we split between multiple steps, we need up with the lots of extra files between layers
RUN tdnf install -y $BUILDDEPS \
&& curl -sSL https://rvm.io/mpapis.asc | gpg --import \
&& curl -sSL https://rvm.io/pkuczynski.asc | gpg --import \
&& curl -sSL https://get.rvm.io | bash -s stable \
&& source /etc/profile.d/rvm.sh \
&& rvm autolibs disable \
&& rvm requirements \
&& rvm install --disable-binary $RUBY_VERSION --default \
&& gem update --system --no-document \
&& gem install bundler -v '>= 2.4.15' --default --no-document \
&& rm -rf $RVM_PATH/src $RVM_PATH/examples $RVM_PATH/docs $RVM_PATH/archives \
$RUBY_PATH/lib/ruby/gems/3.*/cache $RUBY_PATH/lib/ruby/gems/3.*/doc/ \
/usr/share/doc /root/.bundle/cache \
&& rvm cleanup all \
&& gem sources --clear-all \
&& gem cleanup \
&& tdnf remove -y $BUILDDEPS \
&& tdnf clean all
RUN tdnf install -y $BUILDDEPS \
&& mkdir -p /fluentd/log /fluentd/etc /fluentd/plugins /usr/local/bundle/bin/ \
&& echo 'gem: --no-document' >> /etc/gemrc \
&& bundle config silence_root_warning true \
&& cd /fluentd \
&& bundle install \
&& cd /fluentd \
&& gem specific_install https://github.com/javiercri/fluent-plugin-google-cloud.git \
&& cd /fluentd \
&& gem sources --clear-all \
&& ln -s $(which fluentd) /usr/local/bundle/bin/fluentd \
&& gem cleanup \
## Install jemalloc
&& curl -sLo /tmp/jemalloc-5.3.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 \
&& tar -C /tmp/ -xjvf /tmp/jemalloc-5.3.0.tar.bz2 \
&& cd /tmp/jemalloc-5.3.0 \
&& ./configure && make \
&& mv -v lib/libjemalloc.so* /usr/lib \
&& rm -rf /tmp/* \
# cleanup build deps
&& tdnf remove -y $BUILDDEPS \
&& tdnf clean all
COPY image/plugins /fluentd/plugins
COPY config-reloader/templates /templates
COPY config-reloader/validate-from-dir.sh /bin/validate-from-dir.sh
COPY --from=builder /go/src/github.com/vmware/kube-fluentd-operator/config-reloader/config-reloader /bin/config-reloader
# Make sure fluentd picks jemalloc 5.3.0 lib as default
ENV LD_PRELOAD="/usr/lib/libjemalloc.so"
EXPOSE 24444 5140
USER root
ENTRYPOINT ["/fluentd/entrypoint.sh"]