FROM php:8.3-fpm

RUN apt-get update && apt-get install -y \
       libmcrypt-dev \
       libicu-dev \
       libpng-dev \
       libjpeg62-turbo-dev \
       libwebp-dev \
       libfreetype6-dev \
       libxrender1 \
       libfontconfig \
       libxext-dev \
       libzip-dev \
       libldap-dev \
       libmemcached-dev \
       libgmp-dev \
       git \
  && apt-get install -y libmagickwand-dev --no-install-recommends \
  && rm -rf /var/lib/apt/lists/* \
  && docker-php-ext-configure gd --with-freetype --with-jpeg  --with-webp \
  && docker-php-ext-install -j$(nproc) gd bcmath opcache mysqli zip ldap intl exif pdo pdo_mysql gmp \
  && printf "\n" | pecl install imagick \
  && docker-php-ext-enable imagick \
  && git clone https://github.com/phpredis/phpredis /tmp/redis \
  && docker-php-ext-configure /tmp/redis \
  && docker-php-ext-install /tmp/redis \
  && rm -rf /tmp/redis \
  && pecl install apcu \
  && docker-php-ext-enable apcu \
  && pecl install uploadprogress \
  && docker-php-ext-enable uploadprogress \
  && pecl clear-cache 

RUN cd /tmp \
  && 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

USER www-data
WORKDIR /var/www/html