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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: terminal
Andras Bacsaif71fb7266d11
diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.phpindex bf34fec795..c04f5cc8c1 100644--- a/app/Livewire/Project/Shared/ExecuteContainerCommand.php+++ b/app/Livewire/Project/Shared/ExecuteContainerCommand.php@@ -11,7 +11,7 @@ use Livewire\Component;class ExecuteContainerCommand extends Component{- public string $container;+ public $container;public Collection $containers;@@ -57,24 +57,13 @@ class ExecuteContainerCommand extends Componentif ($this->resource->destination->server->isFunctional()) {$this->servers = $this->servers->push($this->resource->destination->server);}- $this->container = $this->resource->uuid;- $this->containers->push($this->container);} elseif (data_get($this->parameters, 'service_uuid')) {$this->type = 'service';$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();- $this->resource->applications()->get()->each(function ($application) {- $this->containers->push(data_get($application, 'name').'-'.data_get($this->resource, 'uuid'));- });- $this->resource->databases()->get()->each(function ($database) {- $this->containers->push(data_get($database, 'name').'-'.data_get($this->resource, 'uuid'));- });if ($this->resource->server->isFunctional()) {$this->servers = $this->servers->push($this->resource->server);}}- if ($this->containers->count() > 0) {- $this->container = $this->containers->first();- }}public function loadContainers()@@ -97,19 +86,45 @@ class ExecuteContainerCommand extends Component];$this->containers = $this->containers->push($payload);}- }- }- if ($this->containers->count() > 0) {- if (data_get($this->parameters, 'application_uuid')) {- $this->container = data_get($this->containers->first(), 'container.Names');} elseif (data_get($this->parameters, 'database_uuid')) {- $this->container = $this->containers->first();+ if ($this->resource->isRunning()) {+ $this->containers = $this->containers->push([+ 'server' => $server,+ 'container' => [+ 'Names' => $this->resource->uuid,+ ],+ ]);+ }} elseif (data_get($this->parameters, 'service_uuid')) {- $this->container = $this->containers->first();- }- if ($this->containers->count() === 1) {- $this->dispatch('connectToContainer');+ $this->resource->applications()->get()->each(function ($application) {+ ray($application);+ if ($application->isRunning()) {+ $this->containers->push([+ 'server' => $this->resource->server,+ 'container' => [+ 'Names' => data_get($application, 'name').'-'.data_get($this->resource, 'uuid'),+ ],+ ]);+ }+ });+ $this->resource->databases()->get()->each(function ($database) {+ if ($database->isRunning()) {+ $this->containers->push([+ 'server' => $this->resource->server,+ 'container' => [+ 'Names' => data_get($database, 'name').'-'.data_get($this->resource, 'uuid'),+ ],+ ]);+ }+ });}++ }+ if ($this->containers->count() > 0) {+ $this->container = $this->containers->first();+ }+ if ($this->containers->count() === 1) {+ $this->dispatch('connectToContainer');}}@@ -117,17 +132,13 @@ class ExecuteContainerCommand extends Componentpublic function connectToContainer(){try {- if (data_get($this->parameters, 'application_uuid')) {- $container = $this->containers->where('container.Names', $this->container)->first();- $container_name = data_get($container, 'container.Names');- if (is_null($container)) {- throw new \RuntimeException('Container not found.');- }- $server = data_get($container, 'server');- } else {- $container_name = $this->container;- $server = $this->servers->first();+ $container_name = data_get($this->container, 'container.Names');+ ray($this->container);+ if (is_null($container_name)) {+ throw new \RuntimeException('Container not found.');}+ $server = data_get($this->container, 'server');+if ($server->isForceDisabled()) {throw new \RuntimeException('Server is disabled.');}diff --git a/app/Livewire/Project/Shared/Terminal.php b/app/Livewire/Project/Shared/Terminal.phpindex de1df3844f..7c23c291da 100644--- a/app/Livewire/Project/Shared/Terminal.php+++ b/app/Livewire/Project/Shared/Terminal.php@@ -24,7 +24,7 @@ class Terminal extends Componentif ($isContainer) {$status = getContainerStatus($server, $identifier);if ($status !== 'running') {- return handleError(new \Exception('Container is not running'), $this);+ return;}$command = generateSshCommand($server, "docker exec -it {$identifier} sh -c 'if [ -f ~/.profile ]; then . ~/.profile; fi; if [ -n \"\$SHELL\" ]; then exec \$SHELL; else sh; fi'");} else {diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.phpindex 6690f254ef..d312fab964 100644--- a/app/Models/ServiceApplication.php+++ b/app/Models/ServiceApplication.php@@ -32,6 +32,16 @@ class ServiceApplication extends BaseModelreturn ServiceApplication::whereRelation('service.environment.project.team', 'id', $teamId)->orderBy('name');}+ public function isRunning()+ {+ return str($this->status)->contains('running');+ }++ public function isExited()+ {+ return str($this->status)->contains('exited');+ }+public function isLogDrainEnabled(){return data_get($this, 'is_log_drain_enabled', false);diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.phpindex 4a749913ea..6b96738e81 100644--- a/app/Models/ServiceDatabase.php+++ b/app/Models/ServiceDatabase.php@@ -25,6 +25,16 @@ class ServiceDatabase extends BaseModelremote_process(["docker restart {$container_id}"], $this->service->server);}+ public function isRunning()+ {+ return str($this->status)->contains('running');+ }++ public function isExited()+ {+ return str($this->status)->contains('exited');+ }+public function isLogDrainEnabled(){return data_get($this, 'is_log_drain_enabled', false);diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.phpindex 4cd194cd86..ee5c3becc4 100644--- a/app/Models/StandaloneClickhouse.php+++ b/app/Models/StandaloneClickhouse.php@@ -75,6 +75,11 @@ class StandaloneClickhouse extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.phpindex 8726b2546a..361abf1109 100644--- a/app/Models/StandaloneDragonfly.php+++ b/app/Models/StandaloneDragonfly.php@@ -75,6 +75,11 @@ class StandaloneDragonfly extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.phpindex 7ecb00348a..e05879371a 100644--- a/app/Models/StandaloneKeydb.php+++ b/app/Models/StandaloneKeydb.php@@ -75,6 +75,11 @@ class StandaloneKeydb extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.phpindex d88653e41c..c1e6c85d73 100644--- a/app/Models/StandaloneMariadb.php+++ b/app/Models/StandaloneMariadb.php@@ -75,6 +75,11 @@ class StandaloneMariadb extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.phpindex f09e932bff..e5ed0a5f4a 100644--- a/app/Models/StandaloneMongodb.php+++ b/app/Models/StandaloneMongodb.php@@ -79,6 +79,11 @@ class StandaloneMongodb extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.phpindex f4e56fab24..bd4a7abb7a 100644--- a/app/Models/StandaloneMysql.php+++ b/app/Models/StandaloneMysql.php@@ -76,6 +76,11 @@ class StandaloneMysql extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.phpindex 311c09c361..db771c7cdf 100644--- a/app/Models/StandalonePostgresql.php+++ b/app/Models/StandalonePostgresql.php@@ -102,6 +102,11 @@ class StandalonePostgresql extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.phpindex 8a202ea9eb..c524d4d03f 100644--- a/app/Models/StandaloneRedis.php+++ b/app/Models/StandaloneRedis.php@@ -71,6 +71,11 @@ class StandaloneRedis extends BaseModel}}+ public function isRunning()+ {+ return (bool) str($this->status)->contains('running');+ }+public function isExited(){return (bool) str($this->status)->startsWith('exited');diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.phpindex 5c6fe87fd5..c5ac0412ff 100644--- a/resources/views/livewire/project/service/configuration.blade.php+++ b/resources/views/livewire/project/service/configuration.blade.php@@ -3,8 +3,8 @@{{ data_get_str($service, 'name')->limit(10) }} > Configuration | Coolify</x-slot><livewire:project.service.navbar :service="$service" :parameters="$parameters" :query="$query" />- <div class="flex flex-col h-full gap-8 pt-6 sm:flex-row">- <div class="flex flex-col items-start gap-2 min-w-fit">+ <div class="flex flex-col gap-8 pt-6 h-full sm:flex-row">+ <div class="flex flex-col gap-2 items-start min-w-fit"><a class="menu-item sm:min-w-fit" target="_blank" href="{{ $service->documentation() }}">Documentation<x-external-link /></a><a class="menu-item sm:min-w-fit" :class="activeTab === 'service-stack' && 'menu-item-active'"@@ -23,10 +23,10 @@@click.prevent="activeTab = 'scheduled-tasks'; window.location.hash = 'scheduled-tasks'"href="#">Scheduled Tasks</a>- <a class="menu-item sm:min-w-fit" :class="activeTab === 'execute-command' && 'menu-item-active'"- @click.prevent="activeTab = 'execute-command';- window.location.hash = 'execute-command'"- href="#">Execute Command</a>+ <a class="menu-item sm:min-w-fit" :class="activeTab === 'terminal' && 'menu-item-active'"+ @click.prevent="activeTab = 'terminal';+ window.location.hash = 'terminal'"+ href="#">Terminal</a><a class="menu-item sm:min-w-fit" :class="activeTab === 'logs' && 'menu-item-active'"@click.prevent="activeTab = 'logs';window.location.hash = 'logs'"@@ -168,7 +168,7 @@</div></div><div x-cloak x-show="activeTab === 'storages'">- <div class="flex items-center gap-2">+ <div class="flex gap-2 items-center"><h2>Storages</h2></div><div class="pb-4">Persistent storage to preserve data between deployments.</div>@@ -191,7 +191,7 @@<div x-cloak x-show="activeTab === 'logs'"><livewire:project.shared.logs :resource="$service" /></div>- <div x-cloak x-show="activeTab === 'execute-command'">+ <div x-cloak x-show="activeTab === 'terminal'"><livewire:project.shared.execute-container-command :resource="$service" /></div><div x-cloak x-show="activeTab === 'environment-variables'">diff --git a/resources/views/livewire/project/shared/execute-container-command.blade.php b/resources/views/livewire/project/shared/execute-container-command.blade.phpindex c86133670a..b8bbecf7c2 100644--- a/resources/views/livewire/project/shared/execute-container-command.blade.php+++ b/resources/views/livewire/project/shared/execute-container-command.blade.php@@ -14,7 +14,7 @@@endif<div x-init="$wire.loadContainers"><div class="pt-4" wire:loading wire:target='loadContainers'>- Loading containers...+ Loading resources...</div><div wire:loading.remove wire:target='loadContainers'>@if (count($containers) > 0)@@ -22,24 +22,12 @@wire:submit="$dispatchSelf('connectToContainer')"><x-forms.select label="Container" id="container" required><option disabled selected>Select container</option>- @if (data_get($this->parameters, 'application_uuid'))- @foreach ($containers as $container)- <option value="{{ data_get($container, 'container.Names') }}">- {{ data_get($container, 'container.Names') }}- ({{ data_get($container, 'server.name') }})- </option>- @endforeach- @elseif(data_get($this->parameters, 'service_uuid'))- @foreach ($containers as $container)- <option value="{{ $container }}">- {{ $container }} ({{ data_get($servers, '0.name') }})- </option>- @endforeach- @else- <option value="{{ $container }}">- {{ $container }} ({{ data_get($servers, '0.name') }})+ @foreach ($containers as $container)+ <option value="{{ data_get($container, 'container.Names') }}">+ {{ data_get($container, 'container.Names') }}+ ({{ data_get($container, 'server.name') }})</option>- @endif+ @endforeach</x-forms.select><x-forms.button type="submit">Connect</x-forms.button></form>