Error correction and preparation of the project for initial deployment

This commit is contained in:
F4ilji
2025-08-11 16:12:10 +05:00
parent 8b2f9e99f0
commit e62b442991
9 changed files with 109 additions and 30 deletions
+37 -11
View File
@@ -1,6 +1,11 @@
FROM php:8.2-fpm
# Устанавливаем рабочую директорию до установки системных зависимостей,
# чтобы все последующие команды выполнялись в правильном контексте.
WORKDIR /var/www
# Установка системных зависимостей
# В одном RUN-слое, чтобы уменьшить количество слоев в образе.
RUN apt-get update && apt-get install -y \
apt-utils \
libpq-dev \
@@ -21,15 +26,17 @@ RUN apt-get update && apt-get install -y \
libicu-dev \
g++ \
default-mysql-client \
&& docker-php-ext-configure gd --with-webp --with-jpeg \
&& docker-php-ext-install gd pdo_mysql bcmath zip intl \
# Установка Node.js (актуальная LTS-версия 18)
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
# Очистка кэша, чтобы уменьшить размер образа
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Установка Node.js (актуальная LTS-версия)
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm
# Установка расширений PHP
RUN docker-php-ext-configure gd --with-webp --with-jpeg \
&& docker-php-ext-install gd pdo_mysql bcmath zip intl
# Установка Composer
ENV COMPOSER_ALLOW_SUPERUSER=1
@@ -37,6 +44,28 @@ RUN curl -sS https://getcomposer.org/installer | php -- \
--filename=composer \
--install-dir=/usr/local/bin
# Создаём необходимые поддиректории внутри 'storage'
# Шаг 5: Копирование файлов Composer для кэширования
COPY composer.json composer.lock ./
# Шаг 6: Установка зависимостей
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Шаг 7: Копирование всего остального кода приложения
# В этот момент директории 'storage' и 'bootstrap/cache' появятся в образе.
COPY . .
# Шаг 8: Создание необходимых поддиректорий
# Эта команда создаст поддиректории внутри 'storage', которые могут отсутствовать.
RUN mkdir -p storage/framework/views storage/framework/sessions storage/framework/cache storage/logs
# Шаг 9: Установка прав доступа
# Теперь эта команда выполнится успешно, так как директории уже существуют.
RUN chown -R www-data:www-data storage bootstrap/cache \
&& chmod -R 775 storage bootstrap/cache
# Копирование конфигураций
COPY ./_docker/app/php.ini /usr/local/etc/php/conf.d/php.ini
COPY ./_docker/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
@@ -47,12 +76,9 @@ RUN chmod 0644 /etc/cron.d/laravel-cron \
&& crontab /etc/cron.d/laravel-cron \
&& touch /var/log/cron.log
# Рабочая директория
WORKDIR /var/www
# Запуск Supervisor (управляет PHP-FPM и Inertia SSR)
# Запуск Supervisor (управляет PHP-FPM, Inertia SSR, и worker-ами)
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]
# Открываем порты
EXPOSE 9000
EXPOSE 13714
EXPOSE 13714
+1 -14
View File
@@ -8,7 +8,6 @@ use App\Containers\InstituteStructure\Models\Faculty;
use App\Ship\Contracts\SeoDescriptionInterface;
use App\Ship\Contracts\SeoTitleInterface;
use App\Ship\Traits\HasSeo;
use BezhanSalleh\FilamentShield\FilamentShield;
use BezhanSalleh\FilamentShield\Support\Utils;
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
use Filament\Models\Contracts\FilamentUser;
@@ -97,19 +96,7 @@ class User extends Authenticatable implements FilamentUser, SeoTitleInterface, S
return $this->hasOne(AcceptedInvitation::class, 'receiver_id');
}
protected static function booted(): void
{
if (config('filament-shield.dashboard_user.enabled', false)) {
FilamentShield::createRole(name: config('filament-shield.dashboard_user.name', 'dashboard_user'));
FilamentShield::createRole(name: config('', 'editor'));
static::created(function (User $user) {
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
});
static::deleting(function (User $user) {
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
});
}
}
public function canAccessPanel(Panel|\Filament\Panel $panel): bool
{
return match ($panel->getId()) {
+4 -1
View File
@@ -20,6 +20,9 @@ class UserObserver
public function created(User $user): void
{
$this->userCacheService->clearAllCacheByModel();
if (\Illuminate\Support\Facades\Schema::hasTable('roles')) {
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
}
}
/**
@@ -56,4 +59,4 @@ class UserObserver
$this->userCacheService->clearCache($user);
$this->userCacheService->clearAllCacheByModel();
}
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace App\Ship\Commands;
use BezhanSalleh\FilamentShield\FilamentShield;
use App\Ship\Abstracts\Commands\ConsoleCommand as AbstractConsoleCommand;
class InitRoles extends AbstractConsoleCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'roles:init-roles';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Initializes default roles for Filament Shield.';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): void
{
// Проверяем, что Filament Shield включен
if (!config('filament-shield.dashboard_user.enabled', false)) {
$this->warn('Filament Shield dashboard user is not enabled in the config.');
return;
}
// Создаем роли
FilamentShield::createRole(
name: config('filament-shield.dashboard_user.name', 'dashboard_user')
);
FilamentShield::createRole(
name: config('', 'editor')
);
$this->info('Filament Shield roles have been initialized successfully.');
}
}
+5
View File
@@ -4,6 +4,7 @@ namespace App\Ship\Kernels;
use AlxDorosenco\PortoForLaravel\Loaders\CommandsLoader;
use AlxDorosenco\PortoForLaravel\Loaders\RoutesLoader;
use App\Ship\Commands\InitRoles;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as LaravelConsoleKernel;
@@ -23,6 +24,10 @@ class ConsoleKernel extends LaravelConsoleKernel
$schedule->command('sitemap:generate')->dailyAt('03:00');
}
protected $commands = [
InitRoles::class,
];
/**
* Register the commands for the application.
*
-1
View File
@@ -14,7 +14,6 @@
"filament/filament": "v3.2.127",
"filament/spatie-laravel-settings-plugin": "^3.2",
"filament/spatie-laravel-tags-plugin": "v3.2.113",
"defstudio/telegraph": "^1.59",
"guava/filament-icon-picker": "2.2.4",
"guzzlehttp/guzzle": "^7.8",
"imangazaliev/didom": "^2.0",
@@ -1,5 +1,6 @@
<?php
use App\Containers\Widget\Models\CustomForm;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@@ -13,7 +14,7 @@ return new class extends Migration
{
Schema::create('custom_form_responses', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\CustomForm::class);
$table->foreignIdFor(CustomForm::class);
$table->text('answers');
$table->boolean('checked')->default(0);
$table->timestamps();
+8 -2
View File
@@ -39,12 +39,15 @@ services:
container_name: ntspi-php
restart: always
ports:
- '5173'
- "5173"
depends_on:
db:
condition: service_healthy
networks:
- app-network
dns:
- 8.8.8.8 # Google DNS
- 1.1.1.1 # Cloudflare DNS
php-queue-worker:
restart: always
@@ -60,6 +63,9 @@ services:
condition: service_healthy
networks:
- app-network
dns:
- 8.8.8.8 # Google DNS
- 1.1.1.1 # Cloudflare DNS
db:
image: mysql:8.0
@@ -100,4 +106,4 @@ volumes:
networks:
app-network:
driver: bridge
driver: bridge
+4
View File
@@ -4,6 +4,10 @@ APP_KEY=base64:AteyeZacFiLsdXZUpcqOR8QTMm/stbJ/cheFLgm8+FQ=
APP_DEBUG=false
APP_URL=http://localhost/
NGINX_ENV=test
PORTO_ENABLED=true
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug