FROM ubuntu:latest


###################################################### Update APT #######################################################
RUN apt-get update -y

###################################################### Utilities #######################################################

#install which (required by Maven), wget, curl and unzip
RUN apt-get install -y git curl wget unzip nano && \
apt-get -y clean all

######################################################### Apache #########################################################

RUN apt-get install -y apache2 && \
apt-get -y clean all

######################################################### PHP #########################################################

RUN apt-get install -y php-mysql php-curl php-json php-cgi  php libapache2-mod-php && \
apt-get -y clean all

######################################################### Apache Configs #########################################################
## Enabling Mod_Rewrite
RUN a2enmod rewrite
RUN a2enmod headers
RUN a2enmod expires
RUN a2enmod deflate

## Fixing localhost error.
RUN echo "ServerName localhost" >> /etc/apache2/conf-available/servername.conf
RUN a2enconf servername

RUN echo "<VirtualHost *:80> \n\
        ServerAdmin webmaster@localhost \n\
        DocumentRoot /var/www/html \n\
 \n\
        ErrorLog ${APACHE_LOG_DIR}/error.log \n\
        CustomLog ${APACHE_LOG_DIR}/access.log combined \n\
 \n\
        <Directory /var/www/html> \n\
                Options Indexes FollowSymLinks MultiViews \n\
                AllowOverride All \n\
                Order allow,deny \n\
                allow from all \n\
        </Directory> \n\
</VirtualHost>" >> /etc/apache2/sites-enabled/000-default.conf

#################################################### Autograder JAR ####################################################

ADD start.sh /start.sh
RUN chmod +x /start.sh

EXPOSE 80

ENTRYPOINT ["/start.sh"]