FROM php:8.3-fpm-bookworm

# Dépendances système
RUN apt-get update && apt-get install -y --no-install-recommends \
        git unzip libicu-dev libzip-dev libpng-dev libjpeg-dev libfreetype6-dev \
        libwebp-dev libonig-dev default-mysql-client \
    && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
    && docker-php-ext-install -j"$(nproc)" \
        intl pdo_mysql mysqli zip gd opcache exif \
    && pecl install redis apcu \
    && docker-php-ext-enable redis apcu \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

# Aligne www-data sur l'uid/gid hôte (1000) : php-fpm peut lire les fichiers
# bind-montés (dont .env.local en 600) sans élargir les permissions côté hôte.
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data

# Config PHP
COPY php.ini /usr/local/etc/php/conf.d/salam.ini

WORKDIR /var/www/html

# Node.js 20 (pour Webpack Encore en dev)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && apt-get clean && rm -rf /var/lib/apt/lists/*
