From 4feb99cbe00c4dccf07ba1507b31cbf0364274ad Mon Sep 17 00:00:00 2001 From: Silas Krause Date: Wed, 1 Nov 2023 21:52:08 +0100 Subject: [PATCH 01/16] Check if docker installation was successful --- scripts/install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 0d759681a..f25e62890 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -46,7 +46,11 @@ apt install -y curl wget git jq jc >/dev/null 2>&1 if ! [ -x "$(command -v docker)" ]; then echo "Docker is not installed. Installing Docker..." curl https://releases.rancher.com/install-docker/${DOCKER_VERSION}.sh | sh - echo "Docker installed successfully" + if [ -x "$(command -v docker)" ]; then + echo "Docker installed successfully." + else + echo "Docker installation failed." + exit 1 fi echo -e "-------------" echo -e "Check Docker Configuration..." From 8ae18f49dc9469ef35b97a321722152cf3d52698 Mon Sep 17 00:00:00 2001 From: Silas Krause Date: Wed, 1 Nov 2023 22:13:25 +0100 Subject: [PATCH 02/16] Add missing `fi` --- scripts/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install.sh b/scripts/install.sh index f25e62890..e98f34166 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -51,6 +51,7 @@ if ! [ -x "$(command -v docker)" ]; then else echo "Docker installation failed." exit 1 + fi fi echo -e "-------------" echo -e "Check Docker Configuration..." From 5cec50efbe1e682554f6ea63a1fce17103117607 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 6 Nov 2023 21:14:32 +0100 Subject: [PATCH 03/16] update install script --- scripts/install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index e98f34166..26ada577f 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -5,7 +5,7 @@ ## Always run "php artisan app:sync-to-bunny-cdn --env=secrets" or "scripts/run sync-bunny" if you update this file. ########### -VERSION="1.0.2" +VERSION="1.0.3" DOCKER_VERSION="24.0" CDN="https://cdn.coollabs.io/coolify" @@ -50,6 +50,8 @@ if ! [ -x "$(command -v docker)" ]; then echo "Docker installed successfully." else echo "Docker installation failed." + echo "Maybe your OS is not supported." + echo "Please visit https://docs.docker.com/engine/install/ and install Docker manually to continue." exit 1 fi fi From ad7aa2eed61df7717519f70183cce4f23bf6a322 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 09:44:47 +0100 Subject: [PATCH 04/16] fix: github source view --- app/Http/Livewire/Source/Github/Change.php | 60 ++++- config/sentry.php | 2 +- config/version.php | 2 +- .../livewire/source/github/change.blade.php | 236 +++++++++--------- routes/web.php | 47 +--- versions.json | 2 +- 6 files changed, 174 insertions(+), 175 deletions(-) diff --git a/app/Http/Livewire/Source/Github/Change.php b/app/Http/Livewire/Source/Github/Change.php index d0b717730..c6d02635a 100644 --- a/app/Http/Livewire/Source/Github/Change.php +++ b/app/Http/Livewire/Source/Github/Change.php @@ -3,17 +3,18 @@ namespace App\Http\Livewire\Source\Github; use App\Models\GithubApp; +use App\Models\InstanceSettings; use Livewire\Component; class Change extends Component { public string $webhook_endpoint; - public string|null $ipv4; - public string|null $ipv6; - public string|null $fqdn; + public ?string $ipv4; + public ?string $ipv6; + public ?string $fqdn; - public bool|null $default_permissions = true; - public bool|null $preview_deployment_permissions = true; + public ?bool $default_permissions = true; + public ?bool $preview_deployment_permissions = true; public $parameters; public GithubApp $github_app; @@ -28,29 +29,68 @@ class Change extends Component 'github_app.custom_user' => 'required|string', 'github_app.custom_port' => 'required|int', 'github_app.app_id' => 'required|int', - 'github_app.installation_id' => 'nullable', - 'github_app.client_id' => 'nullable', - 'github_app.client_secret' => 'nullable', - 'github_app.webhook_secret' => 'nullable', + 'github_app.installation_id' => 'required|int', + 'github_app.client_id' => 'required|string', + 'github_app.client_secret' => 'required|string', + 'github_app.webhook_secret' => 'required|string', 'github_app.is_system_wide' => 'required|bool', ]; public function mount() { + $github_app_uuid = request()->github_app_uuid; + $this->github_app = GithubApp::where('uuid', $github_app_uuid)->first(); + if (!$this->github_app) { + return redirect()->route('source.all'); + } + $settings = InstanceSettings::get(); + $this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret'); + + $this->name = str($this->github_app->name)->kebab(); + $this->fqdn = $settings->fqdn; + + if ($settings->public_ipv4) { + $this->ipv4 = 'http://' . $settings->public_ipv4 . ':' . config('app.port'); + } + if ($settings->public_ipv6) { + $this->ipv6 = 'http://' . $settings->public_ipv6 . ':' . config('app.port'); + } + if ($this->github_app->installation_id && session('from')) { + $source_id = data_get(session('from'), 'source_id'); + if (!$source_id || $this->github_app->id !== $source_id) { + session()->forget('from'); + } else { + $parameters = data_get(session('from'), 'parameters'); + $back = data_get(session('from'), 'back'); + $environment_name = data_get($parameters, 'environment_name'); + $project_uuid = data_get($parameters, 'project_uuid'); + $type = data_get($parameters, 'type'); + $destination = data_get($parameters, 'destination'); + session()->forget('from'); + return redirect()->route($back, [ + 'environment_name' => $environment_name, + 'project_uuid' => $project_uuid, + 'type' => $type, + 'destination' => $destination, + ]); + } + } + $this->parameters = get_route_parameters(); if (isCloud() && !isDev()) { $this->webhook_endpoint = config('app.url'); } else { $this->webhook_endpoint = $this->ipv4; $this->is_system_wide = $this->github_app->is_system_wide; } - $this->parameters = get_route_parameters(); } public function submit() { try { + $this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret'); $this->validate(); $this->github_app->save(); + $this->emit('success', 'Github App updated successfully.'); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/config/sentry.php b/config/sentry.php index 8899bddd2..8ffa05932 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.111', + 'release' => '4.0.0-beta.112', // 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 f02cc33b3..b2220ad08 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ This source will be deleted. It is not reversible.
Please think again.

