33# ###########################################################################################################
44FROM php:8.4-apache
55
6- # #####################################################
7- # Update APT Library
8- # #####################################################
6+ # ###########################################################################################################
7+ # Update APT Library and Upgrade System
8+ # ###########################################################################################################
99RUN apt update -y
10-
11- # #####################################################
12- # Upgrade System
13- # #####################################################
1410RUN apt upgrade -y
1511
16- # #####################################################
12+ # ###########################################################################################################
1713# Install Dependencies
18- # #####################################################
14+ # ###########################################################################################################
1915RUN apt install apache2 -y
2016RUN apt install curl -y
2117RUN apt install cron -y
@@ -25,14 +21,13 @@ RUN apt install libpng-dev -y
2521RUN apt install zlib1g-dev -y
2622RUN apt install libcurl4-openssl-dev -y
2723RUN apt install openssl -y
28- RUN apt install openssl -y
2924RUN apt install libicu-dev -y
3025RUN apt install libxml2-dev -y
3126RUN apt install libzip-dev -y
3227
33- # #####################################################
28+ # ###########################################################################################################
3429# Install PHP Extensions
35- # #####################################################
30+ # ###########################################################################################################
3631RUN docker-php-ext-install mysqli
3732RUN docker-php-ext-install curl
3833RUN docker-php-ext-install bcmath
@@ -45,9 +40,9 @@ RUN docker-php-ext-install zip
4540RUN docker-php-ext-install ctype
4641RUN docker-php-ext-install filter
4742
48- # #####################################################
43+ # ###########################################################################################################
4944# Set Timezone
50- # #####################################################
45+ # ###########################################################################################################
5146ENV TZ=${sf_timezone}
5247RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo "$TZ" > /etc/timezone
5348
@@ -82,29 +77,51 @@ COPY _source/ /var/www/html/
8277# Generate Default Apache2 Certificate (Self Signed)
8378# #####################################################
8479RUN mkdir -p /opt/sf_ssl
85- RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
86- -keyout /opt/sf_ssl/privkey.pem \
87- -out /opt/sf_ssl/cert.pem \
88- -subj "/C=US/ST=State/L=City/O=Organization/OU=OrgUnit/CN=example.com"
8980
9081# ###########################################################################################################
9182# Install MySQL
9283# ###########################################################################################################
9384ENV DEBIAN_FRONTEND=noninteractive
9485RUN apt install mariadb-client -y
9586RUN apt install mariadb-server -y
96- ENV MYSQL_ROOT_PASSWORD=${sf_db_pass}
97- ENV MYSQL_DATABASE=${sf_db_name}
9887RUN echo "[mysqld]\n \
9988skip-networking=0\n \
10089bind-address=0.0.0.0" > /etc/mysql/mariadb.conf.d/99-custom.cnf
10190
91+ # ###########################################################################################################
92+ # Setup Website Cronjob Hourly with Root Access
93+ # ###########################################################################################################
94+ RUN echo "0 * * * * /usr/local/bin/php /var/www/html/cronjob.php 2>&1" >> /etc/cron.d/my-cron-jobs
95+
96+ # ###########################################################################################################
97+ # Install Supervisor
98+ # ###########################################################################################################
99+ RUN apt-get install -y supervisor
100+ COPY ./_script/suitefish_cron.conf /etc/supervisor/conf.d/suitefish_cron.conf
101+ COPY ./_script/suitefish_apache2.conf /etc/supervisor/conf.d/suitefish_apache2.conf
102+ COPY ./_script/suitefish_mysql.conf /etc/supervisor/conf.d/suitefish_mysql.conf
103+ COPY ./_script/suitefish_suitefish.conf /etc/supervisor/conf.d/suitefish_suitefish.conf
104+
105+ # ###########################################################################################################
106+ # Copy Entrypoint Script
107+ # ###########################################################################################################
108+ COPY ./_script/entrypoint.sh /entrypoint.sh
109+ RUN chmod +x /entrypoint.sh
110+ COPY ./_script/restart_mysql.sh /restart_mysql.sh
111+ RUN chmod +x /restart_mysql.sh
112+
113+ # ###########################################################################################################
114+ # Cleanup Image
115+ # ###########################################################################################################
116+ RUN apt-get clean
117+ RUN rm -rf /var/lib/apt/lists/*
118+
119+ # ###########################################################################################################
120+ # Add Entrypoint
121+ # ###########################################################################################################
122+ ENTRYPOINT ["/entrypoint.sh" ]
123+
102124# ###########################################################################################################
103125# Startup Instructions
104126# ###########################################################################################################
105- CMD service mariadb start && \
106- chmod 0770 /var/www -R && \
107- chown www-data:www-data /var/www -R && \
108- mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('${sf_db_pass}');" && \
109- mysql -u root -p${sf_db_pass} -e "CREATE DATABASE IF NOT EXISTS ${sf_db_name};" && \
110- apachectl -D FOREGROUND
127+ CMD ["/usr/bin/supervisord" , "-n" , "-c" , "/etc/supervisor/supervisord.conf" , "--silent" ]
0 commit comments