FROM php:8.3-fpm
# FROM node:alpine AS node
RUN apt-get update && apt-get install
WORKDIR /var/www/
RUN cd /var/www/
# COPY package-lock.json package.json /var/www/

# RUN npm install
# RUN npm install --save-dev chokidar
# Copy composer.lock and composer.json into the working directory
# COPY composer.lock composer.json /var/www/

# Set working directory

RUN apt-get install sudo -y
# Install dependencies for the operating system software
RUN sudo apt-get install -y openssl libssl-dev
RUN sudo apt-get install -y libcurl4-openssl-dev
RUN docker-php-ext-install curl

RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    libzip-dev \
    unzip \
    git \
    supervisor \
    libonig-dev \
    nano \
    curl

# Clear cache

RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install extensions for php
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install gd
RUN pecl list | grep swoole || pecl install swoole
RUN docker-php-ext-enable swoole
RUN pecl install redis && docker-php-ext-enable redis
# Install composer (php package manager)
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer


RUN chown -R www-data:www-data /var/www
# Assign permissions of the working directory to the www-data user
# RUN chown -R www-data:www-data \
#     /var/www/storage \
#     /var/www/bootstrap/cache \
#     /var/www/public
