diff --git a/.github/workflows/coolify-helper-next.yml b/.github/workflows/coolify-helper-next.yml index ef7f5b217..fe14ba759 100644 --- a/.github/workflows/coolify-helper-next.yml +++ b/.github/workflows/coolify-helper-next.yml @@ -4,7 +4,7 @@ on: push: branches: [ "next" ] paths: - - .github/workflows/coolify-helper.yml + - .github/workflows/coolify-helper-next.yml - docker/coolify-helper/Dockerfile env: diff --git a/app/Console/Commands/SyncBunny.php b/app/Console/Commands/SyncBunny.php index 1be47ba8a..a64da5a35 100644 --- a/app/Console/Commands/SyncBunny.php +++ b/app/Console/Commands/SyncBunny.php @@ -16,7 +16,7 @@ class SyncBunny extends Command * * @var string */ - protected $signature = 'sync:bunny {--only-template}'; + protected $signature = 'sync:bunny {--only-template} {--only-version}'; /** * The console command description. @@ -30,7 +30,9 @@ class SyncBunny extends Command */ public function handle() { + $that = $this; $only_template = $this->option('only-template'); + $only_version = $this->option('only-version'); $bunny_cdn = "https://cdn.coollabs.io"; $bunny_cdn_path = "coolify"; $bunny_cdn_storage_name = "coolcdn"; @@ -46,7 +48,7 @@ class SyncBunny extends Command $versions = "versions.json"; - PendingRequest::macro('storage', function ($file) { + PendingRequest::macro('storage', function ($file) use($that) { $headers = [ 'AccessKey' => env('BUNNY_STORAGE_API_KEY'), 'Accept' => 'application/json', @@ -54,21 +56,22 @@ class SyncBunny extends Command ]; $fileStream = fopen($file, "r"); $file = fread($fileStream, filesize($file)); + $that->info('Uploading: ' . $file); return PendingRequest::baseUrl('https://storage.bunnycdn.com')->withHeaders($headers)->withBody($file)->throw(); }); - PendingRequest::macro('purge', function ($url) { + PendingRequest::macro('purge', function ($url) use ($that) { $headers = [ 'AccessKey' => env('BUNNY_API_KEY'), 'Accept' => 'application/json', ]; - ray('Purging: ' . $url); + $that->info('Purging: ' . $url); return PendingRequest::withHeaders($headers)->get('https://api.bunny.net/purge', [ "url" => $url, "async" => false ]); }); try { - $confirmed = confirm('Are you sure?'); + $confirmed = confirm('Are you sure you want to sync?'); if (!$confirmed) { return; } @@ -80,23 +83,28 @@ class SyncBunny extends Command $this->info('Service template uploaded & purged...'); return; } + if ($only_version) { + Http::pool(fn (Pool $pool) => [ + $pool->storage(fileName: "$parent_dir/$versions")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$versions"), + $pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"), + ]); + $this->info('versions.json uploaded & purged...'); + return; + } Http::pool(fn (Pool $pool) => [ - $pool->storage(file: "$parent_dir/$compose_file")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file"), - $pool->storage(file: "$parent_dir/$compose_file_prod")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file_prod"), - $pool->storage(file: "$parent_dir/$production_env")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$production_env"), - $pool->storage(file: "$parent_dir/scripts/$upgrade_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$upgrade_script"), - $pool->storage(file: "$parent_dir/scripts/$install_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$install_script"), - $pool->storage(file: "$parent_dir/$versions")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$versions"), + $pool->storage(fileName: "$parent_dir/$compose_file")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file"), + $pool->storage(fileName: "$parent_dir/$compose_file_prod")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file_prod"), + $pool->storage(fileName: "$parent_dir/$production_env")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$production_env"), + $pool->storage(fileName: "$parent_dir/scripts/$upgrade_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$upgrade_script"), + $pool->storage(fileName: "$parent_dir/scripts/$install_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$install_script"), ]); - $this->info("{$bunny_cdn}/{$bunny_cdn_path}"); Http::pool(fn (Pool $pool) => [ $pool->purge("$bunny_cdn/$bunny_cdn_path/$compose_file"), $pool->purge("$bunny_cdn/$bunny_cdn_path/$compose_file_prod"), $pool->purge("$bunny_cdn/$bunny_cdn_path/$production_env"), $pool->purge("$bunny_cdn/$bunny_cdn_path/$upgrade_script"), $pool->purge("$bunny_cdn/$bunny_cdn_path/$install_script"), - $pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"), ]); $this->info("All files uploaded & purged..."); } catch (\Throwable $e) { diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 48bf7909e..0e4c0e2c7 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -45,10 +45,10 @@ class ProjectController extends Controller public function new() { - $services = Cache::get('services', []); + $services = getServiceTemplates(); $type = Str::of(request()->query('type')); $destination_uuid = request()->query('destination'); - $server_id = request()->query('server'); + $server_id = request()->query('server_id'); $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { @@ -66,9 +66,10 @@ class ProjectController extends Controller 'database_uuid' => $standalone_postgresql->uuid, ]); } - if ($type->startsWith('one-click-service-')) { + if ($type->startsWith('one-click-service-') && !is_null( (int)$server_id)) { $oneClickServiceName = $type->after('one-click-service-')->value(); $oneClickService = data_get($services, "$oneClickServiceName.compose"); + ray($oneClickServiceName); $oneClickDotEnvs = data_get($services, "$oneClickServiceName.envs", null); if ($oneClickDotEnvs) { $oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/'); diff --git a/app/Http/Livewire/Boarding/Index.php b/app/Http/Livewire/Boarding/Index.php index c1ec202cf..d124e6a89 100644 --- a/app/Http/Livewire/Boarding/Index.php +++ b/app/Http/Livewire/Boarding/Index.php @@ -129,6 +129,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== public function selectExistingPrivateKey() { $this->createdPrivateKey = PrivateKey::find($this->selectedExistingPrivateKey); + $this->privateKey = $this->createdPrivateKey->private_key; $this->currentState = 'create-server'; } public function createNewServer() diff --git a/app/Http/Livewire/Project/New/Select.php b/app/Http/Livewire/Project/New/Select.php index 945c646df..4a40c6b35 100644 --- a/app/Http/Livewire/Project/New/Select.php +++ b/app/Http/Livewire/Project/New/Select.php @@ -60,28 +60,9 @@ class Select extends Component if ($forceReload) { Cache::forget('services'); } - if (isDev()) { - $cached = Cache::remember('services', 3600, function () { - $services = File::get(base_path('templates/service-templates.json')); - $services = collect(json_decode($services))->sortKeys(); - $this->emit('success', 'Successfully reloaded services from filesystem (development mode).'); - return $services; - }); - } else { - $cached = Cache::remember('services', 3600, function () { - $services = Http::get(config('constants.services.official')); - if ($services->failed()) { - throw new \Exception($services->body()); - } - - $services = collect($services->json())->sortKeys(); - $this->emit('success', 'Successfully reloaded services from the internet.'); - return $services; - }); - } - $this->services = $cached; + $this->services = getServiceTemplates(); + $this->emit('success', 'Successfully loaded services.'); } catch (\Throwable $e) { - ray($e); return handleError($e, $this); } finally { $this->loadingServices = false; diff --git a/app/Http/Livewire/Project/Service/Show.php b/app/Http/Livewire/Project/Service/Show.php index 7a9e62df2..656adff0a 100644 --- a/app/Http/Livewire/Project/Service/Show.php +++ b/app/Http/Livewire/Project/Service/Show.php @@ -11,8 +11,8 @@ use Livewire\Component; class Show extends Component { public Service $service; - public ServiceApplication $serviceApplication; - public ServiceDatabase $serviceDatabase; + public ?ServiceApplication $serviceApplication = null; + public ?ServiceDatabase $serviceDatabase = null; public array $parameters; public array $query; public Collection $services; diff --git a/app/Http/Livewire/Server/ShowPrivateKey.php b/app/Http/Livewire/Server/ShowPrivateKey.php index a0aa6e1e2..c9c11becb 100644 --- a/app/Http/Livewire/Server/ShowPrivateKey.php +++ b/app/Http/Livewire/Server/ShowPrivateKey.php @@ -14,8 +14,8 @@ class ShowPrivateKey extends Component public function setPrivateKey($newPrivateKeyId) { try { - refresh_server_connection($this->server->privateKey); $oldPrivateKeyId = $this->server->private_key_id; + refresh_server_connection($this->server->privateKey); $this->server->update([ 'private_key_id' => $newPrivateKeyId ]); diff --git a/app/Http/Livewire/Settings/Configuration.php b/app/Http/Livewire/Settings/Configuration.php index 6f5fd3475..668c3d5c4 100644 --- a/app/Http/Livewire/Settings/Configuration.php +++ b/app/Http/Livewire/Settings/Configuration.php @@ -73,7 +73,7 @@ class Configuration extends Component { $file = "$this->dynamic_config_path/coolify.yaml"; if (empty($this->settings->fqdn)) { - remote_process([ + instant_remote_process([ "rm -f $file", ], $this->server); } else { @@ -129,7 +129,6 @@ class Configuration extends Component ]; } $this->save_configuration_to_disk($traefik_dynamic_conf, $file); - dispatch(new ContainerStatusJob($this->server)); } } @@ -142,7 +141,7 @@ class Configuration extends Component $yaml; $base64 = base64_encode($yaml); - remote_process([ + instant_remote_process([ "mkdir -p $this->dynamic_config_path", "echo '$base64' | base64 -d > $file", ], $this->server); diff --git a/app/Models/Application.php b/app/Models/Application.php index 1cdfdea29..b08561ef7 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -212,13 +212,9 @@ class Application extends BaseModel { if (data_get($this, 'private_key_id')) { return 'deploy_key'; - } - if (data_get($this, 'source')) { + } else if (data_get($this, 'source')) { return 'source'; } - if (data_get($this, 'private_key_id')) { - return 'deploy_key'; - } throw new \Exception('No deployment type found'); } public function could_set_build_commands(): bool diff --git a/app/Models/Environment.php b/app/Models/Environment.php index 470ad5e6c..624787ba6 100644 --- a/app/Models/Environment.php +++ b/app/Models/Environment.php @@ -14,7 +14,7 @@ class Environment extends Model public function can_delete_environment() { - return $this->applications()->count() == 0 && $this->postgresqls()->count() == 0; + return $this->applications()->count() == 0 && $this->postgresqls()->count() == 0 && $this->services()->count() == 0; } public function applications() diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 946fa198f..5c19b408d 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -406,3 +406,18 @@ function sslip(Server $server) } return "{$server->ip}.sslip.io"; } + +function getServiceTemplates() +{ + if (isDev()) { + $services = File::get(base_path('templates/service-templates.json')); + $services = collect(json_decode($services))->sortKeys(); + } else { + $services = Http::get(config('constants.services.official')); + if ($services->failed()) { + throw new \Exception($services->body()); + } + $services = collect($services->json())->sortKeys(); + } + return $services; +} diff --git a/config/sentry.php b/config/sentry.php index 592553a39..16e57890d 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.46', + 'release' => '4.0.0-beta.47', // 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 548f25cb6..67a77dc1f 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ -
General configuration for your Coolify instance.
+
General configuration for your Coolify instance.
diff --git a/scripts/install.sh b/scripts/install.sh index e7d7b02b7..c6f702c9b 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -72,14 +72,21 @@ cat >/etc/docker/daemon.json.coolify </etc/docker/daemon.json.coolify cat <<<$(jq -s '.[0] * .[1]' /etc/docker/daemon.json /etc/docker/daemon.json.coolify) >/etc/docker/daemon.json -DIFF=$(diff <(jq --sort-keys . /etc/docker/daemon.json) <(jq --sort-keys . /etc/docker/daemon.json.original-$DATE)) -if [ "$DIFF" != "" ]; then + +if [ -s /etc/docker/daemon.json.original-$DATE ]; then + DIFF=$(diff <(jq --sort-keys . /etc/docker/daemon.json) <(jq --sort-keys . /etc/docker/daemon.json.original-$DATE)) + if [ "$DIFF" != "" ]; then + echo "Docker configuration updated, restart docker daemon..." + systemctl restart docker + else + echo "Docker configuration is up to date." + fi +else echo "Docker configuration updated, restart docker daemon..." systemctl restart docker -else - echo "Docker configuration is up to date." fi + echo -e "-------------" mkdir -p /data/coolify/ssh/keys diff --git a/versions.json b/versions.json index ad86896f4..0e8e37b21 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.46" + "version": "4.0.0-beta.47" } } }