FROM php:8.2-apache

# Instalar dependencias para GD
RUN apt-get update && apt-get install -y \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libwebp-dev \
    libzip-dev \
    && rm -rf /var/lib/apt/lists/*

# Configurar y instalar extensiones PHP
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
    && docker-php-ext-install -j$(nproc) gd mysqli pdo pdo_mysql zip

# Instalar extension Redis
RUN pecl install redis && docker-php-ext-enable redis

# short_open_tag
RUN echo "short_open_tag = On" > /usr/local/etc/php/conf.d/short-tags.ini

# Modulos Apache
RUN a2enmod rewrite headers deflate expires

# AllowOverride All para .htaccess
RUN sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf && \
    sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/Options Indexes FollowSymLinks/Options Indexes FollowSymLinks/' /etc/apache2/apache2.conf

# ServerName
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf

# Cliente MariaDB para importar SQL
RUN apt-get update && apt-get install -y mariadb-client && rm -rf /var/lib/apt/lists/*

WORKDIR /var/www/html
EXPOSE 80
