Merge pull request #2812 from coollabsio/next

v4.0.0-beta.311
This commit is contained in:
Andras Bacsai 2024-07-12 14:15:15 +02:00 committed by GitHub
commit d4f4632461
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 168 additions and 154 deletions

View File

@ -27,7 +27,7 @@ public function __construct($userId = null)
public function broadcastOn(): ?array public function broadcastOn(): ?array
{ {
if ($this->userId) { if (! is_null($this->userId)) {
return [ return [
new PrivateChannel("user.{$this->userId}"), new PrivateChannel("user.{$this->userId}"),
]; ];

View File

@ -65,7 +65,7 @@ public function register(): void
if ($e instanceof RuntimeException) { if ($e instanceof RuntimeException) {
return; return;
} }
$this->settings = InstanceSettings::get(); $this->settings = view()->shared('instanceSettings');
if ($this->settings->do_not_track) { if ($this->settings->do_not_track) {
return; return;
} }

View File

@ -3,7 +3,6 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\InstanceSettings;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use OpenApi\Attributes as OA; use OpenApi\Attributes as OA;
@ -85,7 +84,7 @@ public function enable_api(Request $request)
if ($teamId !== '0') { if ($teamId !== '0') {
return response()->json(['message' => 'You are not allowed to enable the API.'], 403); return response()->json(['message' => 'You are not allowed to enable the API.'], 403);
} }
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$settings->update(['is_api_enabled' => true]); $settings->update(['is_api_enabled' => true]);
return response()->json(['message' => 'API enabled.'], 200); return response()->json(['message' => 'API enabled.'], 200);
@ -136,7 +135,7 @@ public function disable_api(Request $request)
if ($teamId !== '0') { if ($teamId !== '0') {
return response()->json(['message' => 'You are not allowed to disable the API.'], 403); return response()->json(['message' => 'You are not allowed to disable the API.'], 403);
} }
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$settings->update(['is_api_enabled' => false]); $settings->update(['is_api_enabled' => false]);
return response()->json(['message' => 'API disabled.'], 200); return response()->json(['message' => 'API disabled.'], 200);

View File

@ -4,7 +4,6 @@
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Application; use App\Models\Application;
use App\Models\InstanceSettings;
use App\Models\Project; use App\Models\Project;
use App\Models\Server as ModelsServer; use App\Models\Server as ModelsServer;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -301,7 +300,7 @@ public function domains_by_server(Request $request)
$projects = Project::where('team_id', $teamId)->get(); $projects = Project::where('team_id', $teamId)->get();
$domains = collect(); $domains = collect();
$applications = $projects->pluck('applications')->flatten(); $applications = $projects->pluck('applications')->flatten();
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if ($applications->count() > 0) { if ($applications->count() > 0) {
foreach ($applications as $application) { foreach ($applications as $application) {
$ip = $application->destination->server->ip; $ip = $application->destination->server->ip;

View File

@ -2,7 +2,6 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use App\Models\InstanceSettings;
use Closure; use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -15,7 +14,7 @@ public function handle(Request $request, Closure $next): Response
if (isCloud()) { if (isCloud()) {
return $next($request); return $next($request);
} }
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if ($settings->is_api_enabled === false) { if ($settings->is_api_enabled === false) {
return response()->json(['success' => true, 'message' => 'API is disabled.'], 403); return response()->json(['success' => true, 'message' => 'API is disabled.'], 403);
} }

View File

@ -2,7 +2,6 @@
namespace App\Jobs; namespace App\Jobs;
use App\Models\InstanceSettings;
use App\Models\Server; use App\Models\Server;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeEncrypted; use Illuminate\Contracts\Queue\ShouldBeEncrypted;
@ -36,7 +35,7 @@ public function handle(): void
$latest_version = get_latest_version_of_coolify(); $latest_version = get_latest_version_of_coolify();
instant_remote_process(["docker pull -q ghcr.io/coollabsio/coolify:{$latest_version}"], $server, false); instant_remote_process(["docker pull -q ghcr.io/coollabsio/coolify:{$latest_version}"], $server, false);
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$current_version = config('version'); $current_version = config('version');
if (! $settings->is_auto_update_enabled) { if (! $settings->is_auto_update_enabled) {
return; return;

View File

@ -2,7 +2,6 @@
namespace App\Livewire; namespace App\Livewire;
use App\Models\InstanceSettings;
use DanHarrin\LivewireRateLimiting\WithRateLimiting; use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
@ -48,7 +47,7 @@ public function submit()
] ]
); );
$mail->subject("[HELP]: {$this->subject}"); $mail->subject("[HELP]: {$this->subject}");
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$type = set_transanctional_email_settings($settings); $type = set_transanctional_email_settings($settings);
if (! $type) { if (! $type) {
$url = 'https://app.coolify.io/api/feedback'; $url = 'https://app.coolify.io/api/feedback';

View File

@ -2,7 +2,6 @@
namespace App\Livewire\Notifications; namespace App\Livewire\Notifications;
use App\Models\InstanceSettings;
use App\Models\Team; use App\Models\Team;
use App\Notifications\Test; use App\Notifications\Test;
use Livewire\Component; use Livewire\Component;
@ -173,7 +172,7 @@ public function submitResend()
public function copyFromInstanceSettings() public function copyFromInstanceSettings()
{ {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if ($settings->smtp_enabled) { if ($settings->smtp_enabled) {
$team = currentTeam(); $team = currentTeam();
$team->update([ $team->update([

View File

@ -3,32 +3,63 @@
namespace App\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use App\Models\Tag; use App\Models\Tag;
use Livewire\Attributes\Validate;
use Livewire\Component; use Livewire\Component;
// Refactored ✅
class Tags extends Component class Tags extends Component
{ {
public $resource = null; public $resource = null;
public ?string $new_tag = null; #[Validate('required|string|min:2')]
public string $newTags;
public $tags = []; public $tags = [];
protected $listeners = [ public $filteredTags = [];
'refresh' => '$refresh',
];
protected $rules = [
'resource.tags.*.name' => 'required|string|min:2',
'new_tag' => 'required|string|min:2',
];
protected $validationAttributes = [
'new_tag' => 'tag',
];
public function mount() public function mount()
{
$this->loadTags();
}
public function loadTags()
{ {
$this->tags = Tag::ownedByCurrentTeam()->get(); $this->tags = Tag::ownedByCurrentTeam()->get();
$this->filteredTags = $this->tags->filter(function ($tag) {
return ! $this->resource->tags->contains($tag);
});
}
public function submit()
{
try {
$this->validate();
$tags = str($this->newTags)->trim()->explode(' ');
foreach ($tags as $tag) {
if (strlen($tag) < 2) {
$this->dispatch('error', 'Invalid tag.', "Tag <span class='dark:text-warning'>$tag</span> is invalid. Min length is 2.");
continue;
}
if ($this->resource->tags()->where('name', $tag)->exists()) {
$this->dispatch('error', 'Duplicate tags.', "Tag <span class='dark:text-warning'>$tag</span> already added.");
continue;
}
$found = Tag::ownedByCurrentTeam()->where(['name' => $tag])->exists();
if (! $found) {
$found = Tag::create([
'name' => $tag,
'team_id' => currentTeam()->id,
]);
}
$this->resource->tags()->attach($found->id);
}
$this->refresh();
} catch (\Exception $e) {
return handleError($e, $this);
}
} }
public function addTag(string $id, string $name) public function addTag(string $id, string $name)
@ -39,8 +70,9 @@ public function addTag(string $id, string $name)
return; return;
} }
$this->resource->tags()->syncWithoutDetaching($id); $this->resource->tags()->attach($id);
$this->refresh(); $this->refresh();
$this->dispatch('success', 'Tag added.');
} catch (\Exception $e) { } catch (\Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -50,12 +82,12 @@ public function deleteTag(string $id)
{ {
try { try {
$this->resource->tags()->detach($id); $this->resource->tags()->detach($id);
$found_more_tags = Tag::ownedByCurrentTeam()->find($id);
$found_more_tags = Tag::where(['id' => $id, 'team_id' => currentTeam()->id])->first(); if ($found_more_tags && $found_more_tags->applications()->count() == 0 && $found_more_tags->services()->count() == 0) {
if ($found_more_tags->applications()->count() == 0 && $found_more_tags->services()->count() == 0) {
$found_more_tags->delete(); $found_more_tags->delete();
} }
$this->refresh(); $this->refresh();
$this->dispatch('success', 'Tag deleted.');
} catch (\Exception $e) { } catch (\Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@ -63,41 +95,8 @@ public function deleteTag(string $id)
public function refresh() public function refresh()
{ {
$this->resource->load(['tags']); $this->resource->refresh(); // Remove this when legacy_model_binding is false
$this->tags = Tag::ownedByCurrentTeam()->get(); $this->loadTags();
$this->new_tag = null; $this->reset('newTags');
}
public function submit()
{
try {
$this->validate([
'new_tag' => 'required|string|min:2',
]);
$tags = str($this->new_tag)->trim()->explode(' ');
foreach ($tags as $tag) {
if ($this->resource->tags()->where('name', $tag)->exists()) {
$this->dispatch('error', 'Duplicate tags.', "Tag <span class='dark:text-warning'>$tag</span> already added.");
continue;
}
$found = Tag::where(['name' => $tag, 'team_id' => currentTeam()->id])->first();
if (! $found) {
$found = Tag::create([
'name' => $tag,
'team_id' => currentTeam()->id,
]);
}
$this->resource->tags()->syncWithoutDetaching($found->id);
}
$this->refresh();
} catch (\Exception $e) {
return handleError($e, $this);
}
}
public function render()
{
return view('livewire.project.shared.tags');
} }
} }

View File

@ -4,49 +4,61 @@
use Livewire\Component; use Livewire\Component;
// Refactored ✅
class Webhooks extends Component class Webhooks extends Component
{ {
public $resource; public $resource;
public ?string $deploywebhook = null; public ?string $deploywebhook;
public ?string $githubManualWebhook = null; public ?string $githubManualWebhook;
public ?string $gitlabManualWebhook = null; public ?string $gitlabManualWebhook;
public ?string $bitbucketManualWebhook = null; public ?string $bitbucketManualWebhook;
public ?string $giteaManualWebhook = null; public ?string $giteaManualWebhook;
protected $rules = [ public ?string $githubManualWebhookSecret = null;
'resource.manual_webhook_secret_github' => 'nullable|string',
'resource.manual_webhook_secret_gitlab' => 'nullable|string',
'resource.manual_webhook_secret_bitbucket' => 'nullable|string',
'resource.manual_webhook_secret_gitea' => 'nullable|string',
];
public function saveSecret() public ?string $gitlabManualWebhookSecret = null;
public ?string $bitbucketManualWebhookSecret = null;
public ?string $giteaManualWebhookSecret = null;
public function mount()
{
// ray()->clearAll();
// ray()->showQueries();
$this->deploywebhook = generateDeployWebhook($this->resource);
$this->githubManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_github');
$this->githubManualWebhook = generateGitManualWebhook($this->resource, 'github');
$this->gitlabManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_gitlab');
$this->gitlabManualWebhook = generateGitManualWebhook($this->resource, 'gitlab');
$this->bitbucketManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_bitbucket');
$this->bitbucketManualWebhook = generateGitManualWebhook($this->resource, 'bitbucket');
$this->giteaManualWebhookSecret = data_get($this->resource, 'manual_webhook_secret_gitea');
$this->giteaManualWebhook = generateGitManualWebhook($this->resource, 'gitea');
}
public function submit()
{ {
try { try {
$this->validate(); $this->authorize('update', $this->resource);
$this->resource->save(); $this->resource->update([
'manual_webhook_secret_github' => $this->githubManualWebhookSecret,
'manual_webhook_secret_gitlab' => $this->gitlabManualWebhookSecret,
'manual_webhook_secret_bitbucket' => $this->bitbucketManualWebhookSecret,
'manual_webhook_secret_gitea' => $this->giteaManualWebhookSecret,
]);
$this->dispatch('success', 'Secret Saved.'); $this->dispatch('success', 'Secret Saved.');
} catch (\Exception $e) { } catch (\Exception $e) {
return handleError($e, $this); return handleError($e, $this);
} }
} }
public function mount()
{
$this->deploywebhook = generateDeployWebhook($this->resource);
$this->githubManualWebhook = generateGitManualWebhook($this->resource, 'github');
$this->gitlabManualWebhook = generateGitManualWebhook($this->resource, 'gitlab');
$this->bitbucketManualWebhook = generateGitManualWebhook($this->resource, 'bitbucket');
$this->giteaManualWebhook = generateGitManualWebhook($this->resource, 'gitea');
}
public function render()
{
return view('livewire.project.shared.webhooks');
}
} }

View File

@ -18,7 +18,7 @@ class Index extends Component
public function mount() public function mount()
{ {
if (isInstanceAdmin()) { if (isInstanceAdmin()) {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$database = StandalonePostgresql::whereName('coolify-db')->first(); $database = StandalonePostgresql::whereName('coolify-db')->first();
$s3s = S3Storage::whereTeamId(0)->get() ?? []; $s3s = S3Storage::whereTeamId(0)->get() ?? [];
if ($database) { if ($database) {

View File

@ -29,7 +29,7 @@ public function mount()
abort(404); abort(404);
} }
$this->instance_id = config('app.id'); $this->instance_id = config('app.id');
$this->settings = InstanceSettings::get(); $this->settings = view()->shared('instanceSettings');
} }
public function render() public function render()

View File

@ -4,7 +4,6 @@
use App\Jobs\GithubAppPermissionJob; use App\Jobs\GithubAppPermissionJob;
use App\Models\GithubApp; use App\Models\GithubApp;
use App\Models\InstanceSettings;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Livewire\Component; use Livewire\Component;
@ -100,7 +99,7 @@ public function mount()
return redirect()->route('source.all'); return redirect()->route('source.all');
} }
$this->applications = $this->github_app->applications; $this->applications = $this->github_app->applications;
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret'); $this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret');
$this->name = str($this->github_app->name)->kebab(); $this->name = str($this->github_app->name)->kebab();

View File

@ -23,7 +23,7 @@ public function mount()
if (data_get(currentTeam(), 'subscription') && isSubscriptionActive()) { if (data_get(currentTeam(), 'subscription') && isSubscriptionActive()) {
return redirect()->route('subscription.show'); return redirect()->route('subscription.show');
} }
$this->settings = InstanceSettings::get(); $this->settings = view()->shared('instanceSettings');
$this->alreadySubscribed = currentTeam()->subscription()->exists(); $this->alreadySubscribed = currentTeam()->subscription()->exists();
} }

View File

@ -318,7 +318,7 @@ public function setupDefault404Redirect()
public function setupDynamicProxyConfiguration() public function setupDynamicProxyConfiguration()
{ {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$dynamic_config_path = $this->proxyPath().'/dynamic'; $dynamic_config_path = $this->proxyPath().'/dynamic';
if ($this->proxyType() === 'TRAEFIK_V2') { if ($this->proxyType() === 'TRAEFIK_V2') {
$file = "$dynamic_config_path/coolify.yaml"; $file = "$dynamic_config_path/coolify.yaml";

View File

@ -2,7 +2,6 @@
namespace App\Notifications\Channels; namespace App\Notifications\Channels;
use App\Models\InstanceSettings;
use App\Models\User; use App\Models\User;
use Exception; use Exception;
use Illuminate\Mail\Message; use Illuminate\Mail\Message;
@ -14,7 +13,7 @@ class TransactionalEmailChannel
{ {
public function send(User $notifiable, Notification $notification): void public function send(User $notifiable, Notification $notification): void
{ {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if (! data_get($settings, 'smtp_enabled') && ! data_get($settings, 'resend_enabled')) { if (! data_get($settings, 'smtp_enabled') && ! data_get($settings, 'resend_enabled')) {
Log::info('SMTP/Resend not enabled'); Log::info('SMTP/Resend not enabled');

View File

@ -18,7 +18,7 @@ class ResetPassword extends Notification
public function __construct($token) public function __construct($token)
{ {
$this->settings = InstanceSettings::get(); $this->settings = view()->shared('instanceSettings');
$this->token = $token; $this->token = $token;
} }

View File

@ -2,8 +2,10 @@
namespace App\Providers; namespace App\Providers;
use App\Models\InstanceSettings;
use App\Models\PersonalAccessToken; use App\Models\PersonalAccessToken;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Laravel\Sanctum\Sanctum; use Laravel\Sanctum\Sanctum;
@ -14,6 +16,7 @@ public function register(): void {}
public function boot(): void public function boot(): void
{ {
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class); Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
Http::macro('github', function (string $api_url, ?string $github_access_token = null) { Http::macro('github', function (string $api_url, ?string $github_access_token = null) {
if ($github_access_token) { if ($github_access_token) {
return Http::withHeaders([ return Http::withHeaders([
@ -27,5 +30,9 @@ public function boot(): void
])->baseUrl($api_url); ])->baseUrl($api_url);
} }
}); });
if (! env('CI')) {
View::share('instanceSettings', InstanceSettings::get());
}
} }
} }

View File

@ -6,7 +6,6 @@
use App\Actions\Fortify\ResetUserPassword; use App\Actions\Fortify\ResetUserPassword;
use App\Actions\Fortify\UpdateUserPassword; use App\Actions\Fortify\UpdateUserPassword;
use App\Actions\Fortify\UpdateUserProfileInformation; use App\Actions\Fortify\UpdateUserProfileInformation;
use App\Models\InstanceSettings;
use App\Models\OauthSetting; use App\Models\OauthSetting;
use App\Models\User; use App\Models\User;
use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Cache\RateLimiting\Limit;
@ -45,7 +44,7 @@ public function boot(): void
{ {
Fortify::createUsersUsing(CreateNewUser::class); Fortify::createUsersUsing(CreateNewUser::class);
Fortify::registerView(function () { Fortify::registerView(function () {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if (! $settings->is_registration_enabled) { if (! $settings->is_registration_enabled) {
return redirect()->route('login'); return redirect()->route('login');
} }
@ -57,7 +56,7 @@ public function boot(): void
}); });
Fortify::loginView(function () { Fortify::loginView(function () {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$enabled_oauth_providers = OauthSetting::where('enabled', true)->get(); $enabled_oauth_providers = OauthSetting::where('enabled', true)->get();
$users = User::count(); $users = User::count();
if ($users == 0) { if ($users == 0) {

View File

@ -244,13 +244,13 @@ function generate_application_name(string $git_repository, string $git_branch, ?
function is_transactional_emails_active(): bool function is_transactional_emails_active(): bool
{ {
return isEmailEnabled(InstanceSettings::get()); return isEmailEnabled(view()->shared('instanceSettings'));
} }
function set_transanctional_email_settings(?InstanceSettings $settings = null): ?string function set_transanctional_email_settings(?InstanceSettings $settings = null): ?string
{ {
if (! $settings) { if (! $settings) {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
} }
config()->set('mail.from.address', data_get($settings, 'smtp_from_address')); config()->set('mail.from.address', data_get($settings, 'smtp_from_address'));
config()->set('mail.from.name', data_get($settings, 'smtp_from_name')); config()->set('mail.from.name', data_get($settings, 'smtp_from_name'));
@ -284,7 +284,7 @@ function base_ip(): string
if (isDev()) { if (isDev()) {
return 'localhost'; return 'localhost';
} }
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if ($settings->public_ipv4) { if ($settings->public_ipv4) {
return "$settings->public_ipv4"; return "$settings->public_ipv4";
} }
@ -312,7 +312,7 @@ function getFqdnWithoutPort(string $fqdn)
*/ */
function base_url(bool $withPort = true): string function base_url(bool $withPort = true): string
{ {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if ($settings->fqdn) { if ($settings->fqdn) {
return $settings->fqdn; return $settings->fqdn;
} }
@ -379,7 +379,7 @@ function send_internal_notification(string $message): void
} }
function send_user_an_email(MailMessage $mail, string $email, ?string $cc = null): void function send_user_an_email(MailMessage $mail, string $email, ?string $cc = null): void
{ {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$type = set_transanctional_email_settings($settings); $type = set_transanctional_email_settings($settings);
if (! $type) { if (! $type) {
throw new Exception('No email settings found.'); throw new Exception('No email settings found.');
@ -774,6 +774,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$allServices = get_service_templates(); $allServices = get_service_templates();
$topLevelVolumes = collect(data_get($yaml, 'volumes', [])); $topLevelVolumes = collect(data_get($yaml, 'volumes', []));
$topLevelNetworks = collect(data_get($yaml, 'networks', [])); $topLevelNetworks = collect(data_get($yaml, 'networks', []));
$topLevelConfigs = collect(data_get($yaml, 'configs', []));
$topLevelSecrets = collect(data_get($yaml, 'secrets', []));
$services = data_get($yaml, 'services'); $services = data_get($yaml, 'services');
$generatedServiceFQDNS = collect([]); $generatedServiceFQDNS = collect([]);
@ -1402,6 +1404,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'services' => $services->toArray(), 'services' => $services->toArray(),
'volumes' => $topLevelVolumes->toArray(), 'volumes' => $topLevelVolumes->toArray(),
'networks' => $topLevelNetworks->toArray(), 'networks' => $topLevelNetworks->toArray(),
'configs' => $topLevelConfigs->toArray(),
'secrets' => $topLevelSecrets->toArray(),
]; ];
$yaml = data_forget($yaml, 'services.*.volumes.*.content'); $yaml = data_forget($yaml, 'services.*.volumes.*.content');
$resource->docker_compose_raw = Yaml::dump($yaml, 10, 2); $resource->docker_compose_raw = Yaml::dump($yaml, 10, 2);
@ -1441,6 +1445,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
} }
$topLevelNetworks = collect(data_get($yaml, 'networks', [])); $topLevelNetworks = collect(data_get($yaml, 'networks', []));
$topLevelConfigs = collect(data_get($yaml, 'configs', []));
$topLevelSecrets = collect(data_get($yaml, 'secrets', []));
$services = data_get($yaml, 'services'); $services = data_get($yaml, 'services');
$generatedServiceFQDNS = collect([]); $generatedServiceFQDNS = collect([]);
@ -2086,6 +2092,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'services' => $services->toArray(), 'services' => $services->toArray(),
'volumes' => $topLevelVolumes->toArray(), 'volumes' => $topLevelVolumes->toArray(),
'networks' => $topLevelNetworks->toArray(), 'networks' => $topLevelNetworks->toArray(),
'configs' => $topLevelConfigs->toArray(),
'secrets' => $topLevelSecrets->toArray(),
]; ];
if ($isSameDockerComposeFile) { if ($isSameDockerComposeFile) {
$resource->docker_compose_raw = Yaml::dump($yaml, 10, 2); $resource->docker_compose_raw = Yaml::dump($yaml, 10, 2);
@ -2250,7 +2258,7 @@ function validate_dns_entry(string $fqdn, Server $server)
if (str($host)->contains('sslip.io')) { if (str($host)->contains('sslip.io')) {
return true; return true;
} }
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
$is_dns_validation_enabled = data_get($settings, 'is_dns_validation_enabled'); $is_dns_validation_enabled = data_get($settings, 'is_dns_validation_enabled');
if (! $is_dns_validation_enabled) { if (! $is_dns_validation_enabled) {
return true; return true;
@ -2370,7 +2378,7 @@ function checkIfDomainIsAlreadyUsed(Collection|array $domains, ?string $teamId =
if ($domainFound) { if ($domainFound) {
return true; return true;
} }
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if (data_get($settings, 'fqdn')) { if (data_get($settings, 'fqdn')) {
$domain = data_get($settings, 'fqdn'); $domain = data_get($settings, 'fqdn');
if (str($domain)->endsWith('/')) { if (str($domain)->endsWith('/')) {
@ -2442,7 +2450,7 @@ function check_domain_usage(ServiceApplication|Application|null $resource = null
} }
} }
if ($resource) { if ($resource) {
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if (data_get($settings, 'fqdn')) { if (data_get($settings, 'fqdn')) {
$domain = data_get($settings, 'fqdn'); $domain = data_get($settings, 'fqdn');
if (str($domain)->endsWith('/')) { if (str($domain)->endsWith('/')) {
@ -2517,7 +2525,7 @@ function get_public_ips()
{ {
try { try {
echo "Refreshing public ips!\n"; echo "Refreshing public ips!\n";
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
[$first, $second] = Process::concurrently(function (Pool $pool) { [$first, $second] = Process::concurrently(function (Pool $pool) {
$pool->path(__DIR__)->command('curl -4s https://ifconfig.io'); $pool->path(__DIR__)->command('curl -4s https://ifconfig.io');
$pool->path(__DIR__)->command('curl -6s https://ifconfig.io'); $pool->path(__DIR__)->command('curl -6s https://ifconfig.io');

View File

@ -7,7 +7,7 @@
// The release version of your application // The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
'release' => '4.0.0-beta.310', 'release' => '4.0.0-beta.311',
// When left empty or `null` the Laravel environment will be used // When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'), 'environment' => config('app.env'),

View File

@ -1,3 +1,3 @@
<?php <?php
return '4.0.0-beta.310'; return '4.0.0-beta.311';

View File

@ -27,14 +27,14 @@ public function run(): void
$ipv4 = Process::run('curl -4s https://ifconfig.io')->output(); $ipv4 = Process::run('curl -4s https://ifconfig.io')->output();
$ipv4 = trim($ipv4); $ipv4 = trim($ipv4);
$ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP); $ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP);
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if (is_null($settings->public_ipv4) && $ipv4) { if (is_null($settings->public_ipv4) && $ipv4) {
$settings->update(['public_ipv4' => $ipv4]); $settings->update(['public_ipv4' => $ipv4]);
} }
$ipv6 = Process::run('curl -6s https://ifconfig.io')->output(); $ipv6 = Process::run('curl -6s https://ifconfig.io')->output();
$ipv6 = trim($ipv6); $ipv6 = trim($ipv6);
$ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP); $ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP);
$settings = InstanceSettings::get(); $settings = view()->shared('instanceSettings');
if (is_null($settings->public_ipv6) && $ipv6) { if (is_null($settings->public_ipv6) && $ipv6) {
$settings->update(['public_ipv6' => $ipv6]); $settings->update(['public_ipv6' => $ipv6]);
} }

View File

@ -17,6 +17,7 @@ ARG TARGETPLATFORM
# https://github.com/cloudflare/cloudflared/releases # https://github.com/cloudflare/cloudflared/releases
ARG CLOUDFLARED_VERSION=2024.4.1 ARG CLOUDFLARED_VERSION=2024.4.1
ARG POSTGRES_VERSION=15 ARG POSTGRES_VERSION=15
ARG CI=true
WORKDIR /var/www/html WORKDIR /var/www/html

View File

@ -8,7 +8,7 @@
@use('App\Models\InstanceSettings') @use('App\Models\InstanceSettings')
@php @php
$instanceSettings = InstanceSettings::first(); $instanceSettings = view()->shared('instanceSettings');
$name = null; $name = null;
if ($instanceSettings) { if ($instanceSettings) {

View File

@ -109,7 +109,7 @@
<livewire:project.service.storage :resource="$application" /> <livewire:project.service.storage :resource="$application" />
</div> </div>
<div x-cloak x-show="activeTab === 'webhooks'"> <div x-cloak x-show="activeTab === 'webhooks'">
<livewire:project.shared.webhooks :resource="$application" /> <livewire:project.shared.webhooks :resource="$application" lazy />
</div> </div>
<div x-cloak x-show="activeTab === 'previews'"> <div x-cloak x-show="activeTab === 'previews'">
<livewire:project.application.previews :application="$application" /> <livewire:project.application.previews :application="$application" />
@ -133,7 +133,7 @@
<livewire:project.shared.metrics :resource="$application" /> <livewire:project.shared.metrics :resource="$application" />
</div> </div>
<div x-cloak x-show="activeTab === 'tags'"> <div x-cloak x-show="activeTab === 'tags'">
<livewire:project.shared.tags :resource="$application" /> <livewire:project.shared.tags :resource="$application" lazy />
</div> </div>
<div x-cloak x-show="activeTab === 'danger'"> <div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$application" /> <livewire:project.shared.danger :resource="$application" />

View File

@ -99,7 +99,7 @@
<livewire:project.shared.metrics :resource="$database" /> <livewire:project.shared.metrics :resource="$database" />
</div> </div>
<div x-cloak x-show="activeTab === 'tags'"> <div x-cloak x-show="activeTab === 'tags'">
<livewire:project.shared.tags :resource="$database" /> <livewire:project.shared.tags :resource="$database" lazy />
</div> </div>
<div x-cloak x-show="activeTab === 'danger'"> <div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$database" /> <livewire:project.shared.danger :resource="$database" />

View File

@ -1,5 +1,5 @@
<x-forms.select wire:model.live="selectedEnvironment"> <x-forms.select wire:model.live="selectedEnvironment">
<option value="edit">Create/Edit Environments</option> <option value="edit">Create / Edit</option>
<option disabled>-----</option> <option disabled>-----</option>
@foreach ($environments as $environment) @foreach ($environments as $environment)
<option value="{{ $environment->name }}">{{ $environment->name }} <option value="{{ $environment->name }}">{{ $environment->name }}

View File

@ -13,7 +13,7 @@
it.</div> it.</div>
@else @else
@if (!str($resource->status)->contains('running')) @if (!str($resource->status)->contains('running'))
<div class="alert alert-warning">Metrics are only available when the application is running!</div> <div class="alert alert-warning">Metrics are only available when this resource is running!</div>
@else @else
<x-forms.select label="Interval" wire:change="setInterval" id="interval"> <x-forms.select label="Interval" wire:change="setInterval" id="interval">
<option value="5">5 minutes (live)</option> <option value="5">5 minutes (live)</option>

View File

@ -1,10 +1,18 @@
<div> <div>
<h2>Tags</h2> <h2>Tags</h2>
<div class="flex flex-wrap gap-2 pt-4"> <form wire:submit='submit' class="flex items-end gap-2">
@if (data_get($this->resource, 'tags')) <div class="w-64">
@forelse (data_get($this->resource,'tags') as $tagId => $tag) <x-forms.input label="Create new or assign existing tags"
<div helper="You add more at once with space separated list: web api something<br><br>If the tag does not exists, it will be created."
class="px-2 py-1 text-center rounded select-none dark:text-white w-fit bg-neutral-200 hover:bg-neutral-300 dark:bg-coolgray-100 dark:hover:bg-coolgray-200"> wire:model="newTags" placeholder="example: prod app1 user" />
</div>
<x-forms.button type="submit">Add</x-forms.button>
</form>
@if (data_get($this->resource, 'tags') && count(data_get($this->resource, 'tags')) > 0)
<h3 class="pt-4">Assigned Tags</h3>
<div class="flex flex-wrap gap-2 pt-4">
@foreach (data_get($this->resource, 'tags') as $tagId => $tag)
<div class="button">
{{ $tag->name }} {{ $tag->name }}
<svg wire:click="deleteTag('{{ $tag->id }}')" xmlns="http://www.w3.org/2000/svg" fill="none" <svg wire:click="deleteTag('{{ $tag->id }}')" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@ -13,24 +21,14 @@ class="inline-block w-3 h-3 rounded cursor-pointer stroke-current hover:bg-red-5
</path> </path>
</svg> </svg>
</div> </div>
@empty @endforeach
<div class="py-1">No tags yet</div>
@endforelse
@endif
</div>
<form wire:submit='submit' class="flex items-end gap-2 pt-4">
<div class="w-64">
<x-forms.input label="Create new or assign existing tags"
helper="You add more at once with space separated list: web api something<br><br>If the tag does not exists, it will be created."
wire:model="new_tag" />
</div> </div>
<x-forms.button type="submit">Add</x-forms.button> @endif
</form> @if (count($filteredTags) > 0)
@if (count($tags) > 0)
<h3 class="pt-4">Exisiting Tags</h3> <h3 class="pt-4">Exisiting Tags</h3>
<div>Click to add quickly</div> <div>Click to add quickly</div>
<div class="flex flex-wrap gap-2 pt-4"> <div class="flex flex-wrap gap-2 pt-4">
@foreach ($tags as $tag) @foreach ($filteredTags as $tag)
<x-forms.button wire:click="addTag('{{ $tag->id }}','{{ $tag->name }}')"> <x-forms.button wire:click="addTag('{{ $tag->id }}','{{ $tag->name }}')">
{{ $tag->name }}</x-forms.button> {{ $tag->name }}</x-forms.button>
@endforeach @endforeach

View File

@ -13,13 +13,13 @@
<div> <div>
<h3>Manual Git Webhooks</h3> <h3>Manual Git Webhooks</h3>
@if ($githubManualWebhook && $gitlabManualWebhook) @if ($githubManualWebhook && $gitlabManualWebhook)
<form wire:submit='saveSecret' class="flex flex-col gap-2"> <form wire:submit='submit' class="flex flex-col gap-2">
<div class="flex items-end gap-2"> <div class="flex items-end gap-2">
<x-forms.input helper="Content Type in GitHub configuration could be json or form-urlencoded." <x-forms.input helper="Content Type in GitHub configuration could be json or form-urlencoded."
readonly label="GitHub" id="githubManualWebhook"></x-forms.input> readonly label="GitHub" id="githubManualWebhook"></x-forms.input>
<x-forms.input type="password" <x-forms.input type="password"
helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitHub." helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitHub."
label="GitHub Webhook Secret" id="resource.manual_webhook_secret_github"></x-forms.input> label="GitHub Webhook Secret" id="githubManualWebhookSecret"></x-forms.input>
</div> </div>
<a target="_blank" class="flex hover:no-underline" href="{{ $resource?->gitWebhook }}"> <a target="_blank" class="flex hover:no-underline" href="{{ $resource?->gitWebhook }}">
@ -31,21 +31,19 @@
<x-forms.input readonly label="GitLab" id="gitlabManualWebhook"></x-forms.input> <x-forms.input readonly label="GitLab" id="gitlabManualWebhook"></x-forms.input>
<x-forms.input type="password" <x-forms.input type="password"
helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitLab." helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitLab."
label="GitLab Webhook Secret" id="resource.manual_webhook_secret_gitlab"></x-forms.input> label="GitLab Webhook Secret" id="gitlabManualWebhookSecret"></x-forms.input>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<x-forms.input readonly label="Bitbucket" id="bitbucketManualWebhook"></x-forms.input> <x-forms.input readonly label="Bitbucket" id="bitbucketManualWebhook"></x-forms.input>
<x-forms.input type="password" <x-forms.input type="password"
helper="Need to set a secret to be able to use this webhook. It should match with the secret in Bitbucket." helper="Need to set a secret to be able to use this webhook. It should match with the secret in Bitbucket."
label="Bitbucket Webhook Secret" label="Bitbucket Webhook Secret" id="bitbucketManualWebhookSecret"></x-forms.input>
id="resource.manual_webhook_secret_bitbucket"></x-forms.input>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<x-forms.input readonly label="Gitea" id="giteaManualWebhook"></x-forms.input> <x-forms.input readonly label="Gitea" id="giteaManualWebhook"></x-forms.input>
<x-forms.input type="password" <x-forms.input type="password"
helper="Need to set a secret to be able to use this webhook. It should match with the secret in Gitea." helper="Need to set a secret to be able to use this webhook. It should match with the secret in Gitea."
label="Gitea Webhook Secret" label="Gitea Webhook Secret" id="giteaManualWebhookSecret"></x-forms.input>
id="resource.manual_webhook_secret_gitea"></x-forms.input>
</div> </div>
<x-forms.button type="submit">Save</x-forms.button> <x-forms.button type="submit">Save</x-forms.button>
</form> </form>

View File

@ -1,7 +1,7 @@
{ {
"coolify": { "coolify": {
"v4": { "v4": {
"version": "4.0.0-beta.310" "version": "4.0.0-beta.311"
} }
} }
} }