FROM php:7.3-fpm

ARG XDEBUG_REMOTE_HOST="172.17.0.1"

RUN apt-get update && \
    apt-get install -y --no-install-recommends git zip libzip-dev wget libcurl4-openssl-dev

RUN docker-php-ext-install zip curl

# XDebug
RUN pecl install xdebug-2.9.0 && docker-php-ext-enable xdebug
RUN echo "xdebug.remote_enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
    echo "xdebug.remote_host = ${XDEBUG_REMOTE_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini;

# Redis
RUN pecl install -o -f redis && docker-php-ext-enable redis

# Cleanup
RUN rm -rf /tmp/pear

# Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && mv composer.phar /usr/local/bin/composer \
    && chmod +x /usr/local/bin/composer

# Box
RUN wget https://github.com/humbug/box/releases/download/3.8.4/box.phar \
    && mv box.phar /usr/local/bin/box \
    && chmod +x /usr/local/bin/box

# Timezone
RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime
RUN echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini;

WORKDIR /var/www

EXPOSE 9001
