diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index 1234dd231..7c1036b55 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -16,7 +16,7 @@ class UpdateCoolify try { ray('Running InstanceAutoUpdateJob'); $localhost_name = 'localhost'; - if (config('app.env') === 'local') { + if (isDev()) { $localhost_name = 'testing-local-docker-container'; } $this->server = Server::where('name', $localhost_name)->firstOrFail(); @@ -48,7 +48,7 @@ class UpdateCoolify } private function update() { - if (config('app.env') === 'local') { + if (isDev()) { ray('Running update on local docker container'); remote_process([ "sleep 10" diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 095a4c42c..d8d5dabd5 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -12,7 +12,7 @@ class Kernel extends ConsoleKernel { protected function schedule(Schedule $schedule): void { - if (config('app.env') === 'local') { + if (isDev()) { $schedule->command('horizon:snapshot')->everyMinute(); // $schedule->job(new InstanceDockerCleanupJob)->everyMinute(); // $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute(); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 72fe1db9f..3fc20bd25 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -47,7 +47,7 @@ class Handler extends ExceptionHandler { $this->reportable(function (Throwable $e) { $this->settings = InstanceSettings::get(); - if ($this->settings->do_not_track || config('app.env') === 'local') { + if ($this->settings->do_not_track || isDev()) { return; } Integration::captureUnhandledException($e); diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index 3fd4b6f0b..428d6d981 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -50,7 +50,7 @@ class GithubPrivateRepositoryDeployKey extends Component ]; public function mount() { - if (config('app.env') === 'local') { + if (isDev()) { $this->repository_url = 'https://github.com/coollabsio/coolify-examples'; } $this->parameters = getRouteParameters(); diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index 6f97bc10f..07c739201 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -39,7 +39,7 @@ class PublicGitRepository extends Component ]; public function mount() { - if (config('app.env') === 'local') { + if (isDev()) { $this->repository_url = 'https://github.com/coollabsio/coolify-examples'; $this->port = 3000; } diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.php index c57ed4b81..e80e5338b 100644 --- a/app/Http/Livewire/Team/InviteLink.php +++ b/app/Http/Livewire/Team/InviteLink.php @@ -14,7 +14,7 @@ class InviteLink extends Component public string $role = 'member'; public function mount() { - $this->email = config('app.env') === 'local' ? 'test3@example.com' : ''; + $this->email = isDev() ? 'test3@example.com' : ''; } public function viaEmail() { diff --git a/app/Http/Livewire/Upgrade.php b/app/Http/Livewire/Upgrade.php index 2c57b3ff4..bd9cf43d1 100644 --- a/app/Http/Livewire/Upgrade.php +++ b/app/Http/Livewire/Upgrade.php @@ -16,7 +16,7 @@ class Upgrade extends Component $latestVersion = get_latest_version_of_coolify(); $currentVersion = config('version'); version_compare($currentVersion, $latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false; - if (config('app.env') === 'local') { + if (isDev()) { $this->isUpgradeAvailable = true; } } diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php index 788d85455..f9fc68d3f 100644 --- a/bootstrap/helpers/proxy.php +++ b/bootstrap/helpers/proxy.php @@ -7,7 +7,7 @@ if (!function_exists('getProxyConfiguration')) { function getProxyConfiguration(Server $server) { $proxy_path = config('coolify.proxy_config_path'); - if (config('app.env') === 'local') { + if (isDev()) { $proxy_path = $proxy_path . '/testing-host-1/'; } $networks = collect($server->standaloneDockers)->map(function ($docker) { @@ -77,7 +77,7 @@ if (!function_exists('getProxyConfiguration')) { ], ], ]; - if (config('app.env') === 'local') { + if (isDev()) { $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 d23e66d11..b4b6ce0af 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -82,7 +82,7 @@ function set_transanctional_email_settings() ]); } -function base_url() +function base_url(bool $withPort = true) { $settings = InstanceSettings::get(); if ($settings->fqdn) { @@ -90,10 +90,27 @@ function base_url() } $port = config('app.port'); if ($settings->public_ipv4) { - return "http://{$settings->public_ipv4}:{$port}"; + if ($withPort) { + if (isDev()) { + return "http://localhost:{$port}"; + } + return "http://{$settings->public_ipv4}:{$port}"; + } + if (isDev()) { + return "http://localhost"; + } + return "http://{$settings->public_ipv4}"; } if ($settings->public_ipv6) { - return "http://{$settings->public_ipv6}:{$port}"; + if ($withPort) { + return "http://{$settings->public_ipv6}:{$port}"; + } + return "http://{$settings->public_ipv6}"; } return url('/'); } + +function isDev() +{ + return config('app.env') === 'local'; +} diff --git a/config/version.php b/config/version.php index 7f44e7615..1e9458f22 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ ports_mappings_array as $port) - @if (config('app.env') === 'local') + @if (isDev())