Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix

Andras Bacsaif43ca07f33f1
diff --git a/app/Http/Livewire/Source/Github/Change.php b/app/Http/Livewire/Source/Github/Change.php
index f0b9220884..995428e1a9 100644
--- a/app/Http/Livewire/Source/Github/Change.php
+++ b/app/Http/Livewire/Source/Github/Change.php
@@ -8,7 +8,10 @@ use Livewire\Component;
class Change extends Component
{
- public string $host;
+ public string $webhook_endpoint;
+ public string|null $ipv4;
+ public string|null $ipv6;
+ public string|null $fqdn;
public $parameters;
public GithubApp $github_app;
public string $installation_url;
@@ -23,12 +26,18 @@ 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' => 'required|int',
- 'github_app.client_id' => 'required|string',
- 'github_app.client_secret' => 'required|string',
- 'github_app.webhook_secret' => 'required|string',
+ 'github_app.installation_id' => 'nullable',
+ 'github_app.client_id' => 'nullable',
+ 'github_app.client_secret' => 'nullable',
+ 'github_app.webhook_secret' => 'nullable',
'github_app.is_system_wide' => 'required|bool',
];
+ public function mount()
+ {
+ $this->webhook_endpoint = $this->ipv4;
+ $this->parameters = get_parameters();
+ $this->is_system_wide = $this->github_app->is_system_wide;
+ }
public function submit()
{
try {
@@ -48,15 +57,7 @@ class Change extends Component
return general_error_handler(err: $e, that: $this);
}
}
- public function mount()
- {
- $settings = InstanceSettings::get();
- if ($settings->fqdn) {
- $this->host = $settings->fqdn;
- }
- $this->parameters = get_parameters();
- $this->is_system_wide = $this->github_app->is_system_wide;
- }
+
public function delete()
{
try {
diff --git a/config/app.php b/config/app.php
index 6a2c5ce288..a3347a8cda 100644
--- a/config/app.php
+++ b/config/app.php
@@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Facade;
return [
+ 'port' => env('APP_PORT', 8000),
/*
|--------------------------------------------------------------------------
| Application Name
diff --git a/resources/views/livewire/source/github/change.blade.php b/resources/views/livewire/source/github/change.blade.php
index ea2b319c0c..243ad5d062 100644
--- a/resources/views/livewire/source/github/change.blade.php
+++ b/resources/views/livewire/source/github/change.blade.php
@@ -30,40 +30,25 @@
</div>
</div>
<div class="pt-2 pb-10 text-sm">Your Private GitHub App for private repositories.</div>
- @if (!$github_app->app_id)
- <div class="flex items-center gap-4 pt-2 pb-10">
- <div class="text-sm">You need to register a GitHub App before using this source:</div>
- <form>
- <x-forms.button x-on:click.prevent="createGithubApp">Register a GitHub
- Application
- </x-forms.button>
- </form>
- </div>
- @endif
- <div class="flex gap-2">
- <x-forms.input id="github_app.name" label="App Name" required />
-
- @if ($github_app->app_id)
- <x-forms.input id="github_app.organization" label="Organization" disabled
- placeholder="Personal user if empty" />
- @else
- <x-forms.input id="github_app.organization" label="Organization" placeholder="Personal user if empty" />
- @endif
- </div>
- <div class="flex gap-2">
- <x-forms.input id="github_app.html_url" label="HTML Url" disabled />
- <x-forms.input id="github_app.api_url" label="API Url" disabled />
- </div>
- <div class="flex gap-2">
- @if ($github_app->html_url === 'https://github.com')
- <x-forms.input id="github_app.custom_user" label="User" disabled />
- <x-forms.input type="number" id="github_app.custom_port" label="Port" disabled />
- @else
- <x-forms.input id="github_app.custom_user" label="User" required />
- <x-forms.input type="number" id="github_app.custom_port" label="Port" required />
- @endif
- </div>
@if ($github_app->app_id)
+ <div class="flex gap-2">
+ <x-forms.input id="github_app.name" label="App Name" disabled />
+ <x-forms.input id="github_app.organization" label="Organization" disabled
+ placeholder="If empty, personal user will be used" />
+ </div>
+ <div class="flex gap-2">
+ <x-forms.input id="github_app.html_url" label="HTML Url" disabled />
+ <x-forms.input id="github_app.api_url" label="API Url" disabled />
+ </div>
+ <div class="flex gap-2">
+ @if ($github_app->html_url === 'https://github.com')
+ <x-forms.input id="github_app.custom_user" label="User" disabled />
+ <x-forms.input type="number" id="github_app.custom_port" label="Port" disabled />
+ @else
+ <x-forms.input id="github_app.custom_user" label="User" required />
+ <x-forms.input type="number" id="github_app.custom_port" label="Port" required />
+ @endif
+ </div>
<div class="flex gap-2">
<x-forms.input type="number" id="github_app.app_id" label="App Id" disabled />
<x-forms.input type="number" id="github_app.installation_id" label="Installation Id" disabled />
@@ -77,61 +62,97 @@
helper="If checked, this GitHub App will be available for everyone in this Coolify instance."
instantSave id="is_system_wide" />
@else
+ <div class="text-sm ">You need to register a GitHub App before using this source.</div>
+ <div class="flex items-end gap-4 pt-2 pb-10">
+ <form class="flex gap-2">
+ <x-forms.select wire:model='webhook_endpoint' label="Webhook Endpoint"
+ helper="All Git webhooks will be sent to this endpoint. <br><br>If you would like to use domain instead of IP address, set your Coolify instance's FQDN in the Settings menu.">
+ @if ($ipv4)
+ <option value="{{ $ipv4 }}">Use {{ $ipv4 }}</option>
+ @endif
+ @if ($ipv6)
+ <option value="{{ $ipv6 }}">Use {{ $ipv6 }}</option>
+ @endif
+ @if ($fqdn)
+ <option value="{{ $fqdn }}">Use {{ $fqdn }}</option>
+ @endif
+ </x-forms.select>
+ <x-forms.button x-on:click.prevent="createGithubApp('{{ $webhook_endpoint }}')">Register a GitHub
+ Application
+ </x-forms.button>
+ </form>
+ </div>
+ <div class="flex gap-2">
+ <x-forms.input id="github_app.name" label="App Name" disabled />
+ <x-forms.input id="github_app.organization" label="Organization"
+ placeholder="If empty, personal user will be used" disabled />
+ </div>
+ <div class="flex gap-2">
+ <x-forms.input id="github_app.html_url" label="HTML Url" disabled />
+ <x-forms.input id="github_app.api_url" label="API Url" disabled />
+ </div>
+ <div class="flex gap-2">
+ @if ($github_app->html_url === 'https://github.com')
+ <x-forms.input id="github_app.custom_user" label="User" disabled />
+ <x-forms.input type="number" id="github_app.custom_port" label="Port" disabled />
+ @else
+ <x-forms.input id="github_app.custom_user" label="User" required />
+ <x-forms.input type="number" id="github_app.custom_port" label="Port" required />
+ @endif
+ </div>
<x-forms.checkbox
helper="If checked, this GitHub App will be available for everyone in this Coolify instance." noDirty
- label="System Wide?" instantSave id="is_system_wide" />
+ label="System Wide?" instantSave disabled id="is_system_wide" />
+ <script>
+ function createGithubApp(webhook_endpoint) {
+ const {
+ organization,
+ uuid,
+ html_url
+ } = @json($github_app);
+ let baseUrl = webhook_endpoint;
+ const name = @js($name);
+ const isDev = @js(config('app.env')) === 'local';
+ const devWebhook = @js(config('coolify.dev_webhook'));
+ if (isDev && devWebhook) {
+ baseUrl = devWebhook;
+ }
+ const webhookBaseUrl = `${baseUrl}/webhooks`;
+ const path = organization ? `organizations/${organization}/settings/apps/new` : 'settings/apps/new';
+ 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: {
+ contents: 'read',
+ metadata: 'read',
+ pull_requests: 'write',
+ emails: 'read'
+ },
+ 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();
+ }
+ </script>
@endif
</form>
- @if (!$github_app->app_id)
- <script>
- function createGithubApp() {
- const {
- organization,
- uuid,
- html_url
- } = @json($github_app);
- let baseUrl = @js($host);
- const name = @js($name);
- const isDev = @js(config('app.env')) === 'local';
- const devWebhook = @js(config('coolify.dev_webhook'));
- if (isDev && devWebhook) {
- baseUrl = devWebhook;
- }
- const webhookBaseUrl = `${baseUrl}/webhooks`;
- const path = organization ? `organizations/${organization}/settings/apps/new` : 'settings/apps/new';
- 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: {
- contents: 'read',
- metadata: 'read',
- pull_requests: 'write',
- emails: 'read'
- },
- 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();
- }
- </script>
- @endif
</div>
diff --git a/resources/views/source/github/show.blade.php b/resources/views/source/github/show.blade.php
index d1da2979f8..6cbba2911e 100644
--- a/resources/views/source/github/show.blade.php
+++ b/resources/views/source/github/show.blade.php
@@ -1,3 +1,4 @@
<x-layout>
- <livewire:source.github.change :github_app="$github_app" :installation_url="$installation_url" :host="$host" :name="$name" />
+ <livewire:source.github.change :github_app="$github_app" :installation_url="$installation_url" :name="$name" :ipv4="$ipv4"
+ :ipv6="$ipv6" :fqdn="$fqdn" />
</x-layout>
diff --git a/routes/web.php b/routes/web.php
index e52d18eb8b..38ae861f34 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -101,18 +101,22 @@ Route::middleware(['auth'])->group(function () {
})->name('source.all');
Route::get('/source/github/{github_app_uuid}', function (Request $request) {
$github_app = GithubApp::where('uuid', request()->github_app_uuid)->first();
- $name = Str::of(Str::kebab($github_app->name))->start('coolify-');
$settings = InstanceSettings::get();
- $host = $request->schemeAndHttpHost();
- if ($settings->fqdn) {
- $host = $settings->fqdn;
- }
+ $name = Str::of(Str::kebab($github_app->name));
$installation_path = $github_app->html_url === 'https://github.com' ? 'apps' : 'github-apps';
$installation_url = "$github_app->html_url/$installation_path/$name/installations/new";
+ if ($settings->public_ipv4) {
+ $ipv4 = 'http://' . $settings->public_ipv4 . ':' . config('app.port');
+ }
+ if ($settings->public_ipv6) {
+ $ipv6 = 'http://' . $settings->public_ipv6 . ':' . config('app.port');
+ }
return view('source.github.show', [
'github_app' => $github_app,
- 'host' => $host,
'name' => $name,
+ 'ipv4' => $ipv4 ?? null,
+ 'ipv6' => $ipv6 ?? null,
+ 'fqdn' => $settings->fqdn,
'installation_url' => $installation_url,
]);
})->name('source.github.show');