FROM php:8.2-fpm

ARG BUILD_NUMBER
ENV BUILD_NUMBER=${BUILD_NUMBER}

# Install packages
RUN apt-get update && apt-get install -y \
    git \
    zip \
    curl \
    sudo \
    unzip \
    libssl-dev \
    libzip-dev \
    libicu-dev \
    libbz2-dev \
    libpng-dev \
    libjpeg-dev \
    mariadb-client \
    libmcrypt-dev \
    libreadline-dev \
    libfreetype6-dev \
    g++

RUN docker-php-ext-configure ftp --with-openssl-dir=/usr

# Common PHP Extensions
RUN docker-php-ext-install \
    gd \
    bz2 \
    ftp \
    zip \
    intl \
    iconv \
    bcmath \
    opcache \
    calendar \
    pdo_mysql

RUN pecl install redis && docker-php-ext-enable redis
RUN apt-get update && apt-get install -y libmagickwand-dev && pecl install imagick && docker-php-ext-enable imagick

# Ensure PHP logs are captured by the container
ENV LOG_CHANNEL=stderr

COPY .docker/sail/8.2/php.ini /usr/local/etc/php/conf.d/docker-php-env.ini

# Set a volume mount point for your code
VOLUME /var/www/html

COPY . /var/www/tmp

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WORKDIR /var/www/tmp
RUN composer install --no-dev

RUN php artisan event:cache
