FROM openshift/base-ruby:v4.6.0.20220824.174056 AS builder
ENV __doozer=update BUILD_RELEASE=202208241715.p0.gcd23942.assembly.stream BUILD_VERSION=v4.6.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=6 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.6.0-202208241715.p0.gcd23942.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=cd23942 OS_GIT_VERSION=4.6.0-202208241715.p0.gcd23942.assembly.stream-cd23942 SOURCE_DATE_EPOCH=1654026750 SOURCE_GIT_COMMIT=cd239423b4918c5739fc6762b177d30f9b32f8a7 SOURCE_GIT_TAG=v3.11.0-alpha.0-1026-gcd239423 SOURCE_GIT_URL=https://github.com/openshift/origin-aggregated-logging 

MAINTAINER OpenShift Development <dev@lists.openshift.redhat.com>

ARG DATA_VERSION_VALUE=1.6.0
ARG FLUENTD_VERSION_VALUE=1.7.4
ARG HOME_VALUE=/opt/app-root/src
ARG PATH_VALUE=/opt/app-root/src/bin:/opt/app-root/bin
ARG LOGGING_FILE_PATH_VALUE=/var/log/fluentd/fluentd.log
ARG LOGGING_FILE_AGE_VALUE=10
ARG LOGGING_FILE_SIZE_VALUE=1024000
ARG CONTAINER_VALUE=oci

ENV DATA_VERSION=$DATA_VERSION_VALUE \
    FLUENTD_VERSION=$FLUENTD_VERSION_VALUE \
    HOME=$HOME_VALUE \
    PATH=$PATH_VALUE:$PATH \
    LOGGING_FILE_PATH=$LOGGING_FILE_PATH_VALUE \
    LOGGING_FILE_AGE=$LOGGING_FILE_AGE_VALUE \
    LOGGING_FILE_SIZE=$LOGGING_FILE_SIZE_VALUE \
    container=$CONTAINER_VALUE

ARG TEST_REPO
#ADD test.repo /etc/yum.repos.d

USER 0

RUN BUILD_PKGS="make gcc-c++ libffi-devel \
              autoconf automake libtool m4 \
              redhat-rpm-config" && \
  RUNTIME_PKGS="hostname \
                bc \
                iproute" && \
  yum install -y --setopt=tsflags=nodocs $BUILD_PKGS $RUNTIME_PKGS && \
  rpm -V $BUILD_PKGS && \
  rpm -V $RUNTIME_PKGS && \
  yum clean all

# uncomment if you want to try out test rpm builds
#ADD *.rpm /tmp/
#RUN yum -y install /tmp/*.rpm

ADD jemalloc/ ${HOME}/jemalloc/
RUN cd ${HOME}/jemalloc && EXTRA_CFLAGS="$( rpm --eval '%{optflags}' )" ./autogen.sh && \
    make install_lib_shared install_bin && cp COPYING ${HOME}/COPYING.jemalloc && \
    cd .. && rm -rf jemalloc

ADD source.jemalloc /source.jemalloc
RUN bash -c '. /source.jemalloc; echo jemalloc $JEMALLOC_VER >> /contents'

ADD vendored_gem_src/ ${HOME}/vendored_gem_src/
ADD lib/fluent-plugin-remote_syslog/ ${HOME}/vendored_gem_src/fluent-plugin-remote_syslog/
ADD lib/remote_syslog_sender/        ${HOME}/vendored_gem_src/remote_syslog_sender/
ADD lib/syslog_protocol/             ${HOME}/vendored_gem_src/syslog_protocol/
ADD install-gems.sh *.patch.sh *.patch ${HOME}/vendored_gem_src/

RUN cd ${HOME}/vendored_gem_src/ && ./install-gems.sh && cd / && rm -rf ${HOME}/vendored_gem_src/

RUN BUILD_PKGS="make gcc-c++ libffi-devel \
                autoconf automake libtool m4 \
                redhat-rpm-config" && \
    yum remove -y $BUILD_PKGS

RUN mkdir -p /etc/fluent/plugin
ADD configs.d/ /etc/fluent/configs.d/
ADD out_syslog_buffered.rb out_syslog.rb out_rawtcp.rb /etc/fluent/plugin/
ADD run.sh generate_syslog_config.rb wait_for_es_version.rb wait_for_es_version.sh ${HOME}/
ADD lib/generate_throttle_configs/lib/*.rb ${HOME}/
ADD lib/filter_parse_json_field/lib/*.rb /etc/fluent/plugin/
ADD lib/filter_elasticsearch_genid_ext/lib/filter_elasticsearch_genid_ext.rb /etc/fluent/plugin/
ADD lib/parser_viaq_host_audit/lib/*.rb /etc/fluent/plugin/
ADD lib/fluent-plugin-viaq_data_model/lib/fluent/plugin/*.rb /etc/fluent/plugin/
COPY utils/ /usr/local/bin/

RUN mkdir -p /etc/fluent/configs.d/{dynamic,user} && \
    chmod 777 /etc/fluent/configs.d/dynamic && \
    ln -s /etc/fluent/configs.d/user/fluent.conf /etc/fluent/fluent.conf

WORKDIR ${HOME}
CMD ["sh", "run.sh"]

LABEL \
        License="GPLv2+" \
        io.k8s.description="Fluentd container for collecting of container logs" \
        io.k8s.display-name="Fluentd" \
        io.openshift.tags="logging,elk,fluentd" \
        vendor="Red Hat" \
        name="openshift/ose-logging-fluentd" \
        com.redhat.component="logging-fluentd-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Logging" \
        release="202208241715.p0.gcd23942.assembly.stream" \
        io.openshift.build.commit.id="cd239423b4918c5739fc6762b177d30f9b32f8a7" \
        io.openshift.build.source-location="https://github.com/openshift/origin-aggregated-logging" \
        io.openshift.build.commit.url="https://github.com/openshift/origin-aggregated-logging/commit/cd239423b4918c5739fc6762b177d30f9b32f8a7" \
        version="v4.6.0"

