feat(docker): add Docker configuration and production environment setup

This commit is contained in:
2026-06-05 17:19:39 +03:30
parent 1c408130d0
commit 6eae917540
10 changed files with 492 additions and 1 deletions

86
Dockerfile Normal file
View File

@@ -0,0 +1,86 @@
# syntax=docker/dockerfile:1.7
ARG PHP_VERSION=8.4
FROM composer:2 AS composer
FROM node:24-alpine AS assets
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY resources ./resources
COPY public ./public
COPY vite.config.js ./
RUN npm run build
FROM php:${PHP_VERSION}-fpm-bookworm AS app
WORKDIR /var/www/html
ENV COMPOSER_ALLOW_SUPERUSER=1
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/install-php-extensions
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
default-mysql-client \
unzip \
&& install-php-extensions \
bcmath \
dom \
intl \
mbstring \
opcache \
pcntl \
pdo_mysql \
xml \
xmlreader \
zip \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*
COPY docker/php/php.ini /usr/local/etc/php/conf.d/99-production.ini
COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/99-opcache.ini
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY composer.json composer.lock ./
RUN composer install \
--no-dev \
--no-autoloader \
--no-scripts \
--prefer-dist \
--no-interaction \
&& composer check-platform-reqs --no-dev
COPY . .
COPY --from=assets /app/public/build ./public/build
RUN composer dump-autoload --no-dev --optimize --no-scripts \
&& php artisan package:discover --ansi \
&& mkdir -p \
storage/app/public \
storage/framework/cache/data \
storage/framework/sessions \
storage/framework/views \
storage/logs \
bootstrap/cache \
&& rm -rf public/storage \
&& ln -s ../storage/app/public public/storage \
&& chown -R www-data:www-data storage bootstrap/cache
COPY docker/entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
EXPOSE 9000
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
FROM nginx:1.27-alpine AS nginx
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=app /var/www/html/public /var/www/html/public
EXPOSE 80