FROM php:8.3-apache

# Extensions PHP nécessaires
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
        libicu-dev \
 && docker-php-ext-install -j$(nproc) pdo_mysql intl opcache \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

# Active mod_rewrite (pour le routing index.php) + headers (CORS)
RUN a2enmod rewrite headers

# Pointe Apache vers /public
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \
        /etc/apache2/sites-available/*.conf \
        /etc/apache2/apache2.conf \
        /etc/apache2/conf-available/*.conf

# Config PHP minimale en prod
RUN { \
        echo 'opcache.enable=1'; \
        echo 'opcache.memory_consumption=128'; \
        echo 'opcache.validate_timestamps=0'; \
        echo 'display_errors=Off'; \
        echo 'log_errors=On'; \
        echo 'error_log=/dev/stderr'; \
        echo 'expose_php=Off'; \
    } > /usr/local/etc/php/conf.d/donut.ini

EXPOSE 80
