FROM php:8.1-fpm

RUN apt-get update && apt-get install -y \
    libpng-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libzip-dev \
    unzip \
    libcurl4-openssl-dev \
    libonig-dev \
    imagemagick  \
    libmagickwand-dev \
    && pecl install imagick \
    && docker-php-ext-enable imagick

RUN docker-php-ext-install gd pdo pdo_mysql zip curl mbstring xml
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs

WORKDIR /var/www/html

COPY --chown=www-data:www-data . .
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer update && composer install
RUN npm ci


RUN chmod -R 755 /var/www/html/storage
RUN php artisan storage:link


EXPOSE 9000
CMD ["php-fpm"]
