diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index 0952e1bd8..b232e303b 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -27,3 +27,5 @@ You can ask for guidance anytime on our You can login your Coolify instance at `localhost:8000` with `test@example.com` and `password`. Your horizon (Laravel scheduler): `localhost:8000/horizon` - Only reachable if you logged in with root user. + +Mails are caught by Mailpit: `localhost:8025` diff --git a/app/Actions/Database/StartDatabaseProxy.php b/app/Actions/Database/StartDatabaseProxy.php index 922099b4c..eccdf1a6a 100644 --- a/app/Actions/Database/StartDatabaseProxy.php +++ b/app/Actions/Database/StartDatabaseProxy.php @@ -87,7 +87,7 @@ class StartDatabaseProxy "echo '{$dockerfile_base64}' | base64 -d > $configuration_dir/Dockerfile", "echo '{$nginxconf_base64}' | base64 -d > $configuration_dir/nginx.conf", "echo '{$dockercompose_base64}' | base64 -d > $configuration_dir/docker-compose.yaml", - "docker compose --project-directory {$configuration_dir} up --build -d >/dev/null", + "docker compose --project-directory {$configuration_dir} up --build -d", ], $database->destination->server); } } diff --git a/app/Actions/Proxy/CheckProxy.php b/app/Actions/Proxy/CheckProxy.php index 84dc4e955..279fac20e 100644 --- a/app/Actions/Proxy/CheckProxy.php +++ b/app/Actions/Proxy/CheckProxy.php @@ -2,41 +2,50 @@ namespace App\Actions\Proxy; -use App\Enums\ProxyTypes; use App\Models\Server; -use Illuminate\Support\Str; use Lorisleiva\Actions\Concerns\AsAction; -use Spatie\Activitylog\Models\Activity; class CheckProxy { use AsAction; - public function handle(Server $server) + public function handle(Server $server, $fromUI = false) { if (!$server->isProxyShouldRun()) { - throw new \Exception("Proxy should not run"); + if ($fromUI) { + throw new \Exception("Proxy should not run. You selected the Custom Proxy."); + } else { + return false; + } } $status = getContainerStatus($server, 'coolify-proxy'); if ($status === 'running') { $server->proxy->set('status', 'running'); $server->save(); - return 'OK'; + return false; } $ip = $server->ip; if ($server->id === 0) { $ip = 'host.docker.internal'; } - $connection = @fsockopen($ip, '80'); - $connection = @fsockopen($ip, '443'); - $port80 = is_resource($connection) && fclose($connection); - $port443 = is_resource($connection) && fclose($connection); - ray($ip); + $connection80 = @fsockopen($ip, '80'); + $connection443 = @fsockopen($ip, '443'); + $port80 = is_resource($connection80) && fclose($connection80); + $port443 = is_resource($connection443) && fclose($connection443); if ($port80) { - throw new \Exception("Port 80 is in use.
You must stop the process using this port.
Docs: https://coolify.io/docs
Discord: https://coollabs.io/discord"); + if ($fromUI) { + throw new \Exception("Port 80 is in use.
You must stop the process using this port.
Docs: https://coolify.io/docs
Discord: https://coollabs.io/discord"); + } else { + return false; + } } if ($port443) { - throw new \Exception("Port 443 is in use.
You must stop the process using this port.
Docs: https://coolify.io/docs
Discord: https://coollabs.io/discord>"); + if ($fromUI) { + throw new \Exception("Port 443 is in use.
You must stop the process using this port.
Docs: https://coolify.io/docs
Discord: https://coollabs.io/discord"); + } else { + return false; + } } + return true; } } diff --git a/app/Actions/Proxy/StartProxy.php b/app/Actions/Proxy/StartProxy.php index 14b7fefb5..6a6738177 100644 --- a/app/Actions/Proxy/StartProxy.php +++ b/app/Actions/Proxy/StartProxy.php @@ -13,8 +13,6 @@ class StartProxy public function handle(Server $server, bool $async = true): string|Activity { try { - CheckProxy::run($server); - $proxyType = $server->proxyType(); $commands = collect([]); $proxy_path = get_proxy_path(); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 52bf06ed9..730cf4113 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -28,6 +28,7 @@ class Kernel extends ConsoleKernel // $this->check_scheduled_backups($schedule); $this->check_resources($schedule); $this->cleanup_servers($schedule); + $this->check_scheduled_backups($schedule); } else { $schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); diff --git a/app/Http/Livewire/Server/Proxy/Deploy.php b/app/Http/Livewire/Server/Proxy/Deploy.php index 39995e077..7e828b092 100644 --- a/app/Http/Livewire/Server/Proxy/Deploy.php +++ b/app/Http/Livewire/Server/Proxy/Deploy.php @@ -39,7 +39,7 @@ class Deploy extends Component public function checkProxy() { try { - CheckProxy::run($this->server); + CheckProxy::run($this->server, true); $this->emit('startProxyPolling'); $this->emit('proxyChecked'); } catch (\Throwable $e) { diff --git a/app/Http/Livewire/Server/Proxy/Status.php b/app/Http/Livewire/Server/Proxy/Status.php index 90deb1455..8df8f10cd 100644 --- a/app/Http/Livewire/Server/Proxy/Status.php +++ b/app/Http/Livewire/Server/Proxy/Status.php @@ -34,7 +34,7 @@ class Status extends Component } $this->numberOfPolls++; } - CheckProxy::run($this->server); + CheckProxy::run($this->server, true); $this->emit('proxyStatusUpdated'); if ($this->server->proxy->status === 'running') { $this->polling = false; diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index ff4228ac5..09e7c510d 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -73,6 +73,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private string $serverUser = 'root'; private string $serverUserHomeDir = '/root'; + private string $dockerConfigFileExists = 'NOK'; public $tries = 1; public function __construct(int $application_deployment_queue_id) @@ -165,6 +166,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted // Get user home directory $this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server); + ray("test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"); + $this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server); try { if ($this->application->dockerfile) { $this->deploy_simple_dockerfile(); @@ -455,7 +458,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $this->stop_running_container(); $this->execute_remote_command( ["echo -n 'Starting preview deployment.'"], - [executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up -d >/dev/null"), "hidden" => true], + [executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up -d"), "hidden" => true], ); } @@ -463,7 +466,11 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted { $pull = "--pull=always"; $helperImage = config('coolify.helper_image'); - $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; + if ($this->dockerConfigFileExists === 'OK') { + $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; + } else { + $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; + } $this->execute_remote_command( [ @@ -830,7 +837,6 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); ] ); } else { - ray("docker build $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"); $this->execute_remote_command([ executeInDocker($this->deployment_uuid, "docker build $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true ]); @@ -858,7 +864,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); { $this->execute_remote_command( ["echo -n 'Starting application (could take a while).'"], - [executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up --build -d >/dev/null"), "hidden" => true], + [executeInDocker($this->deployment_uuid, "docker compose --project-directory {$this->workdir} up --build -d"), "hidden" => true], ); } diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 4f379ec65..1c8cf1919 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Actions\Proxy\CheckProxy; use App\Actions\Proxy\StartProxy; use App\Models\ApplicationPreview; use App\Models\Server; @@ -117,10 +118,18 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted return data_get($value, 'Name') === '/coolify-proxy'; })->first(); if (!$foundProxyContainer) { - if ($this->server->isProxyShouldRun()) { - StartProxy::run($this->server, false); - $this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server)); + try { + $shouldStart = CheckProxy::run($this->server); + if ($shouldStart) { + StartProxy::run($this->server, false); + $this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server)); + } else { + ray('Proxy could not be started.'); + } + } catch (\Throwable $e) { + ray($e); } + } else { $this->server->proxy->status = data_get($foundProxyContainer, 'State.Status'); $this->server->save(); diff --git a/app/Models/Server.php b/app/Models/Server.php index fa8fdbe39..07f975c48 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -193,23 +193,24 @@ class Server extends BaseModel } public function isProxyShouldRun() { - $shouldRun = false; if ($this->proxyType() === ProxyTypes::NONE->value) { return false; } - foreach ($this->applications() as $application) { - if (data_get($application, 'fqdn')) { - $shouldRun = true; - break; - } - } - if ($this->id === 0) { - $settings = InstanceSettings::get(); - if (data_get($settings, 'fqdn')) { - $shouldRun = true; - } - } - return $shouldRun; + // foreach ($this->applications() as $application) { + // if (data_get($application, 'fqdn')) { + // $shouldRun = true; + // break; + // } + // } + // ray($this->services()->get()); + + // if ($this->id === 0) { + // $settings = InstanceSettings::get(); + // if (data_get($settings, 'fqdn')) { + // $shouldRun = true; + // } + // } + return true; } public function isFunctional() { diff --git a/config/sentry.php b/config/sentry.php index f0fda5f19..4a096757f 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // 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.88', + 'release' => '4.0.0-beta.92', // 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 8de2939a1..d889b7a6c 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ + Coolify @env('local') diff --git a/resources/views/livewire/project/service/application.blade.php b/resources/views/livewire/project/service/application.blade.php index bf3501496..df09da467 100644 --- a/resources/views/livewire/project/service/application.blade.php +++ b/resources/views/livewire/project/service/application.blade.php @@ -18,10 +18,10 @@
@if ($application->required_fqdn) + id="application.fqdn" helper="You can specify one domain with path or more with comma. You can specify a port to bind the domain to.

Example
- http://app.coolify.io, https://cloud.coolify.io/dashboard
- http://app.coolify.io/api/v3
- http://app.coolify.io:3000 -> app.coolify.io will point to port 3000 inside the container. "> @else + id="application.fqdn" helper="You can specify one domain with path or more with comma. You can specify a port to bind the domain to.

Example
- http://app.coolify.io, https://cloud.coolify.io/dashboard
- http://app.coolify.io/api/v3
- http://app.coolify.io:3000 -> app.coolify.io will point to port 3000 inside the container. "> @endif