############################################################################################################
# This Dockerfile will NOT be substituted before deployment!
############################################################################################################

############################################################################################################
# Init Default PHP Image
############################################################################################################
FROM bugfishtm/sf-base:latest

############################################################################################################
# Update all packages
############################################################################################################
RUN apt update -y && apt upgrade -y

############################################################################################################
# Update The Timezone
############################################################################################################
ENV TZ=${sf_timezone}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo "$TZ" > /etc/timezone

############################################################################################################
# Apache Copy Configuration (Optional, if changed)
############################################################################################################
COPY vhost/ /etc/apache2/conf-available/
RUN a2enconf docker-php

############################################################################################################
# Apache Copy Website Content
############################################################################################################
COPY source/ /var/www/html/

############################################################################################################
# Install Supervisor Scripts (optional, if changed)
############################################################################################################
RUN rm -rf /etc/supervisor/conf.d/suitefish_cron.conf
COPY ./script/suitefish_apache2.conf /etc/supervisor/conf.d/suitefish_apache2.conf
RUN rm -rf /etc/supervisor/conf.d/suitefish_mysql.conf
RUN rm -rf  /etc/supervisor/conf.d/suitefish_suitefish.conf
COPY ./script/suitefish_php_fpm.conf /etc/supervisor/conf.d/suitefish_php_fpm.conf

############################################################################################################
# Copy Entrypoint Script
############################################################################################################
COPY ./script/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh 

############################################################################################################
# Cleanup Image
############################################################################################################
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

############################################################################################################
# Add Entrypoint
############################################################################################################
ENTRYPOINT ["/entrypoint.sh"]

############################################################################################################
# Startup Instructions
############################################################################################################
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf", "--silent"]