Skip to content

Commit 6f57885

Browse files
authored
Merge pull request coollabsio#3463 from coollabsio/next
v4.0.0-beta.388
2 parents b2bab45 + 8967315 commit 6f57885

File tree

13 files changed

+110
-145
lines changed

13 files changed

+110
-145
lines changed

app/Livewire/RunCommand.php

Lines changed: 0 additions & 101 deletions
This file was deleted.

app/Livewire/Terminal/Index.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,70 @@
33
namespace App\Livewire\Terminal;
44

55
use App\Models\Server;
6+
use Livewire\Attributes\On;
67
use Livewire\Component;
78

89
class Index extends Component
910
{
11+
public $selected_uuid = 'default';
12+
1013
public $servers = [];
1114

15+
public $containers = [];
16+
1217
public function mount()
1318
{
19+
if (! auth()->user()->isAdmin()) {
20+
abort(403);
21+
}
1422
$this->servers = Server::isReachable()->get();
23+
$this->containers = $this->getAllActiveContainers();
24+
}
25+
26+
private function getAllActiveContainers()
27+
{
28+
return collect($this->servers)->flatMap(function ($server) {
29+
if (! $server->isFunctional()) {
30+
return [];
31+
}
32+
33+
return $server->loadAllContainers()->map(function ($container) use ($server) {
34+
$state = data_get_str($container, 'State')->lower();
35+
if ($state->contains('running')) {
36+
return [
37+
'name' => data_get($container, 'Names'),
38+
'connection_name' => data_get($container, 'Names'),
39+
'uuid' => data_get($container, 'Names'),
40+
'status' => data_get_str($container, 'State')->lower(),
41+
'server' => $server,
42+
'server_uuid' => $server->uuid,
43+
];
44+
}
45+
46+
return null;
47+
})->filter();
48+
});
49+
}
50+
51+
public function updatedSelectedUuid()
52+
{
53+
$this->connectToContainer();
54+
}
55+
56+
#[On('connectToContainer')]
57+
public function connectToContainer()
58+
{
59+
if ($this->selected_uuid === 'default') {
60+
$this->dispatch('error', 'Please select a server or a container.');
61+
62+
return;
63+
}
64+
$container = collect($this->containers)->firstWhere('uuid', $this->selected_uuid);
65+
$this->dispatch('send-terminal-command',
66+
isset($container),
67+
$container['connection_name'] ?? $this->selected_uuid,
68+
$container['server_uuid'] ?? $this->selected_uuid
69+
);
1570
}
1671

1772
public function render()

app/Models/Server.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,18 @@ public function getContainersWithSentinel(): Collection
775775
}
776776
}
777777

778+
public function loadAllContainers(): Collection
779+
{
780+
if ($this->isFunctional()) {
781+
$containers = instant_remote_process(["docker ps -a --format '{{json .}}'"], $this);
782+
$containers = format_docker_command_output_to_json($containers);
783+
784+
return collect($containers);
785+
}
786+
787+
return collect([]);
788+
}
789+
778790
public function loadUnmanagedContainers(): Collection
779791
{
780792
if ($this->isFunctional()) {

config/sentry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// The release version of your application
99
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
10-
'release' => '4.0.0-beta.337',
10+
'release' => '4.0.0-beta.338',
1111
// When left empty or `null` the Laravel environment will be used
1212
'environment' => config('app.env'),
1313

config/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
return '4.0.0-beta.337';
3+
return '4.0.0-beta.338';

docker-compose.prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ services:
110110
retries: 10
111111
timeout: 2s
112112
soketi:
113-
image: 'ghcr.io/coollabsio/coolify-realtime:1.0.0'
113+
image: 'ghcr.io/coollabsio/coolify-realtime:1.0.1'
114114
ports:
115115
- "${SOKETI_PORT:-6001}:6001"
116116
- "6002:6002"
@@ -123,7 +123,7 @@ services:
123123
SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}"
124124
SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}"
125125
healthcheck:
126-
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:6001/ready && wget -qO- http://127.0.0.1:6002/ready || exit 1"]
126+
test: [ "CMD-SHELL", "wget -qO- http://127.0.0.1:6001/ready && wget -qO- http://127.0.0.1:6002/ready || exit 1" ]
127127
interval: 5s
128128
retries: 10
129129
timeout: 2s

docker/coolify-realtime/terminal-server.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ async function handleCommand(ws, command, userId) {
123123
cols: 80,
124124
rows: 30,
125125
cwd: process.env.HOME,
126-
env: process.env
127126
};
128127

129128
// NOTE: - Initiates a process within the Terminal container

other/nightly/docker-compose.prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ services:
110110
retries: 10
111111
timeout: 2s
112112
soketi:
113-
image: 'ghcr.io/coollabsio/coolify-realtime:1.0.0'
113+
image: 'ghcr.io/coollabsio/coolify-realtime:1.0.1'
114114
ports:
115115
- "${SOKETI_PORT:-6001}:6001"
116116
- "6002:6002"
@@ -123,7 +123,7 @@ services:
123123
SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}"
124124
SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}"
125125
healthcheck:
126-
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:6001/ready && wget -qO- http://127.0.0.1:6002/ready || exit 1"]
126+
test: [ "CMD-SHELL", "wget -qO- http://127.0.0.1:6001/ready && wget -qO- http://127.0.0.1:6002/ready || exit 1" ]
127127
interval: 5s
128128
retries: 10
129129
timeout: 2s

other/nightly/versions.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"coolify": {
33
"v4": {
4-
"version": "4.0.0-beta.337"
4+
"version": "4.0.0-beta.338"
55
},
66
"nightly": {
7-
"version": "4.0.0-beta.338"
7+
"version": "4.0.0-beta.339"
88
},
99
"helper": {
1010
"version": "1.0.1"
1111
},
1212
"realtime": {
13-
"version": "1.0.0"
13+
"version": "1.0.1"
1414
}
1515
}
1616
}

resources/views/livewire/project/shared/terminal.blade.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ function initializeWebSocket() {
6767
socket.onerror = (e) => {
6868
console.error('WebSocket error:', e);
6969
};
70+
socket.onclose = () => {
71+
console.log('WebSocket connection closed');
72+
setInterval(() => {
73+
$wire.dispatch('error', 'Connection to terminal lost, please refresh the page.');
74+
}, 2000);
75+
};
7076
}
7177
}
7278
@@ -209,8 +215,8 @@ function checkIfProcessIsRunningAndKillIt() {
209215
term.resize(termWidth, termHeight);
210216
socket.send(JSON.stringify({
211217
resize: {
212-
cols: termWidth,
213-
rows: termHeight
218+
cols: 600,
219+
rows: 600
214220
}
215221
}));
216222
}

0 commit comments

Comments
 (0)