FROM ubuntu:16.04

# Author
MAINTAINER Dominik Visek <visekdo@gmail.com>

# update installed packages
RUN apt-get update
RUN apt-get -y upgrade

# Install apache,curt,lynx-cur
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
        apache2=2.4.18-2ubuntu3.8 curl=7.47.0-1ubuntu2.7 lynx-cur=2.8.9dev8-4ubuntu1

#packages for add-apt-repository
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-software-properties
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python3-software-properties

#set repository
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt-get update

#install php7.2
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
        php7.2 php7.2-mysql php7.2-intl php7.2-soap php7.2-bz2 php7.2-curl php7.2-gd php7.2-imap php7.2-xml php7.2-zip

RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
        php7.2-mbstring php7.2-sqlite

# Manually set up the apache environment variables
ENV APACHE_RUN_USER site-data
ENV APACHE_RUN_GROUP site-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

# Expose apache.
EXPOSE 80

# Update the default apache site with the config we created.
COPY apache-config.conf /etc/apache2/sites-enabled/000-default.conf
COPY php.ini /etc/php/7.2/apache2/php.ini

# Enable apache mods.
RUN a2enmod php7.2
RUN a2enmod rewrite
RUN a2enmod vhost_alias

RUN service apache2 restart

# By default start up apache in the foreground, override with /bin/bash for interative.
CMD /usr/sbin/apache2ctl -D FOREGROUND
