fix: services should have destination as well

This commit is contained in:
Andras Bacsai
2023-10-01 13:59:22 +02:00
parent 23968e7886
commit 9ab5a1f7bd
5 changed files with 78 additions and 9 deletions

View File

@@ -13,14 +13,20 @@ class StartService
$service->saveComposeConfigs();
$commands[] = "cd " . $service->workdir();
$commands[] = "echo '####### Saved configuration files to {$service->workdir()}.'";
$commands[] = "echo '####### Creating Docker network.'";
$commands[] = "docker network create --attachable {$service->uuid} >/dev/null 2>/dev/null || true";
if (is_null($service->destination)) {
$dockerNetwork = $service->uuid;
$commands[] = "echo '####### Creating Docker network.'";
$commands[] = "docker network create --attachable {$dockerNetwork} >/dev/null 2>/dev/null || true";
}
$commands[] = "echo '####### Starting service {$service->name} on {$service->server->name}.'";
$commands[] = "echo '####### Pulling images.'";
$commands[] = "docker compose pull";
$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";
if (is_null($service->destination)) {
$commands[] = "echo '####### Connecting to proxy network.'";
$commands[] = "docker network connect coolify-proxy {$dockerNetwork} 2>/dev/null || true";
}
$activity = remote_process($commands, $service->server);
return $activity;
}

View File

@@ -20,7 +20,9 @@ class StopService
instant_remote_process(["docker rm -f {$db->name}-{$service->uuid}"], $service->server);
$db->update(['status' => 'exited']);
}
instant_remote_process(["docker network disconnect {$service->uuid} coolify-proxy 2>/dev/null"], $service->server, false);
instant_remote_process(["docker network rm {$service->uuid} 2>/dev/null"], $service->server, false);
if (is_null($service->destination)) {
instant_remote_process(["docker network disconnect {$service->uuid} coolify-proxy 2>/dev/null"], $service->server, false);
instant_remote_process(["docker network rm {$service->uuid} 2>/dev/null"], $service->server, false);
}
}
}