FROM php:8.3-fpm-alpine

# Install system deps
RUN apk add --no-cache \
    bash \
    git \
    icu-dev \
    libzip-dev \
    libxml2-dev \
    oniguruma-dev \
    g++ \
    make \
    nodejs \
    npm

# Install PHP extensions
RUN docker-php-ext-configure intl \
    && docker-php-ext-install -j$(nproc) intl pdo pdo_mysql opcache zip \
    && docker-php-ext-install dom xml simplexml xmlreader xmlwriter \
    && docker-php-ext-install -j$(nproc) tokenizer ctype iconv mbstring

# Install composer
ENV COMPOSER_ALLOW_SUPERUSER=1 \
    COMPOSER_HOME=/tmp/composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

# Configure PHP
COPY docker/php/php.ini $PHP_INI_DIR/conf.d/zz-custom.ini

WORKDIR /var/www/html

# Default command
CMD ["php-fpm"]
