# Use Debian Bookworm as base image
FROM debian:bookworm

# Install apache2 and PHP and PHP modules
RUN apt update && \
    apt install -y apache2 php8.2 php8.2-mysqli php8.2-gd php8.2-zip php8.2-dom php8.2-mbstring && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*

# Enable PHP in Apache2
RUN a2enmod php8.2 

# Enable Apache2 mod_rewrite
RUN a2enmod rewrite

# Install Composer
RUN apt update && \
    apt install -y curl php8.2-cli unzip && \
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*

# Change PHP.ini memory limit to 1024MB
RUN sed -i 's/memory_limit = .*/memory_limit = 1024M/' /etc/php/8.2/apache2/php.ini

# Composer install
WORKDIR /var/www/html
COPY composer.json composer.lock ./
RUN composer install --no-interaction



# Start Apache in the foreground
CMD ["apachectl", "-D", "FOREGROUND"]
