FROM php:7.3-apache
WORKDIR /var/www
ENV TZ=Europe/Warsaw
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get -y update
RUN apt-get install -y gnupg
RUN apt-get install -y git nano mc libssl-dev libgd-dev libxml2-dev memcached htop zlib1g-dev curl

# gd extension
RUN rm -rf /var/lib/apt/lists/* && apt-get update && apt-get install -y \
  libpng-dev \
  libfreetype6-dev \
  libjpeg-dev \
  libxpm-dev \
  libxml2-dev \
  libxslt-dev \
  libmcrypt-dev \
  librabbitmq-dev \
  libssh-dev \
  libwebp-dev \
  libzip-dev \
  libpq-dev \
  libssh-dev

RUN docker-php-ext-configure gd \
    --with-freetype-dir=/usr/include/ \
    --with-jpeg-dir=/usr/include/ \
    --with-xpm-dir=/usr/include \
    --with-webp-dir=/usr/include/ # php >=7.0 (use libvpx for php <7.0)

RUN docker-php-ext-install gd

###profiling###
# install mcrypt for xhgui
RUN pecl install mcrypt-1.0.2
RUN docker-php-ext-enable mcrypt

# install pkg-config for pecl
RUN apt-get install -y pkg-config

# install Tideways profiler extension
RUN git clone https://github.com/tideways/php-profiler-extension.git
RUN cd php-profiler-extension && phpize && ./configure && make && make install
RUN docker-php-ext-enable tideways_xhprof
###end profiling###

# install mongodb extension for xhgui
RUN pecl install mongodb
RUN docker-php-ext-enable mongodb
# install xhgui
RUN git clone https://github.com/perftools/xhgui.git
# configure xhgui symply adding config file to container
RUN cd xhgui && php install.php
#enable mongodb ext

#redis
RUN pecl install -o -f redis \
&&  rm -rf /tmp/pear \
&&  docker-php-ext-enable redis

#composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/bin/composer

#php exts
RUN docker-php-ext-install pdo pdo_mysql mbstring bcmath xml zip

COPY vhost.conf /etc/apache2/sites-enabled/000-default.conf
RUN a2enmod rewrite

#memcached
RUN apt-get install -y libmemcached-dev && pecl install memcached && docker-php-ext-enable memcached


#npm
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y nodejs \
&& npm i -g nodemon \
&& npm install -g npm

#gulp
COPY package*.json ./
RUN npm install
RUN npm rebuild node-sass
RUN npm link gulp

#apcu
RUN pecl install apcu \
&& docker-php-ext-enable apcu

#opcache
RUN docker-php-ext-install opcache

RUN service apache2 restart
RUN usermod -u 1000 www-data

