FROM paheko/paheko:1.3.11

#ENV PAHEKO_DIR /usr/share/paheko
ENV PAHEKO_DIR /var/www/paheko

COPY dockers/paheko/config/factory_cron.sh ${PAHEKO_DIR}/
COPY dockers/paheko/config/factory_cron_emails.sh ${PAHEKO_DIR}/
COPY dockers/paheko/config/setupWebRights.sh ${PAHEKO_DIR}/
RUN mkdir ${PAHEKO_DIR}/users

#Plugin facturation (le seul qui ne fasse pas parti de la distribution de base
COPY "dockers/paheko/config/facturation.tar.gz" ${PAHEKO_DIR}/data/plugins/
RUN mkdir ${PAHEKO_DIR}/data/plugins/facturation && tar zxvf ${PAHEKO_DIR}/data/plugins/facturation.tar.gz -C ${PAHEKO_DIR}/data/plugins/facturation && rm ${PAHEKO_DIR}/data/plugins/facturation.tar.gz

#install cron pour factory_cron.sh
RUN apt-get update && apt-get install cron joe rsyslog -y
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
RUN echo "0 1 * * * cd ${PAHEKO_DIR} && ${PAHEKO_DIR}/factory_cron.sh" >> /var/spool/cron/crontabs/root
RUN echo "* * * * *  cd ${PAHEKO_DIR} && ${PAHEKO_DIR}/factory_cron_emails.sh" >> /var/spool/cron/crontabs/root
RUN chmod 600 /var/spool/cron/crontabs/root
RUN sed -i "/exec/i\service cron start\n" /usr/local/bin/docker-php-entrypoint
RUN ln -sf /usr/local/bin/php /usr/bin/

#outil pour debugger dans le docker
RUN apt-get install -y inetutils-ping net-tools

# Set owner web server
RUN chown -R www-data: ${PAHEKO_DIR}

#fab le 03/02/2023: pour avoir un php.ini de prod avec zend.assertions = -1
RUN cp "/usr/local/etc/php/php.ini-production" "/usr/local/etc/php/php.ini"

HEALTHCHECK --timeout=10s CMD exit 0
EXPOSE 80
VOLUME [ "${PAHEKO_DIR}/users" ]