FROM splunk/splunk:latest
env DEBIAN_FRONTEND=noninteractive

####################
# COOMMON PART.
####################
# for systems with apt
# RUN apt update && \
#    apt install -y python3-jinja2 python3-dotenv
# for systems without apt but with pip
RUN sudo python -m pip install --upgrade pip && \
    sudo pip install python-dotenv && sudo pip install Jinja2

# Python3 as default
# RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1

# Copy parser and environment to root
COPY fill_templates.py /
USER root
# COPY .env /

########################
# CUSTOM PART
########################

# Put tpl-files where they will be parsed
COPY *.conf* $SPLUNK_HOME/etc/system/local/

WORKDIR /
ENTRYPOINT ["/fill_templates.py"]                   # MUST be JSON-array syntax

# Place here original ENTRYPOINT and update it when in mother Dockerfile it will be updated\changed
CMD /sbin/entrypoint.sh start-service