FROM php:7.4-fpm

# Installation des dépendances et extensions PHP nécessaires
RUN apt-get update && apt-get install -y \
  libpng-dev \
  libjpeg-dev \
  libfreetype6-dev \
  zip \
  unzip \
  && docker-php-ext-configure gd --with-freetype --with-jpeg \
  && docker-php-ext-install pdo pdo_mysql gd

# Installation de Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WORKDIR /var/www

# Copie des fichiers du projet
COPY . .

COPY nginx.conf /etc/nginx/nginx.conf

# Installation des dépendances du projet
RUN composer install

# Ajustement des permissions
RUN chown -R www-data:www-data /var/www/ \
  && chmod -R 775 /var/www/storage /var/www/bootstrap/cache