feat: attach Coolify defined networks to services
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Actions\Service;
|
|||||||
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class StartService
|
class StartService
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,11 @@ class StartService
|
|||||||
$commands[] = "echo '####### Starting containers.'";
|
$commands[] = "echo '####### Starting containers.'";
|
||||||
$commands[] = "docker compose up -d --remove-orphans --force-recreate";
|
$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 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);
|
$activity = remote_process($commands, $service->server);
|
||||||
return $activity;
|
return $activity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class DockerCompose extends Component
|
|||||||
- type: volume
|
- type: volume
|
||||||
source: mydata
|
source: mydata
|
||||||
target: /data
|
target: /data
|
||||||
volume:
|
|
||||||
nocopy: true
|
|
||||||
- type: bind
|
- type: bind
|
||||||
source: ./var/lib/ghost/data
|
source: ./var/lib/ghost/data
|
||||||
target: /data
|
target: /data
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ class Service extends BaseModel
|
|||||||
$networks = $serviceNetworks->toArray();
|
$networks = $serviceNetworks->toArray();
|
||||||
foreach ($definedNetwork as $key => $network) {
|
foreach ($definedNetwork as $key => $network) {
|
||||||
$networks = array_merge($networks, [
|
$networks = array_merge($networks, [
|
||||||
$network => null
|
$network
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
data_set($service, 'networks', $networks);
|
data_set($service, 'networks', $networks);
|
||||||
|
|||||||
Reference in New Issue
Block a user