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
feat: labels by proxy type
Lorenzo Migliorero3be06ced92ea
diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.phpindex 21e946a9a7..fa2a19c2a6 100644--- a/bootstrap/helpers/docker.php+++ b/bootstrap/helpers/docker.php@@ -1,5 +1,6 @@<?php+use App\Enums\ProxyTypes;use App\Models\Application;use App\Models\ApplicationPreview;use App\Models\Server;@@ -535,26 +536,31 @@ function generateLabelsApplication(Application $application, ?ApplicationPreviewif ($pull_request_id === 0) {if ($application->fqdn) {$domains = str(data_get($application, 'fqdn'))->explode(',');- $labels = $labels->merge(fqdnLabelsForTraefik(- uuid: $appUuid,- domains: $domains,- onlyPort: $onlyPort,- is_force_https_enabled: $application->isForceHttpsEnabled(),- is_gzip_enabled: $application->isGzipEnabled(),- is_stripprefix_enabled: $application->isStripprefixEnabled(),- redirect_direction: $application->redirect- ));- // Add Caddy labels- $labels = $labels->merge(fqdnLabelsForCaddy(- network: $application->destination->network,- uuid: $appUuid,- domains: $domains,- onlyPort: $onlyPort,- is_force_https_enabled: $application->isForceHttpsEnabled(),- is_gzip_enabled: $application->isGzipEnabled(),- is_stripprefix_enabled: $application->isStripprefixEnabled(),- redirect_direction: $application->redirect- ));+ switch($application->destination->server->proxyType()) {+ case ProxyTypes::TRAEFIK_V2->value:+ $labels = $labels->merge(fqdnLabelsForTraefik(+ uuid: $appUuid,+ domains: $domains,+ onlyPort: $onlyPort,+ is_force_https_enabled: $application->isForceHttpsEnabled(),+ is_gzip_enabled: $application->isGzipEnabled(),+ is_stripprefix_enabled: $application->isStripprefixEnabled(),+ redirect_direction: $application->redirect+ ));+ break;+ case ProxyTypes::CADDY->value:+ $labels = $labels->merge(fqdnLabelsForCaddy(+ network: $application->destination->network,+ uuid: $appUuid,+ domains: $domains,+ onlyPort: $onlyPort,+ is_force_https_enabled: $application->isForceHttpsEnabled(),+ is_gzip_enabled: $application->isGzipEnabled(),+ is_stripprefix_enabled: $application->isStripprefixEnabled(),+ redirect_direction: $application->redirect+ ));+ break;+ }}} else {if (data_get($preview, 'fqdn')) {@@ -562,24 +568,30 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview} else {$domains = collect([]);}- $labels = $labels->merge(fqdnLabelsForTraefik(- uuid: $appUuid,- domains: $domains,- onlyPort: $onlyPort,- is_force_https_enabled: $application->isForceHttpsEnabled(),- is_gzip_enabled: $application->isGzipEnabled(),- is_stripprefix_enabled: $application->isStripprefixEnabled()- ));- // Add Caddy labels- $labels = $labels->merge(fqdnLabelsForCaddy(- network: $application->destination->network,- uuid: $appUuid,- domains: $domains,- onlyPort: $onlyPort,- is_force_https_enabled: $application->isForceHttpsEnabled(),- is_gzip_enabled: $application->isGzipEnabled(),- is_stripprefix_enabled: $application->isStripprefixEnabled()- ));++ switch($application->destination->server->proxyType()) {+ case ProxyTypes::TRAEFIK_V2->value:+ $labels = $labels->merge(fqdnLabelsForTraefik(+ uuid: $appUuid,+ domains: $domains,+ onlyPort: $onlyPort,+ is_force_https_enabled: $application->isForceHttpsEnabled(),+ is_gzip_enabled: $application->isGzipEnabled(),+ is_stripprefix_enabled: $application->isStripprefixEnabled()+ ));+ break;+ case ProxyTypes::CADDY->value:+ $labels = $labels->merge(fqdnLabelsForCaddy(+ network: $application->destination->network,+ uuid: $appUuid,+ domains: $domains,+ onlyPort: $onlyPort,+ is_force_https_enabled: $application->isForceHttpsEnabled(),+ is_gzip_enabled: $application->isGzipEnabled(),+ is_stripprefix_enabled: $application->isStripprefixEnabled()+ ));+ break;+ }}diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex e3c8d5218d..9600b13d2d 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -1,6 +1,7 @@<?phpuse App\Enums\ApplicationDeploymentStatus;+use App\Enums\ProxyTypes;use App\Jobs\ServerFilesFromServerJob;use App\Models\Application;use App\Models\ApplicationDeploymentQueue;@@ -1305,27 +1306,33 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal$serviceLabels = $serviceLabels->merge($defaultLabels);if (! $isDatabase && $fqdns->count() > 0) {if ($fqdns) {- $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(- uuid: $resource->uuid,- domains: $fqdns,- is_force_https_enabled: true,- serviceLabels: $serviceLabels,- is_gzip_enabled: $savedService->isGzipEnabled(),- is_stripprefix_enabled: $savedService->isStripprefixEnabled(),- service_name: $serviceName,- image: data_get($service, 'image')- ));- $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy(- network: $resource->destination->network,- uuid: $resource->uuid,- domains: $fqdns,- is_force_https_enabled: true,- serviceLabels: $serviceLabels,- is_gzip_enabled: $savedService->isGzipEnabled(),- is_stripprefix_enabled: $savedService->isStripprefixEnabled(),- service_name: $serviceName,- image: data_get($service, 'image')- ));+ switch($resource->destination->server->proxyType()) {+ case ProxyTypes::TRAEFIK_V2->value:+ $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(+ uuid: $resource->uuid,+ domains: $fqdns,+ is_force_https_enabled: true,+ serviceLabels: $serviceLabels,+ is_gzip_enabled: $savedService->isGzipEnabled(),+ is_stripprefix_enabled: $savedService->isStripprefixEnabled(),+ service_name: $serviceName,+ image: data_get($service, 'image')+ ));+ break;+ case ProxyTypes::CADDY->value:+ $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy(+ network: $resource->destination->network,+ uuid: $resource->uuid,+ domains: $fqdns,+ is_force_https_enabled: true,+ serviceLabels: $serviceLabels,+ is_gzip_enabled: $savedService->isGzipEnabled(),+ is_stripprefix_enabled: $savedService->isStripprefixEnabled(),+ service_name: $serviceName,+ image: data_get($service, 'image')+ ));+ break;+ }}}if ($resource->server->isLogDrainEnabled() && $savedService->isLogDrainEnabled()) {@@ -2023,26 +2030,36 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal});}}- $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(- uuid: $resource->uuid,- domains: $fqdns,- serviceLabels: $serviceLabels,- generate_unique_uuid: $resource->build_pack === 'dockercompose',- image: data_get($service, 'image'),- is_force_https_enabled: $resource->isForceHttpsEnabled(),- is_gzip_enabled: $resource->isGzipEnabled(),- is_stripprefix_enabled: $resource->isStripprefixEnabled(),- ));- $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy(- network: $resource->destination->network,- uuid: $resource->uuid,- domains: $fqdns,- serviceLabels: $serviceLabels,- image: data_get($service, 'image'),- is_force_https_enabled: $resource->isForceHttpsEnabled(),- is_gzip_enabled: $resource->isGzipEnabled(),- is_stripprefix_enabled: $resource->isStripprefixEnabled(),- ));+ switch ($server->proxyType()) {+ case ProxyTypes::TRAEFIK_V2->value:+ $serviceLabels = $serviceLabels->merge(+ fqdnLabelsForTraefik(+ uuid: $resource->uuid,+ domains: $fqdns,+ serviceLabels: $serviceLabels,+ generate_unique_uuid: $resource->build_pack === 'dockercompose',+ image: data_get($service, 'image'),+ is_force_https_enabled: $resource->isForceHttpsEnabled(),+ is_gzip_enabled: $resource->isGzipEnabled(),+ is_stripprefix_enabled: $resource->isStripprefixEnabled(),+ )+ );+ break;+ case ProxyTypes::CADDY->value:+ $serviceLabels = $serviceLabels->merge(+ fqdnLabelsForCaddy(+ network: $resource->destination->network,+ uuid: $resource->uuid,+ domains: $fqdns,+ serviceLabels: $serviceLabels,+ image: data_get($service, 'image'),+ is_force_https_enabled: $resource->isForceHttpsEnabled(),+ is_gzip_enabled: $resource->isGzipEnabled(),+ is_stripprefix_enabled: $resource->isStripprefixEnabled(),+ )+ );+ break;+ }}}}