FROM ubuntu:16.04
MAINTAINER rocho02@gmail.com

# apt-get
RUN apt-get update \
    && apt-get -y install bzip2 git nano wget zip unzip curl vim  \
    && apt-get -y install libmcrypt-dev libzzip-dev zziplib-bin zlib1g-dev  \
    && apt-get -y install apache2
#    && ufw allow in "Apache Full"  \

RUN apt-get -y install php \
                    libapache2-mod-php \
                    php-mcrypt \
                    php-mysql \
                    php-xml \
                    php7.0-gd \
                    php7.0-mbstring

RUN apt-get -y install php-xdebug php-soap php-curl

RUN apt-get -y install \
            # Required by composer
            git \
            zlib1g-dev \
        --no-install-recommends

# Install composer
COPY install-composer /install-composer
RUN /install-composer && rm /install-composer

RUN mkdir -p /var/www/html/api && mkdir -p /var/www/html/admin && mkdir -p /var/www/html/public

WORKDIR /var/www

RUN a2enmod headers
RUN a2enmod rewrite

COPY 000-default.conf /etc/apache2/sites-available/

COPY index.html /var/www/html/

# Ports
EXPOSE 80

RUN  FILE=/etc/php/7.0/apache2/php.ini                         \
    && echo "\n" >> $FILE  \
    && echo "\n# Added for xdebug" >> $FILE  \
    && echo "\nzend_extension=\"/usr/lib/php/20151012/xdebug.so\"  " >> $FILE  \
    && echo "\nxdebug.remote_enable=1 " >> $FILE  \
    && echo "\nxdebug.remote_handler=dbgp  " >> $FILE  \
    && echo "\nxdebug.remote_mode=req " >> $FILE  \
    && echo "\nxdebug.remote_host=172.17.0.1 " >> $FILE  \
    && echo "\nxdebug.remote_port=9000   " >> $FILE  \
    && echo "\nxdebug.remote_connect_back=1 " >> $FILE  \
    && echo "\n" >> $FILE


ENV XDEBUG_CONFIG="idekey=PHPSTORM"

# Default command
CMD ["apachectl", "-D", "FOREGROUND"]

