diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d74ac77 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +FROM debian + +#Run in non-interactive mode +ENV DEBIAN_FRONTEND="noninteractive" HOME="/" + +#Install dependencies +RUN apt update +RUN apt install -y apache2 php7.0 php7.0-mysql php7.0-gd php7.0-mbstring mysql-server git uglifyjs + +#Add shorcuts +RUN echo 'eval "mysqld_safe&"; sleep 10;' > /root/start_mysql.sh + +#Configure servers +RUN a2enmod rewrite +RUN sh /root/start_mysql.sh; mysqladmin -u root password root; mysql -e "CREATE DATABASE comunic"; exit +RUN sh /root/start_mysql.sh; mysql -e "CREATE USER 'comunic'@'localhost'; GRANT ALL PRIVILEGES ON comunic.* To 'comunic'@'localhost' IDENTIFIED BY 'comunic';"; exit +RUN rm /etc/apache2/sites-enabled/000-default.conf +COPY apache2.conf /etc/apache2/sites-enabled + +#Retrieve Comunic API +RUN mkdir /data/ +RUN git clone https://github.com/pierre42100/ComunicAPI /data/api + +#Import database +RUN sh /root/start_mysql.sh; mysql comunic < /data/api/db_struct.sql; exit + +#Create API client +RUN sh /root/start_mysql.sh; /data/api/bin/add_client client token; exit + +#Update API config +COPY overwriteAPIconfig.php /data/api/config/ + +#Initialize user data directory +COPY empty_user_data_dir.tar.gz /root/ +RUN mkdir /data/user_data/ +RUN tar -xf /root/empty_user_data_dir.tar.gz -C /data/user_data +RUN chmod a+rwxX /data/user_data -R + +#Retrieve Comunic Web APP +RUN git clone https://github.com/pierre42100/ComunicWeb /root/webapp + +#Build webapp +RUN /root/webapp/builder build docker +RUN mv /root/webapp/output/* /data; mv /root/webapp/output/.htaccess /data/ + + +#Copy start script +COPY start.sh /root/start +RUN chmod +x /root/start +CMD /root/start diff --git a/apache2.conf b/apache2.conf new file mode 100644 index 0000000..9bfe848 --- /dev/null +++ b/apache2.conf @@ -0,0 +1,12 @@ + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + + + ServerAdmin webmaster@localhost + DocumentRoot /data/ + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + \ No newline at end of file diff --git a/empty_user_data_dir.tar.gz b/empty_user_data_dir.tar.gz new file mode 100644 index 0000000..7895582 Binary files /dev/null and b/empty_user_data_dir.tar.gz differ diff --git a/overwriteAPIconfig.php b/overwriteAPIconfig.php new file mode 100644 index 0000000..10fa76a --- /dev/null +++ b/overwriteAPIconfig.php @@ -0,0 +1,13 @@ +set("mysql", array( + "host" => "localhost", + "database" => "comunic", + "user" => "comunic", + "password" => "comunic" +)); + +//Storage configuration +$config->set("storage_path", "/data/user_data/"); +$config->set("storage_url", "http://".$_SERVER["HTTP_HOST"]."/user_data/"); \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..a48fee3 --- /dev/null +++ b/start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +#Start Mysql Server +mysqld_safe& + +#Start Apache Server +apache2ctl -DFOREGROUND -k start