diff --git a/app/Livewire/Settings/Backup.php b/app/Livewire/Settings/Backup.php index 67a457774..121b73af8 100644 --- a/app/Livewire/Settings/Backup.php +++ b/app/Livewire/Settings/Backup.php @@ -41,35 +41,39 @@ public function mount() } public function add_coolify_database() { - $server = Server::find(0); - $out = instant_remote_process(['docker inspect coolify-db'], $server); - $envs = format_docker_envs_to_json($out); - $postgres_password = $envs['POSTGRES_PASSWORD']; - $postgres_user = $envs['POSTGRES_USER']; - $postgres_db = $envs['POSTGRES_DB']; - $this->database = StandalonePostgresql::create([ - 'id' => 0, - 'name' => 'coolify-db', - 'description' => 'Coolify database', - 'postgres_user' => $postgres_user, - 'postgres_password' => $postgres_password, - 'postgres_db' => $postgres_db, - 'status' => 'running', - 'destination_type' => 'App\Models\StandaloneDocker', - 'destination_id' => 0, - ]); - $this->backup = ScheduledDatabaseBackup::create([ - 'id' => 0, - 'enabled' => true, - 'save_s3' => false, - 'frequency' => '0 0 * * *', - 'database_id' => $this->database->id, - 'database_type' => 'App\Models\StandalonePostgresql', - 'team_id' => currentTeam()->id, - ]); - $this->database->refresh(); - $this->backup->refresh(); - $this->s3s = S3Storage::whereTeamId(0)->get(); + try { + $server = Server::findOrFail(0); + $out = instant_remote_process(['docker inspect coolify-db'], $server); + $envs = format_docker_envs_to_json($out); + $postgres_password = $envs['POSTGRES_PASSWORD']; + $postgres_user = $envs['POSTGRES_USER']; + $postgres_db = $envs['POSTGRES_DB']; + $this->database = StandalonePostgresql::create([ + 'id' => 0, + 'name' => 'coolify-db', + 'description' => 'Coolify database', + 'postgres_user' => $postgres_user, + 'postgres_password' => $postgres_password, + 'postgres_db' => $postgres_db, + 'status' => 'running', + 'destination_type' => 'App\Models\StandaloneDocker', + 'destination_id' => 0, + ]); + $this->backup = ScheduledDatabaseBackup::create([ + 'id' => 0, + 'enabled' => true, + 'save_s3' => false, + 'frequency' => '0 0 * * *', + 'database_id' => $this->database->id, + 'database_type' => 'App\Models\StandalonePostgresql', + 'team_id' => currentTeam()->id, + ]); + $this->database->refresh(); + $this->backup->refresh(); + $this->s3s = S3Storage::whereTeamId(0)->get(); + } catch (\Exception $e) { + return handleError($e, $this); + } } public function backup_now() diff --git a/app/Models/Application.php b/app/Models/Application.php index 3ebe80ee3..1b60914a7 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -621,7 +621,6 @@ function generateGitImportCommands(string $deployment_uuid, int $pull_request_id $commands->push("cd {$baseDir} && git fetch origin {$branch} && $git_checkout_command"); } } - ray($commands); return [ 'commands' => $commands->implode(' && '), 'branch' => $branch, diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php index 5d759e651..0ae94363b 100644 --- a/bootstrap/helpers/github.php +++ b/bootstrap/helpers/github.php @@ -29,7 +29,7 @@ function generate_github_installation_token(GithubApp $source) 'Accept' => 'application/vnd.github.machine-man-preview+json' ])->post("{$source->api_url}/app/installations/{$source->installation_id}/access_tokens"); if ($token->failed()) { - throw new RuntimeException("Failed to get access token for " . $source->name . " with error: " . $token->json()['message']); + throw new RuntimeException("Failed to get access token for " . $source->name . " with error: " . data_get($token->json(),'message','no error message found')); } return $token->json()['token']; } diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 0a51b3ffc..bfb86406c 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -7,11 +7,10 @@ use App\Models\ApplicationDeploymentQueue; use App\Models\PrivateKey; use App\Models\Server; -use App\Notifications\Server\Revived; -use App\Notifications\Server\Unreachable; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Process; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; @@ -135,7 +134,6 @@ function generateSshCommand(Server $server, string $command) $connectionTimeout = config('constants.ssh.connection_timeout'); $serverInterval = config('constants.ssh.server_interval'); - $delimiter = 'EOF-COOLIFY-SSH'; $ssh_command = "timeout $timeout ssh "; if (config('coolify.mux_enabled') && config('coolify.is_windows_docker_desktop') == false) { @@ -145,6 +143,9 @@ function generateSshCommand(Server $server, string $command) $ssh_command .= '-o ProxyCommand="/usr/local/bin/cloudflared access ssh --hostname %h" '; } $command = "PATH=\$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/host/usr/local/sbin:/host/usr/local/bin:/host/usr/sbin:/host/usr/bin:/host/sbin:/host/bin && $command"; + + $delimiter = Hash::make($command); + $command = str_replace($delimiter, '', $command); $ssh_command .= "-i {$privateKeyLocation} " . '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ' . '-o PasswordAuthentication=no ' @@ -158,6 +159,7 @@ function generateSshCommand(Server $server, string $command) . $command . PHP_EOL . $delimiter; // ray($ssh_command); + ray($delimiter); return $ssh_command; } function instant_remote_process(Collection|array $command, Server $server, $throwError = true) diff --git a/config/sentry.php b/config/sentry.php index 5250d3547..f1d8aa314 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.252', + 'release' => '4.0.0-beta.253', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index a0ca28c13..e92f47087 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ text('custom_docker_run_options')->nullable()->change(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('applications', function (Blueprint $table) { + $table->string('custom_docker_run_options')->nullable()->change(); + }); + } +}; diff --git a/versions.json b/versions.json index fdb163496..9cf2b6e22 100644 --- a/versions.json +++ b/versions.json @@ -1,7 +1,7 @@ { "coolify": { "v4": { - "version": "4.0.0-beta.252" + "version": "4.0.0-beta.253" } } }