-
-
-

GitHub App

-
- @if ($github_app->app_id) - Save - + @if (data_get($github_app, 'app_id')) + +
+

GitHub App

+
@if (data_get($github_app, 'installation_id')) + Save - Update Repositories @endif - @else - Save - @endif - - Delete - + + Delete + +
-
-
Your Private GitHub App for private repositories.
- @if (data_get($github_app, 'app_id')) +
Your Private GitHub App for private repositories.
@if (!data_get($github_app, 'installation_id'))
You must complete this step before you can use this source!
- + Install Repositories on GitHub @else @@ -78,110 +72,118 @@
@endif - @else -
- - - - You must complete this step before you can use this source! + + @else +
+

GitHub App

+
+ + Delete +
-
-

Register a GitHub App

-
You need to register a GitHub App before using this source.
-
- @if (!isCloud() || isDev()) -
- - @if ($ipv4) - - @endif - @if ($ipv6) - - @endif - @if ($fqdn) - - @endif - @if (config('app.url')) - - @endif - - - Register - -
- @else +
+
+ + + + You must complete this step before you can use this source! +
+
+

Register a GitHub App

+
You need to register a GitHub App before using this source.
+
+ @if (!isCloud() || isDev()) +
+ + @if ($ipv4) + + @endif + @if ($ipv6) + + @endif + @if ($fqdn) + + @endif + @if (config('app.url')) + + @endif + - Register Now + Register - @endif -
- -
+ @else + + Register Now + + @endif +
+ +
- - - @endif - + const webhookBaseUrl = `${baseUrl}/webhooks`; + const path = organization ? `organizations/${organization}/settings/apps/new` : 'settings/apps/new'; + const default_permissions = { + contents: 'read', + metadata: 'read', + emails: 'read' + }; + if (preview_deployment_permissions) { + default_permissions.pull_requests = 'write'; + } + const data = { + name, + url: baseUrl, + hook_attributes: { + url: `${webhookBaseUrl}/source/github/events`, + active: true, + }, + redirect_url: `${webhookBaseUrl}/source/github/redirect`, + callback_urls: [`${baseUrl}/login/github/app`], + public: false, + request_oauth_on_install: false, + setup_url: `${webhookBaseUrl}/source/github/install?source=${uuid}`, + setup_on_update: true, + default_permissions, + default_events: ['pull_request', 'push'] + }; + const form = document.createElement('form'); + form.setAttribute('method', 'post'); + form.setAttribute('action', `${html_url}/${path}?state=${uuid}`); + const input = document.createElement('input'); + input.setAttribute('id', 'manifest'); + input.setAttribute('name', 'manifest'); + input.setAttribute('type', 'hidden'); + input.setAttribute('value', JSON.stringify(data)); + form.appendChild(input); + document.getElementsByTagName('body')[0].appendChild(form); + form.submit(); + } + + @endif
diff --git a/routes/web.php b/routes/web.php index 83e119aee..54226ca89 100644 --- a/routes/web.php +++ b/routes/web.php @@ -20,11 +20,10 @@ use App\Http\Livewire\Server\PrivateKey\Show as PrivateKeyShow; use App\Http\Livewire\Server\Proxy\Show as ProxyShow; use App\Http\Livewire\Server\Proxy\Logs as ProxyLogs; use App\Http\Livewire\Server\Show; +use App\Http\Livewire\Source\Github\Change as GitHubChange; use App\Http\Livewire\Subscription\Show as SubscriptionShow; use App\Http\Livewire\Waitlist\Index as WaitlistIndex; -use App\Models\GithubApp; use App\Models\GitlabApp; -use App\Models\InstanceSettings; use App\Models\PrivateKey; use App\Models\Server; use App\Models\StandaloneDocker; @@ -178,49 +177,7 @@ Route::middleware(['auth'])->group(function () { 'sources' => $sources, ]); })->name('source.all'); - Route::get('/source/github/{github_app_uuid}', function (Request $request) { - $github_app = GithubApp::where('uuid', request()->github_app_uuid)->first(); - if (!$github_app) { - abort(404); - } - $github_app->makeVisible('client_secret')->makeVisible('webhook_secret'); - $settings = InstanceSettings::get(); - $name = Str::of(Str::kebab($github_app->name)); - if ($settings->public_ipv4) { - $ipv4 = 'http://' . $settings->public_ipv4 . ':' . config('app.port'); - } - if ($settings->public_ipv6) { - $ipv6 = 'http://' . $settings->public_ipv6 . ':' . config('app.port'); - } - if ($github_app->installation_id && session('from')) { - $source_id = data_get(session('from'), 'source_id'); - if (!$source_id || $github_app->id !== $source_id) { - session()->forget('from'); - } else { - $parameters = data_get(session('from'), 'parameters'); - $back = data_get(session('from'), 'back'); - $environment_name = data_get($parameters, 'environment_name'); - $project_uuid = data_get($parameters, 'project_uuid'); - $type = data_get($parameters, 'type'); - $destination = data_get($parameters, 'destination'); - session()->forget('from'); - return redirect()->route($back, [ - 'environment_name' => $environment_name, - 'project_uuid' => $project_uuid, - 'type' => $type, - 'destination' => $destination, - ]); - } - } - return view('source.github.show', [ - 'github_app' => $github_app, - 'name' => $name, - 'ipv4' => $ipv4 ?? null, - 'ipv6' => $ipv6 ?? null, - 'fqdn' => $settings->fqdn, - ]); - })->name('source.github.show'); - + Route::get('/source/github/{github_app_uuid}', GitHubChange::class)->name('source.github.show'); Route::get('/source/gitlab/{gitlab_app_uuid}', function (Request $request) { $gitlab_app = GitlabApp::where('uuid', request()->gitlab_app_uuid)->first(); return view('source.gitlab.show', [ diff --git a/versions.json b/versions.json index 4ebbef973..cff2caaf6 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.111" + "version": "4.0.0-beta.112" } } } From d77c55148bf664eb2e2e1bc24bbf2da430234bbe Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 09:47:25 +0100 Subject: [PATCH 05/16] fix: github source view --- app/Http/Livewire/Source/Github/Change.php | 1 + resources/views/livewire/source/github/change.blade.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/Source/Github/Change.php b/app/Http/Livewire/Source/Github/Change.php index c6d02635a..c9ef89c02 100644 --- a/app/Http/Livewire/Source/Github/Change.php +++ b/app/Http/Livewire/Source/Github/Change.php @@ -98,6 +98,7 @@ class Change extends Component public function instantSave() { + $this->submit(); } public function delete() diff --git a/resources/views/livewire/source/github/change.blade.php b/resources/views/livewire/source/github/change.blade.php index 4548f2a05..1501685ca 100644 --- a/resources/views/livewire/source/github/change.blade.php +++ b/resources/views/livewire/source/github/change.blade.php @@ -41,7 +41,7 @@
+ instantSave id="github_app.is_system_wide" />
@endif
From 7377e9e4155f9cc4b0fb65568ba46419c5c87986 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 09:51:48 +0100 Subject: [PATCH 06/16] fix: dockercleanupjob should be released back --- app/Jobs/DockerCleanupJob.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php index 411a0f464..0813c1218 100644 --- a/app/Jobs/DockerCleanupJob.php +++ b/app/Jobs/DockerCleanupJob.php @@ -2,7 +2,6 @@ namespace App\Jobs; -use App\Models\ApplicationDeploymentQueue; use App\Models\Server; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeEncrypted; @@ -22,7 +21,7 @@ class DockerCleanupJob implements ShouldQueue, ShouldBeEncrypted public function middleware(): array { - return [(new WithoutOverlapping($this->server->uuid))->dontRelease()]; + return [(new WithoutOverlapping($this->server->uuid))]; } public function uniqueId(): string From 2976c72e0900d69cedea10ce3cb22cfa91446c54 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 10:18:28 +0100 Subject: [PATCH 07/16] fix: ui --- app/Http/Livewire/Project/Service/Navbar.php | 8 ++++++-- resources/views/components/services/navbar.blade.php | 4 ++-- resources/views/livewire/project/service/index.blade.php | 2 +- templates/compose/gitea-with-mariadb.yaml | 6 +++--- templates/compose/gitea-with-mysql.yaml | 6 +++--- templates/compose/gitea-with-postgresql.yaml | 6 +++--- templates/compose/gitea.yaml | 2 ++ templates/service-templates.json | 8 ++++---- 8 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/Http/Livewire/Project/Service/Navbar.php b/app/Http/Livewire/Project/Service/Navbar.php index 23ad062a5..1953605e6 100644 --- a/app/Http/Livewire/Project/Service/Navbar.php +++ b/app/Http/Livewire/Project/Service/Navbar.php @@ -27,11 +27,15 @@ class Navbar extends Component $activity = StartService::run($this->service); $this->emit('newMonitorActivity', $activity->id); } - public function stop() + public function stop(bool $forceCleanup = false) { StopService::run($this->service); $this->service->refresh(); - $this->emit('success', 'Service stopped successfully.'); + if ($forceCleanup) { + $this->emit('success', 'Force cleanup service successfully.'); + } else { + $this->emit('success', 'Service stopped successfully.'); + } $this->emit('checkStatus'); } } diff --git a/resources/views/components/services/navbar.blade.php b/resources/views/components/services/navbar.blade.php index 43e16c3df..1d0cf03a5 100644 --- a/resources/views/components/services/navbar.blade.php +++ b/resources/views/components/services/navbar.blade.php @@ -38,13 +38,13 @@ @endif @if (serviceStatus($service) === 'exited') - General + @click.prevent="activeTab = 'general'; window.location.hash = 'general'; if(window.location.search) window.location.search = ''" + href="#">General Storages + @click.prevent="activeTab = 'storages'; window.location.hash = 'storages'; if(window.location.search) window.location.search = ''" + href="#">Storages + Backups @if (data_get($parameters, 'service_name')) @@ -43,8 +47,15 @@
Persistent storage to preserve data between deployments.
Please modify storage layout in your Docker Compose file. - + +
+
+
+

Scheduled Backups

+ + Add +
+ +
@endisset
From a0bb5733e6723e4d0ca766f3f6843cd18cb46184 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 12:30:37 +0100 Subject: [PATCH 09/16] lol n8n with umami db name --- templates/compose/n8n-with-postgresql.yaml | 4 ++-- templates/service-templates.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/compose/n8n-with-postgresql.yaml b/templates/compose/n8n-with-postgresql.yaml index cd96c294d..98248427c 100644 --- a/templates/compose/n8n-with-postgresql.yaml +++ b/templates/compose/n8n-with-postgresql.yaml @@ -12,7 +12,7 @@ services: - GENERIC_TIMEZONE="Europe/Berlin" - TZ="Europe/Berlin" - DB_TYPE=postgresdb - - DB_POSTGRESDB_DATABASE=${POSTGRES_DB:-umami} + - DB_POSTGRESDB_DATABASE=${POSTGRES_DB:-n8n} - DB_POSTGRESDB_HOST=postgresql - DB_POSTGRESDB_PORT=5432 - DB_POSTGRESDB_USER=$SERVICE_USER_POSTGRES @@ -29,7 +29,7 @@ services: environment: - POSTGRES_USER=$SERVICE_USER_POSTGRES - POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES - - POSTGRES_DB=${POSTGRES_DB:-umami} + - POSTGRES_DB=${POSTGRES_DB:-n8n} healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 5s diff --git a/templates/service-templates.json b/templates/service-templates.json index 715979147..88f2d5ef8 100644 --- a/templates/service-templates.json +++ b/templates/service-templates.json @@ -309,7 +309,7 @@ "n8n-with-postgresql": { "documentation": "https:\/\/docs.n8n.io\/hosting\/", "slogan": "n8n is an extendable workflow automation tool which enables you to connect anything to everything via its open, fair-code model.", - "compose": "c2VydmljZXM6CiAgbjhuOgogICAgaW1hZ2U6IGRvY2tlci5uOG4uaW8vbjhuaW8vbjhuCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fTjhOCiAgICAgIC0gJ044Tl9FRElUT1JfQkFTRV9VUkw9JHtTRVJWSUNFX0ZRRE5fTjhOfScKICAgICAgLSAnTjhOX0hPU1Q9JHtTRVJWSUNFX0ZRRE5fTjhOfScKICAgICAgLSAnR0VORVJJQ19USU1FWk9ORT0iRXVyb3BlL0JlcmxpbiInCiAgICAgIC0gJ1RaPSJFdXJvcGUvQmVybGluIicKICAgICAgLSBEQl9UWVBFPXBvc3RncmVzZGIKICAgICAgLSAnREJfUE9TVEdSRVNEQl9EQVRBQkFTRT0ke1BPU1RHUkVTX0RCOi11bWFtaX0nCiAgICAgIC0gREJfUE9TVEdSRVNEQl9IT1NUPXBvc3RncmVzcWwKICAgICAgLSBEQl9QT1NUR1JFU0RCX1BPUlQ9NTQzMgogICAgICAtIERCX1BPU1RHUkVTREJfVVNFUj0kU0VSVklDRV9VU0VSX1BPU1RHUkVTCiAgICAgIC0gREJfUE9TVEdSRVNEQl9TQ0hFTUE9cHVibGljCiAgICAgIC0gREJfUE9TVEdSRVNEQl9QQVNTV09SRD0kU0VSVklDRV9QQVNTV09SRF9QT1NUR1JFUwogICAgdm9sdW1lczoKICAgICAgLSAnbjhuLWRhdGE6L2hvbWUvbm9kZS8ubjhuJwogIC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HUkVTREJfSE9TVD1wb3N0Z3Jlc3FsCiAgICAgIC0gREJfUE9TVEdSRVNEQl9QT1JUPTU0MzIKICAgICAgLSBEQl9QT1NUR1JFU0RCX1VTRVI9JFNFUlZJQ0VfVVNFUl9QT1NUR1JFUwogICAgICAtIERCX1BPU1RHUkVTREJfU0NIRU1BPXB1YmxpYwogICAgICAtIERCX1BPU1RHUkVTREJfUEFTU1dPUkQ9JFNFUlZJQ0VfUEFTU1dPUkRfUE9TVEdSRVMKICAgIHZvbHVtZXM6CiAgICAgIC0gJ244bi1kYXRhOi9ob21lL25vZGUvLm44bicKICAgIGRlcGVuZHNfb246CiAgICAgIC0gcG9zdGdyZXNxbAogIHBvc3RncmVzcWw6CiAgICBpbWFnZTogJ3Bvc3RncmVzOjE1LWFscGluZScKICAgIHZvbHVtZXM6CiAgICAgIC0gJ3Bvc3RncmVzcWwtZGF0YTovdmFyL2xpYi9wb3N0Z3Jlc3FsL2RhdGEnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBQT1NUR1JFU19VU0VSPSRTRVJWSUNFX1VTRVJfUE9TVEdSRVMKICAgICAgLSBQT1NUR1JFU19QQVNTV09SRD0kU0VSVklDRV9QQVNTV09SRF9QT1NUR1JFUwogICAgICAtICdQT1NUR1JFU19EQj0ke1BPU1RHUkVTX0RCOi1uOG59JwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtICdwZ19pc3JlYWR5IC1VICQke1BPU1RHUkVTX1VTRVJ9IC1kICQke1BPU1RHUkVTX0RCfScKICAgICAgaW50ZXJ2YWw6IDVzCiAgICAgIHRpbWVvdXQ6IDIwcwogICAgICByZXRyaWVzOiAxMAo=", "tags": [ "n8n", "workflow", From 56a977c6763ea5d29c16fce6a1f75b618f40300b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 12:50:18 +0100 Subject: [PATCH 10/16] update n8n --- templates/compose/n8n-with-postgresql.yaml | 3 ++- templates/compose/n8n.yaml | 3 ++- templates/service-templates.json | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/compose/n8n-with-postgresql.yaml b/templates/compose/n8n-with-postgresql.yaml index 98248427c..ef9208b02 100644 --- a/templates/compose/n8n-with-postgresql.yaml +++ b/templates/compose/n8n-with-postgresql.yaml @@ -8,7 +8,8 @@ services: environment: - SERVICE_FQDN_N8N - N8N_EDITOR_BASE_URL=${SERVICE_FQDN_N8N} - - N8N_HOST=${SERVICE_FQDN_N8N} + - WEBHOOK_URL=${SERVICE_FQDN_N8N} + - N8N_HOST=${SERVICE_URL_N8N} - GENERIC_TIMEZONE="Europe/Berlin" - TZ="Europe/Berlin" - DB_TYPE=postgresdb diff --git a/templates/compose/n8n.yaml b/templates/compose/n8n.yaml index c8613cf03..99a795cf8 100644 --- a/templates/compose/n8n.yaml +++ b/templates/compose/n8n.yaml @@ -8,7 +8,8 @@ services: environment: - SERVICE_FQDN_N8N - N8N_EDITOR_BASE_URL=${SERVICE_FQDN_N8N} - - N8N_HOST=${SERVICE_FQDN_N8N} + - WEBHOOK_URL=${SERVICE_FQDN_N8N} + - N8N_HOST=${SERVICE_URL_N8N} - GENERIC_TIMEZONE="Europe/Berlin" - TZ="Europe/Berlin" volumes: diff --git a/templates/service-templates.json b/templates/service-templates.json index 88f2d5ef8..53add41cd 100644 --- a/templates/service-templates.json +++ b/templates/service-templates.json @@ -309,7 +309,7 @@ "n8n-with-postgresql": { "documentation": "https:\/\/docs.n8n.io\/hosting\/", "slogan": "n8n is an extendable workflow automation tool which enables you to connect anything to everything via its open, fair-code model.", - "compose": "c2VydmljZXM6CiAgbjhuOgogICAgaW1hZ2U6IGRvY2tlci5uOG4uaW8vbjhuaW8vbjhuCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fTjhOCiAgICAgIC0gJ044Tl9FRElUT1JfQkFTRV9VUkw9JHtTRVJWSUNFX0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XM6MTUtYWxwaW5lJwogICAgdm9sdW1lczoKICAgICAgLSAncG9zdGdyZXNxbC1kYXRhOi92YXIvbGliL3Bvc3RncmVzcWwvZGF0YScKICAgIGVudmlyb25tZW50OgogICAgICAtIFBPU1RHUkVTX1VTRVI9JFNFUlZJQ0VfVVNFUl9QT1NUR1JFUwogICAgICAtIFBPU1RHUkVTX1BBU1NXT1JEPSRTRVJWSUNFX1BBU1NXT1JEX1BPU1RHUkVTCiAgICAgIC0gJ1BPU1RHUkVTX0RCPSR7UE9TVEdSRVNfREI6LW44bn0nCiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRC1TSEVMTAogICAgICAgIC0gJ3BnX2lzcmVhZHkgLVUgJCR7UE9TVEdSRVNfVVNFUn0gLWQgJCR7UE9TVEdSRVNfREJ9JwogICAgICBpbnRlcnZhbDogNXMKICAgICAgdGltZW91dDogMjBzCiAgICAgIHJldHJpZXM6IDEwCg==", "tags": [ "n8n", "workflow", @@ -323,7 +323,7 @@ "n8n": { "documentation": "https:\/\/docs.n8n.io\/hosting\/", "slogan": "n8n is an extendable workflow automation tool which enables you to connect anything to everything via its open, fair-code model.", - "compose": "c2VydmljZXM6CiAgbjhuOgogICAgaW1hZ2U6IGRvY2tlci5uOG4uaW8vbjhuaW8vbjhuCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fTjhOCiAgICAgIC0gJ044Tl9FRElUT1JfQkFTRV9VUkw9JHtTRVJWSUNFX0ZRRE5fTjhOfScKICAgICAgLSAnTjhOX0hPU1Q9JHtTRVJWSUNFX0ZRRE5fTjhOfScKICAgICAgLSAnR0VORVJJQ19USU1FWk9ORT0iRXVyb3BlL0JlcmxpbiInCiAgICAgIC0gJ1RaPSJFdXJvcGUvQmVybGluIicKICAgIHZvbHVtZXM6CiAgICAgIC0gJ244bi1kYXRhOi9ob21lL25vZGUvLm44bicK", + "compose": "c2VydmljZXM6CiAgbjhuOgogICAgaW1hZ2U6IGRvY2tlci5uOG4uaW8vbjhuaW8vbjhuCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fTjhOCiAgICAgIC0gJ044Tl9FRElUT1JfQkFTRV9VUkw9JHtTRVJWSUNFX0ZRRE5fTjhOfScKICAgICAgLSAnV0VCSE9PS19VUkw9JHtTRVJWSUNFX0ZRRE5fTjhOfScKICAgICAgLSAnTjhOX0hPU1Q9JHtTRVJWSUNFX1VSTF9OOE59JwogICAgICAtICdHRU5FUklDX1RJTUVaT05FPSJFdXJvcGUvQmVybGluIicKICAgICAgLSAnVFo9IkV1cm9wZS9CZXJsaW4iJwogICAgdm9sdW1lczoKICAgICAgLSAnbjhuLWRhdGE6L2hvbWUvbm9kZS8ubjhuJwo=", "tags": [ "n8n", "workflow", From 74830b12f31fd16847fb3a1ca0499745b2e2c519 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 13:28:10 +0100 Subject: [PATCH 11/16] Fix Docker network creation command in StartService.php --- app/Actions/Service/StartService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Actions/Service/StartService.php b/app/Actions/Service/StartService.php index 965162037..aa4c65886 100644 --- a/app/Actions/Service/StartService.php +++ b/app/Actions/Service/StartService.php @@ -16,7 +16,7 @@ class StartService $commands[] = "cd " . $service->workdir(); $commands[] = "echo '####### Saved configuration files to {$service->workdir()}.'"; $commands[] = "echo '####### Creating Docker network.'"; - $commands[] = "docker network create --attachable {$service->uuid} >/dev/null 2>/dev/null || true"; + $commands[] = "docker network create --attachable '{$service->uuid}' >/dev/null || true"; $commands[] = "echo '####### Starting service {$service->name} on {$service->server->name}.'"; $commands[] = "echo '####### Pulling images.'"; $commands[] = "docker compose pull"; From e1bc2cc406e33f65611aac823d7d7b45f62bb182 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 13:28:48 +0100 Subject: [PATCH 12/16] Fix docker network connection issue in StartService.php --- app/Actions/Service/StartService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Actions/Service/StartService.php b/app/Actions/Service/StartService.php index aa4c65886..1cdc4826d 100644 --- a/app/Actions/Service/StartService.php +++ b/app/Actions/Service/StartService.php @@ -22,11 +22,11 @@ class StartService $commands[] = "docker compose pull"; $commands[] = "echo '####### Starting containers.'"; $commands[] = "docker compose up -d --remove-orphans --force-recreate"; - $commands[] = "docker network connect $service->uuid coolify-proxy 2>/dev/null || true"; + $commands[] = "docker network connect $service->uuid coolify-proxy || true"; $compose = data_get($service,'docker_compose',[]); $serviceNames = data_get(Yaml::parse($compose),'services',[]); foreach($serviceNames as $serviceName => $serviceConfig){ - $commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} 2>/dev/null || true"; + $commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} || true"; } $activity = remote_process($commands, $service->server); return $activity; From b01f6ac4145954aeb009bb99d541302f546c435f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 13:29:05 +0100 Subject: [PATCH 13/16] Fix docker network connection in StartService.php --- app/Actions/Service/StartService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Actions/Service/StartService.php b/app/Actions/Service/StartService.php index 1cdc4826d..74bdd81cb 100644 --- a/app/Actions/Service/StartService.php +++ b/app/Actions/Service/StartService.php @@ -22,7 +22,7 @@ class StartService $commands[] = "docker compose pull"; $commands[] = "echo '####### Starting containers.'"; $commands[] = "docker compose up -d --remove-orphans --force-recreate"; - $commands[] = "docker network connect $service->uuid coolify-proxy || true"; + $commands[] = "docker network connect $service->uuid coolify-proxy || true"; $compose = data_get($service,'docker_compose',[]); $serviceNames = data_get(Yaml::parse($compose),'services',[]); foreach($serviceNames as $serviceName => $serviceConfig){ From a7f9fad6270c8edbb2a7b7abe66cd28d6977fbb3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 13:49:15 +0100 Subject: [PATCH 14/16] Add support for Dockerfile target build --- .../Livewire/Project/Application/General.php | 2 ++ app/Jobs/ApplicationDeploymentJob.php | 9 ++++-- ..._07_123731_add_target_build_dockerfile.php | 28 +++++++++++++++++++ .../project/application/general.blade.php | 1 + 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2023_11_07_123731_add_target_build_dockerfile.php diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index 703c85b92..bc853108f 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -55,6 +55,7 @@ class General extends Component 'application.docker_registry_image_tag' => 'nullable', 'application.dockerfile_location' => 'nullable', 'application.custom_labels' => 'nullable', + 'application.dockerfile_target_build' => 'nullable', ]; protected $validationAttributes = [ 'application.name' => 'name', @@ -77,6 +78,7 @@ class General extends Component 'application.docker_registry_image_tag' => 'Docker registry image tag', 'application.dockerfile_location' => 'Dockerfile location', 'application.custom_labels' => 'Custom labels', + 'application.dockerfile_target_build' => 'Dockerfile target build', ]; public function mount() diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 4ffc1f6b6..d91334745 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -69,6 +69,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private $docker_compose_base64; private string $dockerfile_location = '/Dockerfile'; private ?string $addHosts = null; + private ?string $buildTarget = null; private $log_model; private Collection $saved_outputs; @@ -178,6 +179,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted return "--add-host $name:$ip"; })->implode(' '); + if ($this->application->dockerfile_target_build) { + $this->buildTarget = " --target {$this->application->dockerfile_target_build} "; + } + // Get user home directory $this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server); $this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server); @@ -921,7 +926,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted if ($this->application->settings->is_static) { $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->build_image_name {$this->workdir}"), "hidden" => true + executeInDocker($this->deployment_uuid, "docker build $this->buildTarget $this->addHosts --network host -f {$this->workdir}/{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true ]); $dockerfile = base64_encode("FROM {$this->application->static_image} @@ -959,7 +964,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); ); } else { $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 + executeInDocker($this->deployment_uuid, "docker build $this->buildTarget $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true ]); } } diff --git a/database/migrations/2023_11_07_123731_add_target_build_dockerfile.php b/database/migrations/2023_11_07_123731_add_target_build_dockerfile.php new file mode 100644 index 000000000..26f43e925 --- /dev/null +++ b/database/migrations/2023_11_07_123731_add_target_build_dockerfile.php @@ -0,0 +1,28 @@ +string('dockerfile_target_build')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('applications', function (Blueprint $table) { + $table->dropColumn('dockerfile_target_build'); + }); + } +}; diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index a5440aa03..475763e41 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -72,6 +72,7 @@ + @endif @if ($application->could_set_build_commands()) @if ($application->settings->is_static) From 18e98aaf52e171c96d668093ddf85e4057fcd8b5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 14:09:24 +0100 Subject: [PATCH 15/16] Add S3 storage to Livewire components and fix backup job network issue --- app/Http/Livewire/Project/Database/ScheduledBackups.php | 2 ++ app/Http/Livewire/Project/Service/Show.php | 3 +++ app/Http/Livewire/Settings/Backup.php | 1 - app/Jobs/DatabaseBackupJob.php | 8 ++++++-- .../livewire/project/database/scheduled-backups.blade.php | 2 +- resources/views/livewire/project/service/show.blade.php | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/Project/Database/ScheduledBackups.php b/app/Http/Livewire/Project/Database/ScheduledBackups.php index baac1bb99..ec20b1adb 100644 --- a/app/Http/Livewire/Project/Database/ScheduledBackups.php +++ b/app/Http/Livewire/Project/Database/ScheduledBackups.php @@ -11,6 +11,7 @@ class ScheduledBackups extends Component public $type; public $selectedBackup; public $selectedBackupId; + public $s3s; protected $listeners = ['refreshScheduledBackups']; protected $queryString = ['selectedBackupId']; @@ -25,6 +26,7 @@ class ScheduledBackups extends Component } else { $this->type = 'database'; } + $this->s3s = currentTeam()->s3s; } public function setSelectedBackup($backupId) { $this->selectedBackupId = $backupId; diff --git a/app/Http/Livewire/Project/Service/Show.php b/app/Http/Livewire/Project/Service/Show.php index 958fd595a..53f5033f4 100644 --- a/app/Http/Livewire/Project/Service/Show.php +++ b/app/Http/Livewire/Project/Service/Show.php @@ -16,6 +16,8 @@ class Show extends Component public array $parameters; public array $query; public Collection $services; + public $s3s; + protected $listeners = ['generateDockerCompose']; public function mount() @@ -33,6 +35,7 @@ class Show extends Component $this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first(); $this->serviceDatabase->getFilesFromServer(); } + $this->s3s = currentTeam()->s3s; } catch(\Throwable $e) { return handleError($e, $this); } diff --git a/app/Http/Livewire/Settings/Backup.php b/app/Http/Livewire/Settings/Backup.php index 916344ddc..7a5e2f0ed 100644 --- a/app/Http/Livewire/Settings/Backup.php +++ b/app/Http/Livewire/Settings/Backup.php @@ -69,7 +69,6 @@ class Backup extends Component ]); $this->database->refresh(); $this->backup->refresh(); - ray($this->backup); $this->s3s = S3Storage::whereTeamId(0)->get(); } diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php index 1fc1a02d6..94e907834 100644 --- a/app/Jobs/DatabaseBackupJob.php +++ b/app/Jobs/DatabaseBackupJob.php @@ -364,8 +364,12 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted $bucket = $this->s3->bucket; $endpoint = $this->s3->endpoint; $this->s3->testConnection(); - $commands[] = "docker run --pull=always -d --network {$this->database->destination->network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro ghcr.io/coollabsio/coolify-helper >/dev/null 2>&1"; - + if (data_get($this->backup, 'database_type') === 'App\Models\ServiceDatabase') { + $network = $this->database->service->destination->network; + } else { + $network = $this->database->destination->network; + } + $commands[] = "docker run --pull=always -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro ghcr.io/coollabsio/coolify-helper"; $commands[] = "docker exec backup-of-{$this->backup->uuid} mc config host add temporary {$endpoint} $key $secret"; $commands[] = "docker exec backup-of-{$this->backup->uuid} mc cp $this->backup_location temporary/$bucket{$this->backup_dir}/"; instant_remote_process($commands, $this->server); diff --git a/resources/views/livewire/project/database/scheduled-backups.blade.php b/resources/views/livewire/project/database/scheduled-backups.blade.php index b2be851a6..091d41287 100644 --- a/resources/views/livewire/project/database/scheduled-backups.blade.php +++ b/resources/views/livewire/project/database/scheduled-backups.blade.php @@ -26,7 +26,7 @@
@if ($type === 'service-database' && $selectedBackup)
-

Executions

Scheduled Backups + Add
- +
@endisset From 332a0b9e040d3757f54b26e28a9345efcafd06d8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 14:40:58 +0100 Subject: [PATCH 16/16] Remove ANSI colors from console output. --- app/Http/Livewire/Project/Shared/GetLogs.php | 2 +- bootstrap/helpers/shared.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/Project/Shared/GetLogs.php b/app/Http/Livewire/Project/Shared/GetLogs.php index b693793cf..4244bed12 100644 --- a/app/Http/Livewire/Project/Shared/GetLogs.php +++ b/app/Http/Livewire/Project/Shared/GetLogs.php @@ -17,7 +17,7 @@ class GetLogs extends Component public int $numberOfLines = 100; public function doSomethingWithThisChunkOfOutput($output) { - $this->outputs .= $output; + $this->outputs .= removeAnsiColors($output); } public function instantSave() { diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 8e8b2ec3e..013821bd7 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -501,3 +501,6 @@ function generateDeployWebhook($resource) { $url = $api . $endpoint . "?uuid=$uuid&force=false"; return $url; } +function removeAnsiColors($text) { + return preg_replace('/\e[[][A-Za-z0-9];?[0-9]*m?/', '', $text); +}