FROM registry.chiefsoft.net/php-fpm:7.4

RUN apt -y update
#RUN apt-cache search gsoap
#RUN find / | grep 'php'
#RUN apt -y install libjson-c4

#RUN apt-cache search libjson
RUN apt -y install libconfig++-dev libconfig++9v5 libconfig-dev libconfig9 libpq-dev libpq5 libjson-c-dev libjson-c5 \
 libpcrecpp0v5 unixodbc-dev postgresql-server-dev-13 libgsoap-dev libgsoap-2.8.104

RUN apt -y install rapidjson-dev libboost-all-dev

# RUN apt -y install libconfig++-dev libconfig++9v5 libconfig-dev libconfig9 libpq-dev libpq5 libjson-c-dev libjson-c4 \
# libpcrecpp0v5 unixodbc-dev postgresql-server-dev-12 libgsoap-dev libgsoap-2.8.91

# DEBUG
RUN apt -y install gdb strace vim postgresql-client-13

ARG CACHEBUST=1

ADD wrenchboard/scripts/* /usr/local/bin/
ADD wrenchboard/configs/* /cfgs/

RUN rm -rf /opt/mainsite/wrenchboard
RUN mkdir -p /opt/mainsite/wrenchboard
COPY www/ /opt/mainsite/wrenchboard/www
COPY www-api/ /opt/mainsite/wrenchboard/www-api
ADD wrenchboard/build/* /opt/mainsite/wrenchboard/build/
COPY wrenchboard/email/ /opt/mainsite/wrenchboard/email
ADD wrenchboard/etc/* /opt/mainsite/wrenchboard/etc/
COPY wrenchboard/src/ /opt/mainsite/wrenchboard/src

RUN cd /opt/mainsite/wrenchboard/src && make clean

RUN cd /opt/mainsite/wrenchboard/build && ./configure

RUN cd /opt/mainsite/wrenchboard/src && make

#RUN ls -l /usr/local/lib/php/extensions/no-debug-non-zts-20190902
RUN ln -s /opt/mainsite/wrenchboard/src/modules/wrenchboard_api_root.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/wrenchboard_api_root.so

RUN touch /opt/mainsite/wrenchboard/logs/wrenchboard_api_root.log
RUN chmod a+w /opt/mainsite/wrenchboard/logs/wrenchboard_api_root.log

RUN echo "extension=wrenchboard_api_root.so" > /usr/local/etc/php/conf.d/docker-php-ext-wrenchboard.ini
