FROM php:8.2-apache

# Install required libraries and dependencies
RUN apt-get update && apt-get install -y \
    libicu-dev \
    libonig-dev \
    libzip-dev \
    unzip \
    libc-client-dev \
    libkrb5-dev \
    && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
    && docker-php-ext-install \
    intl \
    mbstring \
    zip \
    imap \
    mysqli \
    pdo_mysql \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Enable Apache rewrite module
RUN a2enmod rewrite

# Copy application files
COPY . /var/www/html

# Set permissions for application files
RUN chown -R www-data:www-data /var/www/html && \
    chmod -R 775 /var/www/html/var /var/www/html/config /var/www/html/public

# Expose port 80
EXPOSE 80

# Start Apache
CMD ["apache2-foreground"]