# Use an official PHP image with Apache
FROM php:8.2-apache

# Set the working directory to /var/www/html
WORKDIR /var/www/html

# Copy the composer.json file to the container
COPY ./composer.json .

# Install required packages: zip, unzip, git
RUN apt-get update && apt-get install -y \
    zip \
    unzip \
    git \
    && docker-php-ext-install mysqli pdo pdo_mysql \
    && docker-php-ext-enable mysqli pdo_mysql

# Install Composer
COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer

# Run composer install
RUN composer install

# Ensure the Apache service runs in the foreground (this is the default)
CMD ["apache2-foreground"]

# Expose port 80 to the outside world
EXPOSE 80
