# Use PHP 7.4.32 with Apache
FROM php:7.4.32-apache

# Install required PHP extensions
RUN apt-get update && apt-get install -y \
    libpng-dev libonig-dev libxml2-dev zip unzip git curl libgmp-dev \
    && docker-php-ext-install mysqli pdo_mysql mbstring gd bcmath gmp

# Enable Apache mod_rewrite
RUN a2enmod rewrite

# Change Apache listening port to 8080 to avoid host conflicts
RUN sed -i 's/80/8080/g' /etc/apache2/ports.conf /etc/apache2/sites-available/000-default.conf

# Set working directory
WORKDIR /var/www/html

# Copy application files
COPY . .

# Set permissions for Apache
RUN chown -R www-data:www-data /var/www/html \
    && chmod -R 755 /var/www/html

# Expose Apache port
EXPOSE 8080

# Start Apache in foreground
CMD ["apache2-foreground"]
