From a378b5108ee93c718428ffea5d15750621eb5c89 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 9 Aug 2023 15:57:53 +0200 Subject: [PATCH] refactor a lot of things fix: postgres_passwords could be longer feat: able to define postgresql databases from the ui --- app/Actions/Database/StartPostgresql.php | 2 +- app/Actions/License/CheckResaleLicense.php | 2 +- app/Actions/Server/UpdateCoolify.php | 4 +- app/Console/Kernel.php | 2 +- app/Exceptions/Handler.php | 2 +- app/Http/Controllers/Controller.php | 4 +- app/Http/Controllers/ProjectController.php | 14 ++- .../Livewire/Project/Application/Heading.php | 2 +- .../Livewire/Project/Application/Previews.php | 2 +- .../Livewire/Project/Application/Rollback.php | 2 +- .../Livewire/Project/Database/Heading.php | 2 +- .../Livewire/Project/DeleteEnvironment.php | 2 +- app/Http/Livewire/Project/DeleteProject.php | 2 +- .../Project/New/GithubPrivateRepository.php | 2 +- .../New/GithubPrivateRepositoryDeployKey.php | 4 +- .../Project/New/PublicGitRepository.php | 4 +- app/Http/Livewire/Project/New/Select.php | 2 +- app/Http/Livewire/Project/Shared/Danger.php | 2 +- .../Shared/EnvironmentVariable/Add.php | 2 +- .../Shared/EnvironmentVariable/Show.php | 2 +- .../Livewire/Project/Shared/Storages/Add.php | 2 +- app/Http/Livewire/Server/PrivateKey.php | 2 +- app/Http/Livewire/Source/Github/Change.php | 2 +- app/Http/Livewire/Team/InviteLink.php | 2 +- app/Http/Livewire/Team/Storage/Create.php | 2 +- app/Http/Livewire/Upgrade.php | 2 +- app/Http/Middleware/SubscriptionValid.php | 2 +- app/Jobs/DockerCleanupJob.php | 2 +- bootstrap/helpers/contants.php | 3 + bootstrap/helpers/databases.php | 28 ++++++ bootstrap/helpers/proxy.php | 4 +- bootstrap/helpers/shared.php | 87 +++++++++++-------- ...res_password_of_standalone_postgresqls.php | 21 +++++ .../components/applications/links.blade.php | 10 +-- .../components/settings/navbar.blade.php | 2 +- resources/views/dashboard.blade.php | 2 +- .../notifications/discord-settings.blade.php | 2 +- .../notifications/email-settings.blade.php | 2 +- .../views/livewire/server/form.blade.php | 2 +- resources/views/team/show.blade.php | 2 +- routes/webhooks.php | 2 +- versions.json | 16 ++-- 42 files changed, 167 insertions(+), 92 deletions(-) create mode 100644 bootstrap/helpers/contants.php create mode 100644 bootstrap/helpers/databases.php create mode 100644 database/migrations/2023_08_09_154921_change_postgres_password_of_standalone_postgresqls.php diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 27e0620f1..4b9b99f3e 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -150,7 +150,7 @@ private function generate_environment_variables() private function generate_init_scripts() { - if (count($this->database->init_scripts) === 0) { + if (is_null($this->database->init_scripts) || count($this->database->init_scripts) === 0) { return; } foreach ($this->database->init_scripts as $init_script) { diff --git a/app/Actions/License/CheckResaleLicense.php b/app/Actions/License/CheckResaleLicense.php index 2ce3c574a..71d1dddaa 100644 --- a/app/Actions/License/CheckResaleLicense.php +++ b/app/Actions/License/CheckResaleLicense.php @@ -18,7 +18,7 @@ public function __invoke() return; } $base_url = config('coolify.license_url'); - if (isDev()) { + if (is_dev()) { $base_url = 'http://host.docker.internal:8787'; } $instance_id = config('app.id'); diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index 8b5644a1d..8f81852d8 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -17,7 +17,7 @@ public function __invoke(bool $force) $settings = InstanceSettings::get(); ray('Running InstanceAutoUpdateJob'); $localhost_name = 'localhost'; - if (isDev()) { + if (is_dev()) { $localhost_name = 'testing-local-docker-container'; } $this->server = Server::where('name', $localhost_name)->firstOrFail(); @@ -52,7 +52,7 @@ public function __invoke(bool $force) private function update() { - if (isDev()) { + if (is_dev()) { ray("Running update on local docker container. Updating to $this->latest_version"); remote_process([ "sleep 10" diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index b580979ff..501303b2f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule): void { // $schedule->call(fn() => $this->check_scheduled_backups($schedule))->everyTenSeconds(); - if (isDev()) { + if (is_dev()) { $schedule->command('horizon:snapshot')->everyMinute(); $schedule->job(new InstanceApplicationsStatusJob)->everyMinute(); $schedule->job(new ProxyCheckJob)->everyFiveMinutes(); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 9d9dabab6..b08c07012 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -45,7 +45,7 @@ public function register(): void { $this->reportable(function (Throwable $e) { $this->settings = InstanceSettings::get(); - if ($this->settings->do_not_track || isDev()) { + if ($this->settings->do_not_track || is_dev()) { return; } Integration::captureUnhandledException($e); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 125f56d70..a2ed0f2f9 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -19,7 +19,7 @@ class Controller extends BaseController public function subscription() { - if (!isCloud()) { + if (!is_cloud()) { abort(404); } return view('subscription', [ @@ -29,7 +29,7 @@ public function subscription() public function license() { - if (!isCloud()) { + if (!is_cloud()) { abort(404); } return view('settings.license', [ diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 80cdc7b47..9cab1063d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -41,6 +41,9 @@ public function show() public function new() { + $type = request()->query('type'); + $destination_uuid = request()->query('destination'); + $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); @@ -49,9 +52,14 @@ public function new() if (!$environment) { return redirect()->route('dashboard'); } - - $type = request()->query('type'); - + if (in_array($type, DATABASE_TYPES)) { + $standalone_postgresql = create_standalone_postgresql($environment->id, $destination_uuid); + return redirect()->route('project.database.configuration', [ + 'project_uuid' => $project->uuid, + 'environment_name' => $environment->name, + 'database_uuid' => $standalone_postgresql->uuid, + ]); + } return view('project.new', [ 'type' => $type ]); diff --git a/app/Http/Livewire/Project/Application/Heading.php b/app/Http/Livewire/Project/Application/Heading.php index 41b84bb15..fdbe5f71e 100644 --- a/app/Http/Livewire/Project/Application/Heading.php +++ b/app/Http/Livewire/Project/Application/Heading.php @@ -17,7 +17,7 @@ class Heading extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function check_status() diff --git a/app/Http/Livewire/Project/Application/Previews.php b/app/Http/Livewire/Project/Application/Previews.php index f6f493827..b3582fbef 100644 --- a/app/Http/Livewire/Project/Application/Previews.php +++ b/app/Http/Livewire/Project/Application/Previews.php @@ -20,7 +20,7 @@ class Previews extends Component public function mount() { $this->pull_requests = collect(); - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function loadStatus($pull_request_id) diff --git a/app/Http/Livewire/Project/Application/Rollback.php b/app/Http/Livewire/Project/Application/Rollback.php index ee827b206..d4ac53045 100644 --- a/app/Http/Livewire/Project/Application/Rollback.php +++ b/app/Http/Livewire/Project/Application/Rollback.php @@ -16,7 +16,7 @@ class Rollback extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function rollbackImage($commit) diff --git a/app/Http/Livewire/Project/Database/Heading.php b/app/Http/Livewire/Project/Database/Heading.php index 300804bad..59f4955a6 100644 --- a/app/Http/Livewire/Project/Database/Heading.php +++ b/app/Http/Livewire/Project/Database/Heading.php @@ -34,7 +34,7 @@ public function check_status() public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function stop() diff --git a/app/Http/Livewire/Project/DeleteEnvironment.php b/app/Http/Livewire/Project/DeleteEnvironment.php index da08b5fc6..f341d7cb5 100644 --- a/app/Http/Livewire/Project/DeleteEnvironment.php +++ b/app/Http/Livewire/Project/DeleteEnvironment.php @@ -12,7 +12,7 @@ class DeleteEnvironment extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function delete() diff --git a/app/Http/Livewire/Project/DeleteProject.php b/app/Http/Livewire/Project/DeleteProject.php index bfb1b683c..5bbfea17a 100644 --- a/app/Http/Livewire/Project/DeleteProject.php +++ b/app/Http/Livewire/Project/DeleteProject.php @@ -12,7 +12,7 @@ class DeleteProject extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function delete() diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepository.php b/app/Http/Livewire/Project/New/GithubPrivateRepository.php index dcd4b8c81..77b2b2dab 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepository.php @@ -38,7 +38,7 @@ class GithubPrivateRepository extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); $this->query = request()->query(); $this->repositories = $this->branches = collect(); $this->github_apps = GithubApp::private(); diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index afc0062a0..1bab8ce1f 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -50,10 +50,10 @@ class GithubPrivateRepositoryDeployKey extends Component public function mount() { - if (isDev()) { + if (is_dev()) { $this->repository_url = 'https://github.com/coollabsio/coolify-examples'; } - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); $this->query = request()->query(); $this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->where('id', '!=', 0)->get(); } diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index a610bf47b..7fd15cd34 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -45,11 +45,11 @@ class PublicGitRepository extends Component public function mount() { - if (isDev()) { + if (is_dev()) { $this->repository_url = 'https://github.com/coollabsio/coolify-examples'; $this->port = 3000; } - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); $this->query = request()->query(); } diff --git a/app/Http/Livewire/Project/New/Select.php b/app/Http/Livewire/Project/New/Select.php index e09862649..f95599154 100644 --- a/app/Http/Livewire/Project/New/Select.php +++ b/app/Http/Livewire/Project/New/Select.php @@ -17,7 +17,7 @@ class Select extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function set_type(string $type) diff --git a/app/Http/Livewire/Project/Shared/Danger.php b/app/Http/Livewire/Project/Shared/Danger.php index 3b5283ef2..911192a2a 100644 --- a/app/Http/Livewire/Project/Shared/Danger.php +++ b/app/Http/Livewire/Project/Shared/Danger.php @@ -14,7 +14,7 @@ class Danger extends Component public function mount() { $this->modalId = new Cuid2(7); - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function delete() diff --git a/app/Http/Livewire/Project/Shared/EnvironmentVariable/Add.php b/app/Http/Livewire/Project/Shared/EnvironmentVariable/Add.php index 783c52183..cf14a894e 100644 --- a/app/Http/Livewire/Project/Shared/EnvironmentVariable/Add.php +++ b/app/Http/Livewire/Project/Shared/EnvironmentVariable/Add.php @@ -26,7 +26,7 @@ class Add extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function submit() diff --git a/app/Http/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Http/Livewire/Project/Shared/EnvironmentVariable/Show.php index f17ac8893..f75a91b63 100644 --- a/app/Http/Livewire/Project/Shared/EnvironmentVariable/Show.php +++ b/app/Http/Livewire/Project/Shared/EnvironmentVariable/Show.php @@ -25,7 +25,7 @@ class Show extends Component public function mount() { $this->modalId = new Cuid2(7); - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function submit() diff --git a/app/Http/Livewire/Project/Shared/Storages/Add.php b/app/Http/Livewire/Project/Shared/Storages/Add.php index afd7b408b..e7831f1cb 100644 --- a/app/Http/Livewire/Project/Shared/Storages/Add.php +++ b/app/Http/Livewire/Project/Shared/Storages/Add.php @@ -25,7 +25,7 @@ class Add extends Component public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } public function submit() diff --git a/app/Http/Livewire/Server/PrivateKey.php b/app/Http/Livewire/Server/PrivateKey.php index 4f9a1e022..366aec85f 100644 --- a/app/Http/Livewire/Server/PrivateKey.php +++ b/app/Http/Livewire/Server/PrivateKey.php @@ -39,6 +39,6 @@ public function checkConnection() public function mount() { - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); } } diff --git a/app/Http/Livewire/Source/Github/Change.php b/app/Http/Livewire/Source/Github/Change.php index b85575cd5..e2be4e0ab 100644 --- a/app/Http/Livewire/Source/Github/Change.php +++ b/app/Http/Livewire/Source/Github/Change.php @@ -38,7 +38,7 @@ class Change extends Component public function mount() { $this->webhook_endpoint = $this->ipv4; - $this->parameters = getRouteParameters(); + $this->parameters = get_route_parameters(); $this->is_system_wide = $this->github_app->is_system_wide; } diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.php index 66a8add4e..d52533012 100644 --- a/app/Http/Livewire/Team/InviteLink.php +++ b/app/Http/Livewire/Team/InviteLink.php @@ -15,7 +15,7 @@ class InviteLink extends Component public function mount() { - $this->email = isDev() ? 'test3@example.com' : ''; + $this->email = is_dev() ? 'test3@example.com' : ''; } public function viaEmail() diff --git a/app/Http/Livewire/Team/Storage/Create.php b/app/Http/Livewire/Team/Storage/Create.php index 38aee59b5..3edf29c20 100644 --- a/app/Http/Livewire/Team/Storage/Create.php +++ b/app/Http/Livewire/Team/Storage/Create.php @@ -36,7 +36,7 @@ class Create extends Component public function mount() { - if (isDev()) { + if (is_dev()) { $this->name = 'Local MinIO'; $this->description = 'Local MinIO'; $this->key = 'minioadmin'; diff --git a/app/Http/Livewire/Upgrade.php b/app/Http/Livewire/Upgrade.php index e79c73fb7..f46e37ff7 100644 --- a/app/Http/Livewire/Upgrade.php +++ b/app/Http/Livewire/Upgrade.php @@ -18,7 +18,7 @@ public function checkUpdate() $this->latestVersion = get_latest_version_of_coolify(); $currentVersion = config('version'); version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false; - if (isDev()) { + if (is_dev()) { $this->isUpgradeAvailable = true; } $settings = InstanceSettings::get(); diff --git a/app/Http/Middleware/SubscriptionValid.php b/app/Http/Middleware/SubscriptionValid.php index e7fcdff3c..c63c6d823 100644 --- a/app/Http/Middleware/SubscriptionValid.php +++ b/app/Http/Middleware/SubscriptionValid.php @@ -12,7 +12,7 @@ class SubscriptionValid public function handle(Request $request, Closure $next): Response { if (auth()->user()) { - if (isCloud() && !isSubscribed()) { + if (is_cloud() && !isSubscribed()) { ray('SubscriptionValid Middleware'); $allowed_paths = [ diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php index 2c0a3fc06..52279c241 100644 --- a/app/Jobs/DockerCleanupJob.php +++ b/app/Jobs/DockerCleanupJob.php @@ -32,7 +32,7 @@ public function handle(): void try { $servers = Server::all(); foreach ($servers as $server) { - if (isDev()) { + if (is_dev()) { $docker_root_filesystem = "/"; } else { $docker_root_filesystem = instant_remote_process(['stat --printf=%m $(docker info --format "{{json .DockerRootDir}}" |sed \'s/"//g\')'], $server); diff --git a/bootstrap/helpers/contants.php b/bootstrap/helpers/contants.php new file mode 100644 index 000000000..3c4d7d290 --- /dev/null +++ b/bootstrap/helpers/contants.php @@ -0,0 +1,3 @@ +first(); + if (!$destination) { + throw new Exception('Destination not found'); + } + return StandalonePostgresql::create([ + 'name' => generate_database_name('postgresql'), + 'postgres_password' => \Illuminate\Support\Str::password(), + 'environment_id' => $environment_id, + 'destination_id' => $destination->id, + 'destination_type' => $destination->getMorphClass(), + ]); + +} diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php index 1ae747686..831d5fc0b 100644 --- a/bootstrap/helpers/proxy.php +++ b/bootstrap/helpers/proxy.php @@ -13,7 +13,7 @@ function get_proxy_path() function generate_default_proxy_configuration(Server $server) { $proxy_path = get_proxy_path(); - if (isDev()) { + if (is_dev()) { $proxy_path = config('coolify.dev_config_path') . '/' . $server->name . '/proxy'; } $networks = collect($server->standaloneDockers)->map(function ($docker) { @@ -85,7 +85,7 @@ function generate_default_proxy_configuration(Server $server) ], ], ]; - if (isDev()) { + if (is_dev()) { $config['services']['traefik']['command'][] = "--log.level=debug"; } return Yaml::dump($config, 4, 2); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 388d7f31c..fed4a418f 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -5,37 +5,45 @@ use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Route; use Illuminate\Support\Str; +use Nubs\RandomNameGenerator\All; use Visus\Cuid2\Cuid2; -function application_configuration_dir() :string { +function application_configuration_dir(): string +{ return '/data/coolify/applications'; } -function database_configuration_dir(): string { + +function database_configuration_dir(): string +{ return '/data/coolify/databases'; } -function backup_dir(): string { + +function backup_dir(): string +{ return '/data/coolify/backups'; } -function generate_readme_file(string $name, string $updated_at): string { - return "Resource name: {$name}\nLatest Deployment Date: {$updated_at}"; + +function generate_readme_file(string $name, string $updated_at): string +{ + return "Resource name: $name\nLatest Deployment Date: $updated_at"; } -function general_error_handler(\Throwable|null $err = null, $that = null, $isJson = false, $customErrorMessage = null) +function general_error_handler(Throwable|null $err = null, $that = null, $isJson = false, $customErrorMessage = null): mixed { try { - ray('ERROR OCCURED: ' . $err->getMessage()); + ray('ERROR OCCURRED: ' . $err->getMessage()); if ($err instanceof QueryException) { if ($err->errorInfo[0] === '23505') { - throw new \Exception($customErrorMessage ?? 'Duplicate entry found.', '23505'); + throw new Exception($customErrorMessage ?? 'Duplicate entry found.', '23505'); } else if (count($err->errorInfo) === 4) { - throw new \Exception($customErrorMessage ?? $err->errorInfo[3]); + throw new Exception($customErrorMessage ?? $err->errorInfo[3]); } else { - throw new \Exception($customErrorMessage ?? $err->errorInfo[2]); + throw new Exception($customErrorMessage ?? $err->errorInfo[2]); } } else { - throw new \Exception($customErrorMessage ?? $err->getMessage()); + throw new Exception($customErrorMessage ?? $err->getMessage()); } - } catch (\Throwable $error) { + } catch (Throwable $error) { if ($that) { return $that->emit('error', $customErrorMessage ?? $error->getMessage()); } elseif ($isJson) { @@ -46,51 +54,54 @@ function general_error_handler(\Throwable|null $err = null, $that = null, $isJso } else { ray($customErrorMessage); ray($error); + return $customErrorMessage ?? $error->getMessage(); } } } -function getRouteParameters() +function get_route_parameters(): array { return Route::current()->parameters(); } -function get_latest_version_of_coolify() +function get_latest_version_of_coolify(): string { try { $response = Http::get('https://cdn.coollabs.io/coolify/versions.json'); $versions = $response->json(); return data_get($versions, 'coolify.v4.version'); - } catch (\Throwable $th) { + } catch (Throwable $th) { //throw $th; ray($th->getMessage()); return '0.0.0'; } } -function generate_random_name() +function generate_random_name(): string { - $generator = \Nubs\RandomNameGenerator\All::create(); + $generator = All::create(); $cuid = new Cuid2(7); - return Str::kebab("{$generator->getName()}-{$cuid}"); + return Str::kebab("{$generator->getName()}-$cuid"); } -function generate_application_name(string $git_repository, string $git_branch) +function generate_application_name(string $git_repository, string $git_branch): string { $cuid = new Cuid2(7); - return Str::kebab("{$git_repository}:{$git_branch}-{$cuid}"); + return Str::kebab("$git_repository:$git_branch-$cuid"); } -function is_transactional_emails_active() +function is_transactional_emails_active(): bool { return data_get(InstanceSettings::get(), 'smtp_enabled'); } -function set_transanctional_email_settings() +function set_transanctional_email_settings(): void { $settings = InstanceSettings::get(); $password = data_get($settings, 'smtp_password'); - if ($password) $password = decrypt($password); + if (isset($password)) { + $password = decrypt($password); + } config()->set('mail.default', 'smtp'); config()->set('mail.mailers.smtp', [ @@ -105,16 +116,19 @@ function set_transanctional_email_settings() ]); } -function base_ip() +function base_ip(): string { - if (isDev()) { + if (is_dev()) { return "http://localhost"; } $settings = InstanceSettings::get(); - return "http://{$settings->public_ipv4}"; + return "http://$settings->public_ipv4"; } -function base_url(bool $withPort = true) +/** + * If fqdn is set, return it, otherwise return public ip. + */ +function base_url(bool $withPort = true): string { $settings = InstanceSettings::get(); if ($settings->fqdn) { @@ -123,31 +137,32 @@ function base_url(bool $withPort = true) $port = config('app.port'); if ($settings->public_ipv4) { if ($withPort) { - if (isDev()) { - return "http://localhost:{$port}"; + if (is_dev()) { + return "http://localhost:$port"; } - return "http://{$settings->public_ipv4}:{$port}"; + return "http://$settings->public_ipv4:$port"; } - if (isDev()) { + if (is_dev()) { return "http://localhost"; } - return "http://{$settings->public_ipv4}"; + return "http://$settings->public_ipv4"; } if ($settings->public_ipv6) { if ($withPort) { - return "http://{$settings->public_ipv6}:{$port}"; + return "http://$settings->public_ipv6:$port"; } - return "http://{$settings->public_ipv6}"; + return "http://$settings->public_ipv6"; } return url('/'); } -function isDev() +function is_dev(): bool { return config('app.env') === 'local'; } -function isCloud() +function is_cloud(): bool { return !config('coolify.self_hosted'); } + diff --git a/database/migrations/2023_08_09_154921_change_postgres_password_of_standalone_postgresqls.php b/database/migrations/2023_08_09_154921_change_postgres_password_of_standalone_postgresqls.php new file mode 100644 index 000000000..f062f962a --- /dev/null +++ b/database/migrations/2023_08_09_154921_change_postgres_password_of_standalone_postgresqls.php @@ -0,0 +1,21 @@ +text('postgres_password')->change(); + }); + } + + public function down(): void + { + Schema::table('standalone_postgresqls', function (Blueprint $table) { + $table->string('postgres_password')->change(); + }); + } +}; diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.php index 2ba3897d8..f99fab82e 100644 --- a/resources/views/components/applications/links.blade.php +++ b/resources/views/components/applications/links.blade.php @@ -25,7 +25,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove + d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"/> {{ $fqdn }} @@ -44,7 +44,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove + d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"/> PR{{ data_get($preview, 'pull_request_id') }} | {{ data_get($preview, 'fqdn') }} @@ -55,7 +55,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove @endif @if (data_get($application, 'ports_mappings_array')) @foreach ($application->ports_mappings_array as $port) - @if (isDev()) + @if (is_dev())
  • @@ -66,7 +66,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove + d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"/> Port {{ $port }} @@ -83,7 +83,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove + d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"/> Port {{ $port }} diff --git a/resources/views/components/settings/navbar.blade.php b/resources/views/components/settings/navbar.blade.php index 85d18f507..ea3dd6c49 100644 --- a/resources/views/components/settings/navbar.blade.php +++ b/resources/views/components/settings/navbar.blade.php @@ -10,7 +10,7 @@ href="{{ route('settings.emails') }}"> - @if (isCloud()) + @if (is_cloud()) diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 9ce1c2633..75a0b1e26 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -22,7 +22,7 @@
    {{ $s3s->count() }}
    - @if (isDev()) + @if (is_dev()) @endif diff --git a/resources/views/livewire/notifications/discord-settings.blade.php b/resources/views/livewire/notifications/discord-settings.blade.php index e9c69f585..9ec66ea1c 100644 --- a/resources/views/livewire/notifications/discord-settings.blade.php +++ b/resources/views/livewire/notifications/discord-settings.blade.php @@ -23,7 +23,7 @@ @if (data_get($model, 'discord_enabled'))

    Subscribe to events

    - @if (isDev()) + @if (is_dev()) @endif
    Applications
    diff --git a/resources/views/livewire/notifications/email-settings.blade.php b/resources/views/livewire/notifications/email-settings.blade.php index c819ee16b..09d0f5acb 100644 --- a/resources/views/livewire/notifications/email-settings.blade.php +++ b/resources/views/livewire/notifications/email-settings.blade.php @@ -60,7 +60,7 @@ class="text-white normal-case btn btn-xs no-animation btn-primary"> @if (data_get($model, 'smtp_enabled'))

    Subscribe to events

    - @if (isDev()) + @if (is_dev()) @endif
    Applications
    diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index eec027904..dfed018e3 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -87,7 +87,7 @@
    This will remove this server from Coolify. Beware! There is no coming back!
    - @if ($server->id !== 0 || isDev()) + @if ($server->id !== 0 || is_dev()) Delete diff --git a/resources/views/team/show.blade.php b/resources/views/team/show.blade.php index 9f7596bc5..e28e91295 100644 --- a/resources/views/team/show.blade.php +++ b/resources/views/team/show.blade.php @@ -1,7 +1,7 @@ - @if (isCloud()) + @if (is_cloud())

    Subscription

    @if (data_get(auth()->user()->currentTeam(), diff --git a/routes/webhooks.php b/routes/webhooks.php index eb698d8ff..eff2cb639 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -174,7 +174,7 @@ } }); -if (isCloud()) { +if (is_cloud()) { Route::post('/payments/events', function () { try { $secret = config('coolify.lemon_squeezy_webhook_secret'); diff --git a/versions.json b/versions.json index 04132c13c..25d09437e 100644 --- a/versions.json +++ b/versions.json @@ -1,10 +1,10 @@ { - "coolify": { - "main": { - "version": "3.12.33" - }, - "v4": { - "version": "4.0.0-beta.18" - } + "coolify": { + "main": { + "version": "3.12.36" + }, + "v4": { + "version": "4.0.0-beta.18" } -} \ No newline at end of file + } +}