diff --git a/app/Console/Commands/DeployRunCommand.php b/app/Console/Commands/DeployRunCommand.php deleted file mode 100644 index 942cf76..0000000 --- a/app/Console/Commands/DeployRunCommand.php +++ /dev/null @@ -1,203 +0,0 @@ -lockFile)) { - $this->error('Deploy already in progress'); - return 1; - } - - File::put($this->lockFile, (string) getpid()); - $this->initStatus(); - - try { - $this->executeDeploy(); - $this->updateStatus([ - 'running' => false, - 'success' => true, - ]); - return 0; - } catch (\Exception $e) { - $this->handleError($e); - return 1; - } finally { - File::delete($this->lockFile); - } - } - - private function initStatus(): void - { - $this->writeStatus([ - 'running' => true, - 'step' => 0, - 'total_steps' => $this->totalSteps, - 'current_step' => '', - 'started_at' => now()->toIso8601String(), - 'logs' => [], - 'error' => null, - ]); - } - - private function writeStatus(array $data): void - { - File::put($this->statusFile, json_encode($data)); - } - - private function updateStatus(array $updates): void - { - $status = json_decode(File::get($this->statusFile), true); - $status = array_merge($status, $updates); - $this->writeStatus($status); - } - - private function addLog(string $message): void - { - $status = json_decode(File::get($this->statusFile), true); - $status['logs'][] = '[' . now()->format('H:i:s') . '] ' . $message; - $this->writeStatus($status); - $this->line($message); - } - - private function executeStep(int $step, string $name, callable $callback): void - { - $this->updateStatus([ - 'step' => $step, - 'current_step' => $name, - ]); - $this->addLog("Step {$step}/{$this->totalSteps}: {$name}"); - - $callback(); - - $this->addLog("✅ {$name} completed"); - } - - private function executeDeploy(): void - { - $this->executeStep(1, 'Maintenance mode', function () { - $this->execCommand('php artisan down'); - }); - - $this->executeStep(2, 'Git pull', function () { - $this->execCommand('git config --global --add safe.directory /var/www'); - $this->execCommand('git reset --hard'); - $this->execCommand('git pull origin master'); - }); - - $this->executeStep(3, 'Composer install', function () { - $this->execCommand('composer install --no-dev --no-interaction --prefer-dist --no-cache'); - }); - - $this->executeStep(4, 'Database backup', function () { - $backupDir = storage_path('app/backups'); - if (!is_dir($backupDir)) { - mkdir($backupDir, 0755, true); - } - $filename = 'backup_' . now()->format('Y-m-d_H-i-s') . '.sql.gz'; - $filepath = $backupDir . '/' . $filename; - $dbHost = env('DB_HOST', 'db'); - $dbName = env('DB_DATABASE', 'ntspi_db'); - $dbUser = env('DB_USERNAME', 'admin'); - $dbPass = env('DB_PASSWORD', 'secret'); - $this->execCommand( - "mysqldump -h {$dbHost} -u {$dbUser} -p{$dbPass} {$dbName} | gzip > {$filepath}" - ); - $this->addLog("Backup saved: {$filepath}"); - }); - - $this->executeStep(5, 'Migrate', function () { - $this->execCommand('php artisan migrate --force'); - }); - - $this->executeStep(6, 'NPM install', function () { - $this->execCommand('npm install --legacy-peer-deps'); - }); - - $this->executeStep(7, 'NPM build', function () { - $this->execCommand('npm run build'); - }); - - $this->executeStep(8, 'Cache clear', function () { - $this->execCommand('php artisan cache:clear'); - $this->execCommand('php artisan config:clear'); - $this->execCommand('php artisan route:clear'); - $this->execCommand('php artisan view:clear'); - $this->execCommand('php artisan filament:clear-cached-components'); - $this->execCommand('php artisan filament:optimize-clear'); - }); - - $this->executeStep(9, 'Cache warm', function () { - $this->execCommand('php artisan routes:register'); - $this->execCommand('php artisan route:cache'); - $this->execCommand('php artisan view:cache'); - $this->execCommand('php artisan icons:cache'); - $this->execCommand('php artisan filament:cache-components'); - $this->execCommand('php artisan filament:optimize'); - }); - - $this->executeStep(10, 'Fix permissions', function () { - $this->execCommand('chown -R www-data:www-data storage bootstrap/cache'); - $this->execCommand('chmod -R 775 storage bootstrap/cache'); - }); - - $this->executeStep(11, 'Restart processes', function () { - $this->execCommand('supervisorctl restart inertia-ssr'); - $this->execCommand('supervisorctl restart cron'); - }); - - $this->executeStep(12, 'Restart queue workers', function () { - $this->execCommand('php artisan queue:restart'); - }); - - $this->executeStep(13, 'Maintenance off', function () { - $this->execCommand('php artisan up'); - }); - } - - private function execCommand(string $command): void - { - $process = Process::run($command); - - if ($process->exitCode() !== 0) { - throw new \RuntimeException( - "Command failed: {$command}\n" . $process->errorOutput() - ); - } - } - - private function handleError(\Exception $e): void - { - $this->addLog("❌ Error: " . $e->getMessage()); - - $this->updateStatus([ - 'running' => false, - 'success' => false, - 'error' => $e->getMessage(), - ]); - - $this->addLog('Attempting rollback...'); - - try { - $this->execCommand('git checkout .'); - $this->execCommand('composer install --no-dev --prefer-dist'); - $this->execCommand('php artisan up'); - $this->addLog('Rollback completed'); - } catch (\Exception $rollbackException) { - $this->addLog("❌ Rollback failed: " . $rollbackException->getMessage()); - } - } -} diff --git a/app/Containers/Dashboard/UI/API/Controllers/DeployController.php b/app/Containers/Dashboard/UI/API/Controllers/DeployController.php deleted file mode 100644 index c00af53..0000000 --- a/app/Containers/Dashboard/UI/API/Controllers/DeployController.php +++ /dev/null @@ -1,44 +0,0 @@ -lockFile)) { - return response()->json([ - 'error' => 'Deploy already in progress' - ], 409); - } - - Process::run('nohup php artisan deploy:run > /dev/null 2>&1 &'); - - return response()->json(['message' => 'Deploy started']); - } - - public function status(): JsonResponse - { - if (!File::exists($this->statusFile)) { - return response()->json([ - 'running' => false, - 'step' => 0, - 'total_steps' => 12, - 'current_step' => '', - 'logs' => [], - 'error' => null, - ]); - } - - $status = json_decode(File::get($this->statusFile), true); - return response()->json($status); - } -} diff --git a/app/Containers/Dashboard/UI/API/Routes/api.php b/app/Containers/Dashboard/UI/API/Routes/api.php deleted file mode 100644 index acafca2..0000000 --- a/app/Containers/Dashboard/UI/API/Routes/api.php +++ /dev/null @@ -1,15 +0,0 @@ -group(function () { - Route::post('/deploy', [DeployController::class, 'store']); - Route::get('/deploy/status', [DeployController::class, 'status']); -}); diff --git a/app/Containers/Dashboard/UI/WEB/Routes/web.php b/app/Containers/Dashboard/UI/WEB/Routes/web.php index f5683bc..1722e8b 100755 --- a/app/Containers/Dashboard/UI/WEB/Routes/web.php +++ b/app/Containers/Dashboard/UI/WEB/Routes/web.php @@ -416,11 +416,6 @@ Route::middleware(['access-check', 'dashboard.auth'])->group(function () { Route::put('/{credential}', [IntegrationCredentialsController::class, 'update'])->name('update'); Route::delete('/{credential}', [IntegrationCredentialsController::class, 'destroy'])->name('destroy'); }); - - // Deploy - Route::get('/dashboard/deploy', function () { - return inertia()->render('Dashboard/Deploy/Index'); - })->name('dashboard.deploy'); }); diff --git a/app/Ship/Kernels/ConsoleKernel.php b/app/Ship/Kernels/ConsoleKernel.php index 63439e6..b091dd0 100755 --- a/app/Ship/Kernels/ConsoleKernel.php +++ b/app/Ship/Kernels/ConsoleKernel.php @@ -5,7 +5,6 @@ namespace App\Ship\Kernels; use AlxDorosenco\PortoForLaravel\Loaders\CommandsLoader; use AlxDorosenco\PortoForLaravel\Loaders\RoutesLoader; use App\Containers\Dashboard\Commands\FetchEmailNewsCommand; -use App\Console\Commands\DeployRunCommand; use App\Ship\Commands\InitRoles; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as LaravelConsoleKernel; @@ -35,7 +34,6 @@ class ConsoleKernel extends LaravelConsoleKernel protected $commands = [ InitRoles::class, FetchEmailNewsCommand::class, - DeployRunCommand::class, ]; /** diff --git a/resources/js/Pages/Dashboard/Components/quickActionsConfig.js b/resources/js/Pages/Dashboard/Components/quickActionsConfig.js index acc6061..0fff24a 100644 --- a/resources/js/Pages/Dashboard/Components/quickActionsConfig.js +++ b/resources/js/Pages/Dashboard/Components/quickActionsConfig.js @@ -31,10 +31,4 @@ export const quickActions = [ href: null, icon: 'cog', }, - { - label: 'Deploy', - route: 'dashboard.deploy', - href: null, - icon: 'cog', - }, ]; diff --git a/resources/js/Pages/Dashboard/Deploy/Index.vue b/resources/js/Pages/Dashboard/Deploy/Index.vue deleted file mode 100644 index 2d8483e..0000000 --- a/resources/js/Pages/Dashboard/Deploy/Index.vue +++ /dev/null @@ -1,117 +0,0 @@ - - - - - Deploy - - - - - - - - diff --git a/resources/js/Pages/Dashboard/Deploy/components/DeployButton.vue b/resources/js/Pages/Dashboard/Deploy/components/DeployButton.vue deleted file mode 100644 index 05a56ce..0000000 --- a/resources/js/Pages/Dashboard/Deploy/components/DeployButton.vue +++ /dev/null @@ -1,20 +0,0 @@ - - - - - Deploying... - 🚀 Deploy to Production - - diff --git a/resources/js/Pages/Dashboard/Deploy/components/DeployLogs.vue b/resources/js/Pages/Dashboard/Deploy/components/DeployLogs.vue deleted file mode 100644 index 01c5b36..0000000 --- a/resources/js/Pages/Dashboard/Deploy/components/DeployLogs.vue +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Logs - - - No logs yet... - - - {{ log }} - - - - diff --git a/resources/js/Pages/Dashboard/Deploy/components/DeployProgress.vue b/resources/js/Pages/Dashboard/Deploy/components/DeployProgress.vue deleted file mode 100644 index 3fecdf2..0000000 --- a/resources/js/Pages/Dashboard/Deploy/components/DeployProgress.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - {{ currentStep }} - {{ step }}/{{ totalSteps }} - - - - - - - - ❌ {{ error }} - - - - ✅ Deploy completed successfully - - -