FROM php:8.3-fpm
RUN apt-get update -y \
    && apt-get install -y nginx \
    && apt-get install -y libpq-dev


RUN apt-get update && apt-get -y install curl
COPY ./services/config/php/* $PHP_INI_DIR/conf.d/

RUN curl https://getcomposer.org/download/2.7.7/composer.phar -o composer.phar \
    && mv composer.phar /usr/bin/composer && chmod +x /usr/bin/composer

RUN mkdir -p /var/www/.composer
RUN chown www-data /var/www/.composer


RUN apt-get install -y \
            libzip-dev \
            zip \
            libicu-dev \
            libjpeg-dev \
            libjpeg62-turbo-dev \
            libpng-dev \
            zlib1g-dev \
            libwebp-dev \
            libfreetype6-dev \
            libonig-dev \
            npm \
    && docker-php-ext-configure zip \
    && docker-php-ext-install zip intl
RUN apt-get install -y libgd3 libgd-dev && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN docker-php-ext-install -j$(nproc) gd
RUN  docker-php-ext-enable zip



COPY services/config/entrypoint.sh /etc/entrypoint.sh
COPY services/config/foreground.sh /etc/foreground.sh


RUN chmod +x /etc/entrypoint.sh
RUN chmod +x /etc/foreground.sh
COPY --chown=www-data:www-data ./project /var/www/html

WORKDIR /var/www/html
RUN composer install --no-dev --ignore-platform-reqs
RUN npm install
RUN npm run build
RUN apt-get purge --auto-remove -y npm

RUN #composer install --no-dev --no-interaction --no-autoloader --no-scripts
RUN #composer dump-autoload --optimize

RUN mv .env.prod .env

COPY services/config/nginx-site.conf /etc/nginx/sites-enabled/default

#CMD ["/etc/foreground.sh"]
ENTRYPOINT ["/etc/foreground.sh"]


#Uncaught Exception:
#TypeError: Object has been destroyed
#at IpcMainImpl.<anonymous> (/Users/ryjek/Library/Application Support/Steam/steamapps/common/Fake Lay/Fakelay.app/Contents/Resources/app.asar/src/main.js:108:23)
#at IpcMainImpl.emit (node:events:519:28)
#at WebContents.<anonymous> (node:electron/js2c/browser_init:2:82388)
#at WebContents.emit (node:events:519:28)



#[EINVAL] pool_dataset_create.share_type: Filesystem permissions on path /mnt/storage1 prevent access for group "builtin_users" to the path /mnt/storage1/nextcloud.
#This may be fixed by granting the aforementioned group execute permissions on the path: /mnt/storage1.