работа с контейнерами

This commit is contained in:
2026-08-03 00:09:50 +04:00
parent 6c18cad816
commit c25304919c
13 changed files with 599 additions and 4 deletions
+116
View File
@@ -0,0 +1,116 @@
# syntax=docker/dockerfile:1
FROM php:8.3-fpm-bookworm AS php-base
ARG APP_UID=1000
ARG APP_GID=1000
ENV APP_ENV=production \
APP_DEBUG=false \
COMPOSER_ALLOW_SUPERUSER=1
WORKDIR /var/www/html
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libfcgi-bin \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j"$(nproc)" \
bcmath \
exif \
gd \
intl \
pcntl \
pdo_mysql \
sockets \
zip \
&& apt-mark manual \
libfcgi-bin \
libfreetype6 \
libicu72 \
libjpeg62-turbo \
libpng16-16 \
libzip4 \
&& apt-get purge -y --auto-remove \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid "$APP_GID" app \
&& useradd --uid "$APP_UID" --gid "$APP_GID" --create-home --shell /usr/sbin/nologin app
COPY docker/production/php.ini /usr/local/etc/php/conf.d/99-production.ini
COPY docker/production/php-fpm-pool.conf /usr/local/etc/php-fpm.d/zz-production.conf
FROM php-base AS vendor
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
COPY . .
RUN composer install \
--no-dev \
--prefer-dist \
--optimize-autoloader \
--no-interaction \
--no-progress \
&& composer clear-cache
FROM node:24-bookworm-slim AS frontend
WORKDIR /var/www/html
COPY package.json package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY resources ./resources
COPY public ./public
COPY vite.config.* ./
ARG VITE_APP_NAME=Moonwell
ENV VITE_APP_NAME="$VITE_APP_NAME"
RUN npm run build
FROM php-base AS app
COPY --from=vendor --chown=app:app /var/www/html /var/www/html
COPY --from=frontend --chown=app:app /var/www/html/public/build /var/www/html/public/build
RUN mkdir -p \
bootstrap/cache \
storage/app/public \
storage/framework/cache/data \
storage/framework/sessions \
storage/framework/views \
storage/logs \
&& chown -R app:app bootstrap/cache storage
EXPOSE 9000
CMD ["php-fpm", "--nodaemonize"]
FROM nginx:1.27-alpine AS web
ARG APP_UID=1000
ARG APP_GID=1000
RUN addgroup -S -g "$APP_GID" app \
&& adduser -S -D -H -u "$APP_UID" -G app app
COPY docker/production/nginx.conf /etc/nginx/nginx.conf
COPY --from=vendor --chown=app:app /var/www/html/public /var/www/html/public
COPY --from=frontend --chown=app:app /var/www/html/public/build /var/www/html/public/build
USER app
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
+60
View File
@@ -0,0 +1,60 @@
worker_processes auto;
pid /tmp/nginx.pid;
error_log /dev/stderr warn;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
client_max_body_size 100m;
client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
server {
listen 8080 default_server;
server_name _;
root /var/www/html/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /healthz {
allow 127.0.0.1;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /healthz;
fastcgi_pass app:9000;
}
location = /index.php {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php;
fastcgi_param HTTP_PROXY "";
fastcgi_pass app:9000;
fastcgi_read_timeout 60s;
}
location ~ \.php$ {
return 404;
}
location ~ /\. {
deny all;
}
}
}
+23
View File
@@ -0,0 +1,23 @@
[www]
user = app
group = app
listen = 0.0.0.0:9000
pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 4
pm.max_requests = 500
request_terminate_timeout = 60s
request_slowlog_timeout = 10s
slowlog = /proc/self/fd/2
ping.path = /healthz
ping.response = pong
clear_env = no
catch_workers_output = yes
decorate_workers_output = no
+22
View File
@@ -0,0 +1,22 @@
[PHP]
expose_php = Off
display_errors = Off
display_startup_errors = Off
log_errors = On
memory_limit = 256M
max_execution_time = 60
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
[Date]
date.timezone = UTC
[opcache]
opcache.enable = 1
opcache.enable_cli = 0
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.validate_timestamps = 0
opcache.save_comments = 1