Add Docker Compose based applications and preview deployments to proxy on restart
This commit is contained in:
parent
d058e04213
commit
2788fcf4e1
@ -228,6 +228,23 @@ class Server extends BaseModel
|
|||||||
return $standaloneDocker->applications;
|
return $standaloneDocker->applications;
|
||||||
})->flatten();
|
})->flatten();
|
||||||
}
|
}
|
||||||
|
public function dockerComposeBasedApplications()
|
||||||
|
{
|
||||||
|
return $this->applications()->filter(function ($application) {
|
||||||
|
return data_get($application, 'build_pack') === 'dockercompose';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function dockerComposeBasedPreviewDeployments()
|
||||||
|
{
|
||||||
|
return $this->previews()->filter(function ($preview) {
|
||||||
|
$applicationId = data_get($preview, 'application_id');
|
||||||
|
$application = Application::find($applicationId);
|
||||||
|
if (!$application) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return data_get($application, 'build_pack') === 'dockercompose';
|
||||||
|
});
|
||||||
|
}
|
||||||
public function services()
|
public function services()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Service::class);
|
return $this->hasMany(Service::class);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Actions\Proxy\SaveConfiguration;
|
use App\Actions\Proxy\SaveConfiguration;
|
||||||
|
use App\Models\Application;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
@ -12,15 +13,31 @@ function get_proxy_path()
|
|||||||
}
|
}
|
||||||
function connectProxyToNetworks(Server $server)
|
function connectProxyToNetworks(Server $server)
|
||||||
{
|
{
|
||||||
// TODO: Connect to compose based application networks as well.
|
|
||||||
// Standalone networks
|
// Standalone networks
|
||||||
$networks = collect($server->standaloneDockers)->map(function ($docker) {
|
$networks = collect($server->standaloneDockers)->map(function ($docker) {
|
||||||
return $docker['network'];
|
return $docker['network'];
|
||||||
});
|
});
|
||||||
// Service networks
|
// Service networks
|
||||||
foreach($server->services()->get() as $service) {
|
foreach ($server->services()->get() as $service) {
|
||||||
$networks->push($service->networks());
|
$networks->push($service->networks());
|
||||||
}
|
}
|
||||||
|
// Docker compose based apps
|
||||||
|
$docker_compose_apps = $server->dockerComposeBasedApplications();
|
||||||
|
foreach ($docker_compose_apps as $app) {
|
||||||
|
$networks->push($app->uuid);
|
||||||
|
}
|
||||||
|
// Docker compose based preview deployments
|
||||||
|
$docker_compose_previews = $server->dockerComposeBasedPreviewDeployments();
|
||||||
|
foreach ($docker_compose_previews as $preview) {
|
||||||
|
$pullRequestId = $preview->pull_request_id;
|
||||||
|
$applicationId = $preview->application_id;
|
||||||
|
$application = Application::find($applicationId);
|
||||||
|
if (!$application) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$network = "{$application->uuid}-{$pullRequestId}";
|
||||||
|
$networks->push($network);
|
||||||
|
}
|
||||||
$networks = collect($networks)->flatten()->unique();
|
$networks = collect($networks)->flatten()->unique();
|
||||||
if ($networks->count() === 0) {
|
if ($networks->count() === 0) {
|
||||||
$networks = collect(['coolify']);
|
$networks = collect(['coolify']);
|
||||||
|
@ -1072,7 +1072,6 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
throw new \Exception($e->getMessage());
|
throw new \Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ray($yaml);
|
|
||||||
$server = $resource->destination->server;
|
$server = $resource->destination->server;
|
||||||
$topLevelVolumes = collect(data_get($yaml, 'volumes', []));
|
$topLevelVolumes = collect(data_get($yaml, 'volumes', []));
|
||||||
if ($pull_request_id !== 0) {
|
if ($pull_request_id !== 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user