FROM php:8.5-apache

# Enable Apache rewrite module
RUN a2enmod rewrite

# Install system dependencies, PHP extensions, and clean up apt cache
RUN apt-get update && apt-get install -y \
    unzip \
    libzip-dev \
    libicu-dev \
    git \
 && docker-php-ext-install \
    bcmath \
    mysqli \
    pdo_mysql \
    zip \
    intl \
 && pecl install redis \
 && docker-php-ext-enable redis \
 && rm -rf /var/lib/apt/lists/*

# Update Apache DocumentRoot to /var/www/wkvs/html/ and enable .htaccess overrides
ENV APACHE_DOCUMENT_ROOT=/var/www/wkvs/html/

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
 && sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
 && sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf