FROM php:8.2-apache

RUN set -eux; \
    apt-get update; \
    apt-get install -y --no-install-recommends \
      libzip-dev unzip libpng-dev libjpeg-dev libfreetype6-dev; \
    docker-php-ext-configure gd --with-freetype --with-jpeg; \
    docker-php-ext-install \
      pdo pdo_mysql mbstring zip gd; \
    rm -rf /var/lib/apt/lists/*

RUN a2enmod rewrite

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

COPY . /var/www/html

RUN set -eux; \
    chown -R www-data:www-data /var/www/html; \
    chmod -R 755 /var/www/html

WORKDIR /var/www/html

RUN set -eux; composer install --no-interaction --prefer-dist --optimize-autoloader

EXPOSE 80
