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 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 opcache
RUN docker-php-ext-install -j$(nproc) gd
RUN  docker-php-ext-enable zip
RUN  docker-php-ext-enable opcache

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

RUN chmod +x /etc/foreground.sh


COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --chown=www-data:www-data ./project /var/www/html

WORKDIR /var/www/html
RUN composer install --no-dev --no-interaction --no-autoloader --no-scripts

RUN npm install
RUN npm run build
RUN apt-get purge --auto-remove -y npm


ENV COMPOSER_ALLOW_SUPERUSER=1
RUN composer dump-autoload --optimize


RUN mv .env.prod .env
COPY services/config/nginx-site.conf /etc/nginx/sites-enabled/default

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.