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.

feat: attach Coolify defined networks to services

Andras Bacsai540717e80987
diff --git a/app/Actions/Service/StartService.php b/app/Actions/Service/StartService.php
index 25a0614d91..965162037f 100644
--- a/app/Actions/Service/StartService.php
+++ b/app/Actions/Service/StartService.php
@@ -4,6 +4,7 @@ namespace App\Actions\Service;
use Lorisleiva\Actions\Concerns\AsAction;
use App\Models\Service;
+use Symfony\Component\Yaml\Yaml;
class StartService
{
@@ -22,7 +23,11 @@ class StartService
$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 $network --alias $service->name-$service->uuid $service->name-$service->uuid 2>/dev/null || 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";
+ }
$activity = remote_process($commands, $service->server);
return $activity;
}
diff --git a/app/Http/Livewire/Project/New/DockerCompose.php b/app/Http/Livewire/Project/New/DockerCompose.php
index ae3a1c08c2..81c487ccfc 100644
--- a/app/Http/Livewire/Project/New/DockerCompose.php
+++ b/app/Http/Livewire/Project/New/DockerCompose.php
@@ -32,8 +32,6 @@ class DockerCompose extends Component
- type: volume
source: mydata
target: /data
- volume:
- nocopy: true
- type: bind
source: ./var/lib/ghost/data
target: /data
diff --git a/app/Models/Service.php b/app/Models/Service.php
index c370e62b1d..a430dc2dd7 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -258,7 +258,7 @@ class Service extends BaseModel
$networks = $serviceNetworks->toArray();
foreach ($definedNetwork as $key => $network) {
$networks = array_merge($networks, [
- $network => null
+ $network
]);
}
data_set($service, 'networks', $networks);