FROM centos:8

ARG user_var="root"

#SHELL ["/bin/bash", "-c"]


RUN yum -y update
RUN yum -y update tzdata
#RUN yum -y install bash-completion bash-completion-extras
RUN yum -y install bash-completion


########## needed for PHP
#RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#RUN yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

#RUN yum-config-manager --enable remi-php74


RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
RUN dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

RUN dnf -y module reset php
RUN dnf -y module install php:remi-8.0


RUN dnf -y install yum-utils





# Install php (cli/fpm)
RUN yum -y install \
    	git \
        php \
        php-cli \
        php-fpm \
        php-json \
        php-intl \
        php-curl \
        php-dom \
        php-mbstring \
        php-bcmath \
    	php-yaml \
        python3 \
        python3-pandas \
        python3-xlsxwriter \
        python3-netaddr \
        python3-requests \
    && yum clean all


### PAN-OS-PHP
WORKDIR /tools/pan-os-php

COPY appid-toolbox ./appid-toolbox
COPY lib ./lib
COPY phpseclib ./phpseclib
COPY git-php ./git-php
COPY utils ./utils
COPY tests ./tests
COPY iron-skillet ./iron-skillet
COPY migration ./migration


# PHP library of pan-os-php
RUN echo 'include_path = "/usr/share/php:/tools/pan-os-php"' >> /etc/php.ini
RUN chmod -R 777 /tools/pan-os-php


# UTIL alias for pan-os-php
RUN cat /tools/pan-os-php/utils/alias.sh >> /$user_var/.bashrc
RUN cat /tools/pan-os-php/utils/bash_autocompletion/enable_bash.txt >> /$user_var/.bashrc

#COPY utils/bash_autocompletion/pan-os-php.sh /usr/share/bash-completion/completions/pan-os-php
RUN ln -s /tools/pan-os-php/utils/bash_autocompletion/pan-os-php.sh /usr/share/bash-completion/completions/pan-os-php

RUN git config --global user.email=test@test.com user.name=test

#for BASH 5.0
RUN yum -y install curl
RUN yum -y groupinstall "Development Tools"
RUN curl -O https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz
RUN tar xvf bash-5.0.tar.gz
RUN cd bash-5.0 && ./configure && make && make install

#NOT working for CENTOS Docker Container
#RUN dnf -y install util-linux-user
#RUN echo '/usr/local/bin/bash' >> /etc/shells
#RUN chsh -s /usr/local/bin/bash

RUN yes | cp /usr/local/bin/bash /bin/bash

# Entrypoint script
WORKDIR /scripts
COPY docker/entrypoint.sh .

# Working dir for the app
VOLUME /share
WORKDIR /share

ENTRYPOINT [ "/bin/bash", "/scripts/entrypoint.sh" ]
