FROM php:7.4-fpm-alpine

# Install dev dependencies
RUN apk add --no-cache --virtual .build-deps \
    $PHPIZE_DEPS \
    curl-dev \
    libtool \
    postgresql-dev

# Install production dependencies
RUN apk add --no-cache \
    bash \
    curl \
    g++ \
    gcc \
    libc-dev \
    make \
    openssh-client \
    postgresql-libs \
    nodejs \
    nodejs-npm

RUN npm i -g pm2

# Install PECL and PEAR extensions
RUN pecl install \
    xdebug

# Install and enable php extensions
RUN docker-php-ext-enable \
    xdebug

RUN docker-php-ext-install \
    pdo_pgsql \
    bcmath

# Install composer
ENV COMPOSER_HOME /composer
ENV PATH ./vendor/bin:/composer/vendor/bin:$PATH
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

# Cleanup dev dependencies
RUN apk del -f .build-deps

#CRON legacy
COPY cron /home/cron
RUN chmod 0744 /home/cron
RUN crontab /home/cron
RUN touch /var/log/cron.log

# Command
ADD cmd.sh /home/cmd.sh
RUN chmod +x /home/cmd.sh

# Setup working directory
WORKDIR /var/www

EXPOSE 9000
CMD ["/home/cmd.sh"]
