FROM webdevops/php-nginx:8.2-alpine
WORKDIR /app

COPY ./custom/php.ini /opt/docker/etc/php/php.ini
COPY ./custom/custom_nginx.conf /opt/docker/etc/nginx/vhost.conf
COPY ./custom/nginx.conf /opt/docker/etc/nginx/nginx.conf
COPY .env ./
COPY . ./

# RUN chown -R www-data:www-data /app \
#     && chmod -R 777 /app/storage \
#     && chmod -R 777 /app/bootstrap/cache

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

COPY composer.json composer.lock /app
RUN composer update
RUN composer install \
    --ignore-platform-reqs \
    --no-interaction \
    --no-plugins \
    --no-scripts \
    --prefer-dist
RUN chown -R www-data:www-data /app/public \
    && chown -R www-data:www-data /app/storage \
    && chmod -R 777 /app/storage \
    && chmod -R 777 /app/bootstrap/cache \
    && chmod -R 777 /app/public
RUN apk add php-gd

RUN php artisan key:generate

#RUN php artisan migrate --seed

RUN apk update && apk add nodejs npm

RUN npm install

RUN npm run build

EXPOSE 80

