# Use an official Node.js image with a specified version
FROM node:23 AS node

# Use the PHP 8.3-fpm image as a base
FROM php:8.3-fpm

# Install additional dependencies for PHP
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        git \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

# Copy the installed Node.js binaries from the Node.js image
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /usr/local/include/node /usr/local/include/node
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules

# Install npm (Node Package Manager)
RUN apt-get install -y npm

# Continue with the rest of your Dockerfile
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN install-php-extensions gd xdebug zip intl mbstring exif mysqli pdo_mysql redis pcntl sockets

RUN apt-get update && apt-get install -y default-mysql-client

# Install Composer
RUN install-php-extensions @composer
