feat: attach Coolify defined networks to services
This commit is contained in:
parent
d446cd4103
commit
540717e809
@ -4,6 +4,7 @@
|
||||
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use App\Models\Service;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class StartService
|
||||
{
|
||||
@ -22,7 +23,11 @@ public function handle(Service $service)
|
||||
$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;
|
||||
}
|
||||
|
@ -32,8 +32,6 @@ public function mount()
|
||||
- type: volume
|
||||
source: mydata
|
||||
target: /data
|
||||
volume:
|
||||
nocopy: true
|
||||
- type: bind
|
||||
source: ./var/lib/ghost/data
|
||||
target: /data
|
||||
|
@ -258,7 +258,7 @@ public function parse(bool $isNew = false): Collection
|
||||
$networks = $serviceNetworks->toArray();
|
||||
foreach ($definedNetwork as $key => $network) {
|
||||
$networks = array_merge($networks, [
|
||||
$network => null
|
||||
$network
|
||||
]);
|
||||
}
|
||||
data_set($service, 'networks', $networks);
|
||||
|
Loading…
Reference in New Issue
Block a user