FROM php:8.1-fpm
RUN apt-get update && apt-get install -y \
    vim \
    wget \
    curl \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libzip-dev \
    libxml2-dev \
    libssl-dev \
    libonig-dev \
    libcurl4-openssl-dev \
    libmcrypt-dev \
    libreadline-dev \
    libxslt1-dev \
    libicu-dev \
    libmemcached-dev \
    zlib1g-dev \
    ca-certificates \
    apt-transport-https \
    software-properties-common \
     libffi-dev

RUN docker-php-ext-install \
    mysqli \
    pdo_mysql \
    bcmath \
    calendar \
    exif \
    gettext \
    shmop \
    soap \
    sockets \
    sysvmsg \
    sysvsem \
    sysvshm \
    xsl \
    opcache \
    zip

# Configure and install GD
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

# Install PECL extensions
RUN printf "yes\n" | pecl install igbinary redis xdebug \
    && docker-php-ext-enable igbinary redis xdebug

# Install and enable intl extension
RUN docker-php-ext-configure intl \
    && docker-php-ext-install intl

# Install FFI
RUN docker-php-ext-install ffi

# Enable some built-in extensions
# RUN docker-php-ext-enable opcache

# Create session directory
RUN mkdir -p /var/cpanel/php/sessions/ea-php83 \
    && chmod 777 /var/cpanel/php/sessions/ea-php83

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

