###############################################################################
# docker/php/Dockerfile
# Image PHP 8.3-FPM partagée par tous les 13 services Laravel
# Extensions : pdo_pgsql, redis, gd, mbstring, xml, curl, zip, pcntl, bcmath, intl
###############################################################################

FROM php:8.3-fpm-alpine

# ── Dépendances système ───────────────────────────────────────────────────────
RUN apk add --no-cache \
    git \
    curl \
    zip \
    unzip \
    libpng-dev \
    libxml2-dev \
    postgresql-dev \
    icu-dev \
    oniguruma-dev \
    linux-headers \
    $PHPIZE_DEPS

# ── Extensions PHP ────────────────────────────────────────────────────────────
RUN docker-php-ext-install \
    pdo \
    pdo_pgsql \
    mbstring \
    xml \
    curl \
    zip \
    pcntl \
    bcmath \
    intl \
    gd \
    opcache

# ── Redis (via PECL) ──────────────────────────────────────────────────────────
RUN pecl install redis && docker-php-ext-enable redis

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

# ── Configuration PHP pour la production ─────────────────────────────────────
COPY php.ini /usr/local/etc/php/conf.d/workspace.ini

# ── Répertoire de travail ─────────────────────────────────────────────────────
WORKDIR /var/www

# ── Droits ───────────────────────────────────────────────────────────────────
RUN chown -R www-data:www-data /var/www

EXPOSE 9000
CMD ["php-fpm"]
