diff --git a/.dockerignore b/.dockerignore index 7a0f505..1377df3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,12 +4,12 @@ .gitattributes node_modules vendor +public/build storage/framework/cache/data storage/framework/sessions storage/framework/views storage/logs storage/app/public -public/build .dockerignore docker-compose.yml *.md @@ -17,3 +17,5 @@ docker-compose.yml phpunit.xml tests scripts +bootstrap/cache/*.php +!bootstrap/cache/.gitkeep diff --git a/Dockerfile b/Dockerfile index 599ab7a..1c9f89c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,30 @@ -FROM php:8.2-alpine +FROM composer:2 AS vendor + +WORKDIR /app +COPY composer.json composer.lock ./ +RUN composer install \ + --no-dev \ + --optimize-autoloader \ + --no-interaction \ + --no-scripts \ + --no-autoloader + +FROM node:22-alpine AS frontend + +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci +COPY resources/ resources/ +COPY vite.config.js ./ +RUN npm run build + +FROM php:8.2-fpm-alpine RUN apk add --no-cache \ - postgresql-dev \ nginx \ supervisor \ curl \ + postgresql-dev \ libpng-dev \ libjpeg-turbo-dev \ freetype-dev \ @@ -18,16 +38,15 @@ WORKDIR /app COPY . . -RUN composer install --no-dev --optimize-autoloader --no-interaction \ +COPY --from=vendor /app/vendor vendor/ +COPY --from=frontend /app/public/build public/build/ + +RUN composer dump-autoload --no-dev --optimize \ && php artisan storage:link \ + && php artisan package:discover --ansi \ && chmod -R 775 storage bootstrap/cache \ && chown -R www-data:www-data storage bootstrap/cache -RUN apk add --no-cache nodejs npm \ - && npm ci && npm run build \ - && rm -rf node_modules \ - && apk del nodejs npm - COPY docker/nginx.conf /etc/nginx/http.d/default.conf COPY docker/supervisord.conf /etc/supervisor.conf @@ -35,4 +54,6 @@ RUN echo "* * * * * php /app/artisan schedule:run >> /dev/null 2>&1" > /etc/cron EXPOSE 80 +STOPSIGNAL SIGQUIT + CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor.conf"]