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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: caddy network issue feat: connect compose based apps to predefined network
Andras Bacsaie86f8ddd0913
diff --git a/app/Livewire/Project/Application/Advanced.php b/app/Livewire/Project/Application/Advanced.phpindex 278cab5a1c..d35867e8f6 100644--- a/app/Livewire/Project/Application/Advanced.php+++ b/app/Livewire/Project/Application/Advanced.php@@ -27,6 +27,8 @@ class Advanced extends Component'application.settings.gpu_count' => 'string|required','application.settings.gpu_device_ids' => 'string|required','application.settings.gpu_options' => 'string|required',+ 'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required',+ 'application.settings.connect_to_docker_network' => 'boolean|required',];public function mount() {$this->is_force_https_enabled = $this->application->isForceHttpsEnabled();@@ -54,8 +56,14 @@ class Advanced extends Component$this->application->settings->is_stripprefix_enabled = $this->is_stripprefix_enabled;$this->dispatch('resetDefaultLabels', false);}+ if ($this->application->settings->is_raw_compose_deployment_enabled) {+ $this->application->parseRawCompose();+ } else {+ $this->application->parseCompose();+ }$this->application->settings->save();$this->dispatch('success', 'Settings saved.');+ $this->dispatch('configurationChanged');}public function submit() {if ($this->application->settings->gpu_count && $this->application->settings->gpu_device_ids) {diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex 022a7b7107..6926e52cb6 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -34,7 +34,8 @@ class General extends Componentpublic $parsedServiceDomains = [];protected $listeners = [- 'resetDefaultLabels'+ 'resetDefaultLabels',+ 'configurationChanged' => '$refresh'];protected $rules = ['application.name' => 'required',@@ -72,7 +73,6 @@ class General extends Component'application.post_deployment_command' => 'nullable','application.post_deployment_command_container' => 'nullable','application.settings.is_static' => 'boolean|required',- 'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required','application.settings.is_build_server_enabled' => 'boolean|required','application.watch_paths' => 'nullable',];@@ -108,7 +108,6 @@ class General extends Component'application.docker_compose_custom_start_command' => 'Docker compose custom start command','application.docker_compose_custom_build_command' => 'Docker compose custom build command','application.settings.is_static' => 'Is static',- 'application.settings.is_raw_compose_deployment_enabled' => 'Is raw compose deployment enabled','application.settings.is_build_server_enabled' => 'Is build server enabled','application.watch_paths' => 'Watch paths',];@@ -337,11 +336,6 @@ class General extends Componentcheck_domain_usage(resource: $this->application);}}- if ($this->application->settings->is_raw_compose_deployment_enabled) {- $this->application->parseRawCompose();- } else {- $this->parsedServices = $this->application->parseCompose();- }}$this->application->custom_labels = base64_encode($this->customLabels);$this->application->save();diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 966b1db595..25c8cfb815 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -1424,6 +1424,14 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = falforeach ($definedNetwork as $key => $network) {$networks->put($network, null);}+ if (data_get($resource, 'settings.connect_to_docker_network')) {+ $network = $resource->destination->network;+ $networks->put($network, null);+ $topLevelNetworks->put($network, [+ 'name' => $network,+ 'external' => true+ ]);+ }data_set($service, 'networks', $networks->toArray());// Get variables from the serviceforeach ($serviceVariables as $variableName => $variable) {@@ -1585,7 +1593,6 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal$fqdns = data_get($domains, "$serviceName.domain");if ($fqdns) {$fqdns = str($fqdns)->explode(',');- $uuid = new Cuid2(7);if ($pull_request_id !== 0) {$fqdns = $fqdns->map(function ($fqdn) use ($pull_request_id, $resource) {$preview = ApplicationPreview::findPreviewByApplicationAndPullId($resource->id, $pull_request_id);@@ -1604,13 +1611,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal});}$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(- uuid: $uuid,+ uuid: $resource->uuid,domains: $fqdns,serviceLabels: $serviceLabels));$serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy(network: $resource->destination->network,- uuid: $uuid,+ uuid: $resource->uuid,domains: $fqdns,serviceLabels: $serviceLabels));diff --git a/database/migrations/2024_04_25_073615_add_docker_network_to_application_settings.php b/database/migrations/2024_04_25_073615_add_docker_network_to_application_settings.phpnew file mode 100644index 0000000000..aeae6f77de--- /dev/null+++ b/database/migrations/2024_04_25_073615_add_docker_network_to_application_settings.php@@ -0,0 +1,29 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('application_settings', function (Blueprint $table) {+ $table->boolean('connect_to_docker_network')->default(false);++ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('application_settings', function (Blueprint $table) {+ $table->dropColumn('connect_to_docker_network');+ });+ }+};diff --git a/resources/views/livewire/project/application/advanced.blade.php b/resources/views/livewire/project/application/advanced.blade.phpindex 75a55c5b9f..5d2922a7e0 100644--- a/resources/views/livewire/project/application/advanced.blade.php+++ b/resources/views/livewire/project/application/advanced.blade.php@@ -25,8 +25,21 @@instantSave id="is_gzip_enabled" /><x-forms.checkbox helper="Strip Prefix is used to remove prefixes from paths. Like /api/ to /api."instantSave id="is_stripprefix_enabled" label="Strip Prefixes" />- <h3>Logs</h3>+ @if ($application->build_pack === 'dockercompose')+ <x-forms.checkbox instantSave id="application.settings.is_raw_compose_deployment_enabled"+ label="Raw Compose Deployment"+ helper="WARNING: Advanced use cases only. Your docker compose file will be deployed as-is. Nothing is modified by Coolify. You need to configure the proxy parts. More info in the <a class='underline dark:text-white' href='https://coolify.io/docs/knowledge-base/docker/compose#raw-docker-compose-deployment'>documentation.</a>" />+ @endif+ @if ($application->build_pack === 'dockercompose')+ <h3>Network</h3>+ <div class="w-96">+ <x-forms.checkbox instantSave id="application.settings.connect_to_docker_network"+ label="Connect To Predefined Network"+ helper="By default, you do not reach the Coolify defined networks.<br>Starting a docker compose based resource will have an internal network. <br>If you connect to a Coolify defined network, you maybe need to use different internal DNS names to connect to a resource.<br><br>For more information, check <a class='underline dark:text-white' target='_blank' href='https://coolify.io/docs/knowledge-base/docker/compose#connect-to-predefined-networks'>this</a>." />+ </div>+ @endif@if (!$application->settings->is_raw_compose_deployment_enabled)+ <h3>Logs</h3><x-forms.checkbox helper="Drain logs to your configured log drain endpoint in your Server settings."instantSave id="application.settings.is_log_drain_enabled" label="Drain Logs" />@endifdiff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex 558db9c3c4..de83b03ee4 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -4,7 +4,7 @@<h2>General</h2><x-forms.button type="submit">Save- </x-forms.button>+ </x-forms.button></div><div>General configuration for your application.</div><div class="flex flex-col gap-2 py-4">@@ -38,13 +38,8 @@</div>@endif@if ($application->build_pack === 'dockercompose')- <div class="w-96">- <x-forms.checkbox instantSave id="application.settings.is_raw_compose_deployment_enabled"- label="Raw Compose Deployment"- helper="WARNING: Advanced use cases only. Your docker compose file will be deployed as-is. Nothing is modified by Coolify. You need to configure the proxy parts. More info in the <a href='https://coolify.io/docs/knowledge-base/docker/compose#raw-docker-compose-deployment'>documentation.</a>" />- </div>@if (count($parsedServices) > 0 && !$application->settings->is_raw_compose_deployment_enabled)- <h3>Domains</h3>+ <h3 class="pt-6">Domains</h3>@foreach (data_get($parsedServices, 'services') as $serviceName => $service)@if (!isDatabaseImage(data_get($service, 'image')))<div class="flex items-end gap-2">