# fluentd/Dockerfile

FROM fluent/fluentd:v1.17.0-debian-amd64-1.0
USER root
RUN apt-get update && \
    apt-get install -y python3 python3-pip
    
# The virtual env of python3 is used to allow the installation of tensorflow
RUN apt install -y python3-venv   
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install packages within the virtual environment
RUN apt-get install -y iproute2
RUN pip install tensorflow scikit-learn numpy joblib

# In case of necessity fluend is installed and for secureness fluentd is updated
RUN gem install fluent-plugin-elasticsearch --no-document --version 5.0.3
RUN gem update fluentd


ENV DEBIAN_FRONTEND=noninteractive

# Preconfigure tzdata with the desired timezone
RUN ln -fs /usr/share/zoneinfo/Europe/Madrid /etc/localtime && \
    echo "Europe/Madrid" > /etc/timezone && \
    apt-get update && \
    apt-get install -y tzdata && \
    dpkg-reconfigure --frontend noninteractive tzdata
    
RUN apt-get install -y systemctl cron
RUN echo "00 00 * * * /bin/bash /shared-volume/prediction/livePrediction/liveLogfileCreator.sh" | crontab -


COPY entrypoints/ep_fluentd.sh entrypoints/ep_fluentd.sh
RUN chmod +x entrypoints/ep_fluentd.sh
