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.

fix: only append docker network if service/app is running

Andras Bacsaie6e48c581277
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 538eb89d93..8ee78bb73b 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -451,6 +451,11 @@ class Application extends BaseModel
);
}
+ public function isRunning()
+ {
+ return (bool) str($this->status)->startsWith('running');
+ }
+
public function isExited()
{
return (bool) str($this->status)->startsWith('exited');
diff --git a/app/Models/ApplicationPreview.php b/app/Models/ApplicationPreview.php
index 2825f984f3..57d20e3aa6 100644
--- a/app/Models/ApplicationPreview.php
+++ b/app/Models/ApplicationPreview.php
@@ -35,6 +35,11 @@ class ApplicationPreview extends BaseModel
return self::where('application_id', $application_id)->where('pull_request_id', $pull_request_id)->firstOrFail();
}
+ public function isRunning()
+ {
+ return (bool) str($this->status)->startsWith('running');
+ }
+
public function application()
{
return $this->belongsTo(Application::class);
diff --git a/app/Models/Service.php b/app/Models/Service.php
index 3ab178046a..1aa88c8ecb 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -77,6 +77,11 @@ class Service extends BaseModel
}
}
+ public function isRunning()
+ {
+ return (bool) str($this->status())->contains('running');
+ }
+
public function isExited()
{
return (bool) str($this->status())->contains('exited');
diff --git a/bootstrap/helpers/proxy.php b/bootstrap/helpers/proxy.php
index 23c9a23338..dccfaeb38e 100644
--- a/bootstrap/helpers/proxy.php
+++ b/bootstrap/helpers/proxy.php
@@ -36,16 +36,23 @@ function collectDockerNetworksByServer(Server $server)
}
// Service networks
foreach ($server->services()->get() as $service) {
- $networks->push($service->networks());
+ if ($service->isRunning()) {
+ $networks->push($service->networks());
+ }
}
// Docker compose based apps
$docker_compose_apps = $server->dockerComposeBasedApplications();
foreach ($docker_compose_apps as $app) {
- $networks->push($app->uuid);
+ if ($app->isRunning()) {
+ $networks->push($app->uuid);
+ }
}
// Docker compose based preview deployments
$docker_compose_previews = $server->dockerComposeBasedPreviewDeployments();
foreach ($docker_compose_previews as $preview) {
+ if (! $preview->isRunning()) {
+ continue;
+ }
$pullRequestId = $preview->pull_request_id;
$applicationId = $preview->application_id;
$application = Application::find($applicationId);