Skip to content

Commit e1037ac

Browse files
authored
Merge branch 'next' into fix/filebrowser-template
2 parents 606d46e + 88c2b1e commit e1037ac

File tree

11 files changed

+215
-47
lines changed

11 files changed

+215
-47
lines changed

app/Actions/Database/StartDragonfly.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public function handle(StandaloneDragonfly $database)
4646
'networks' => [
4747
$this->database->destination->network,
4848
],
49-
'ulimits' => [
50-
'memlock' => '-1',
51-
],
5249
'labels' => [
5350
'coolify.managed' => 'true',
5451
],

app/Livewire/Project/Shared/ExecuteContainerCommand.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class ExecuteContainerCommand extends Component
1313
{
14+
public $selected_container = 'default';
15+
1416
public $container;
1517

1618
public Collection $containers;
@@ -83,11 +85,14 @@ public function loadContainers()
8385
$containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true);
8486
}
8587
foreach ($containers as $container) {
86-
$payload = [
87-
'server' => $server,
88-
'container' => $container,
89-
];
90-
$this->containers = $this->containers->push($payload);
88+
// if container state is running
89+
if (data_get($container, 'State') === 'running') {
90+
$payload = [
91+
'server' => $server,
92+
'container' => $container,
93+
];
94+
$this->containers = $this->containers->push($payload);
95+
}
9196
}
9297
} elseif (data_get($this->parameters, 'database_uuid')) {
9398
if ($this->resource->isRunning()) {
@@ -100,7 +105,6 @@ public function loadContainers()
100105
}
101106
} elseif (data_get($this->parameters, 'service_uuid')) {
102107
$this->resource->applications()->get()->each(function ($application) {
103-
ray($application);
104108
if ($application->isRunning()) {
105109
$this->containers->push([
106110
'server' => $this->resource->server,
@@ -131,21 +135,26 @@ public function loadContainers()
131135
#[On('connectToContainer')]
132136
public function connectToContainer()
133137
{
138+
if ($this->selected_container === 'default') {
139+
$this->dispatch('error', 'Please select a container.');
140+
141+
return;
142+
}
134143
try {
135-
$container_name = data_get($this->container, 'container.Names');
136-
if (is_null($container_name)) {
144+
$container = collect($this->containers)->firstWhere('container.Names', $this->selected_container);
145+
if (is_null($container)) {
137146
throw new \RuntimeException('Container not found.');
138147
}
139148
$server = data_get($this->container, 'server');
140149

141150
if ($server->isForceDisabled()) {
142151
throw new \RuntimeException('Server is disabled.');
143152
}
144-
145-
$this->dispatch('send-terminal-command',
146-
true,
147-
$container_name,
148-
$server->uuid,
153+
$this->dispatch(
154+
'send-terminal-command',
155+
isset($container),
156+
data_get($container, 'container.Names'),
157+
data_get($container, 'server.uuid')
149158
);
150159

151160
} catch (\Throwable $e) {

app/Models/EnvironmentVariable.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ public function realValue(): Attribute
126126
$env = $this->get_real_environment_variables($this->value, $resource);
127127

128128
return data_get($env, 'value', $env);
129-
if (is_string($env)) {
130-
return $env;
131-
}
132-
133-
return $env->value;
134129
}
135130
);
136131
}

app/Models/InstanceSettings.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,17 @@ public function getTitleDisplayName(): string
8585

8686
return "[{$instanceName}]";
8787
}
88+
89+
public function helperVersion(): Attribute
90+
{
91+
return Attribute::make(
92+
get: function () {
93+
if (isDev()) {
94+
return 'latest';
95+
}
96+
97+
return $this->helper_version;
98+
}
99+
);
100+
}
88101
}

bootstrap/helpers/shared.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,6 @@ function parseLineForSudo(string $command, Server $server): string
12361236
function get_public_ips()
12371237
{
12381238
try {
1239-
echo "Refreshing public ips!\n";
1240-
$settings = \App\Models\InstanceSettings::get();
12411239
[$first, $second] = Process::concurrently(function (Pool $pool) {
12421240
$pool->path(__DIR__)->command('curl -4s https://ifconfig.io');
12431241
$pool->path(__DIR__)->command('curl -6s https://ifconfig.io');
@@ -1251,7 +1249,7 @@ function get_public_ips()
12511249

12521250
return;
12531251
}
1254-
$settings->update(['public_ipv4' => $ipv4]);
1252+
InstanceSettings::get()->update(['public_ipv4' => $ipv4]);
12551253
}
12561254
} catch (\Exception $e) {
12571255
echo "Error: {$e->getMessage()}\n";
@@ -1266,7 +1264,7 @@ function get_public_ips()
12661264

12671265
return;
12681266
}
1269-
$settings->update(['public_ipv6' => $ipv6]);
1267+
InstanceSettings::get()->update(['public_ipv6' => $ipv6]);
12701268
}
12711269
} catch (\Throwable $e) {
12721270
echo "Error: {$e->getMessage()}\n";
@@ -3828,6 +3826,21 @@ function convertComposeEnvironmentToArray($environment)
38283826
{
38293827
$convertedServiceVariables = collect([]);
38303828
if (isAssociativeArray($environment)) {
3829+
if ($environment instanceof Collection) {
3830+
$changedEnvironment = collect([]);
3831+
$environment->each(function ($value, $key) use ($changedEnvironment) {
3832+
$parts = explode('=', $value, 2);
3833+
if (count($parts) === 2) {
3834+
$key = $parts[0];
3835+
$realValue = $parts[1] ?? '';
3836+
$changedEnvironment->put($key, $realValue);
3837+
} else {
3838+
$changedEnvironment->put($key, $value);
3839+
}
3840+
});
3841+
3842+
return $changedEnvironment;
3843+
}
38313844
$convertedServiceVariables = $environment;
38323845
} else {
38333846
foreach ($environment as $value) {

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"zircote/swagger-php": "^4.10"
4949
},
5050
"require-dev": {
51+
"barryvdh/laravel-debugbar": "^3.13",
5152
"fakerphp/faker": "^v1.21.0",
5253
"laravel/dusk": "^v8.0",
5354
"laravel/pint": "^1.16",

composer.lock

Lines changed: 153 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

database/seeders/PopulateSshKeysDirectorySeeder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function run()
1919

2020
PrivateKey::chunk(100, function ($keys) {
2121
foreach ($keys as $key) {
22-
echo 'Storing key: '.$key->name."\n";
2322
$key->storeInFileSystem();
2423
}
2524
});

database/seeders/ProductionSeeder.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,13 @@ public function run(): void
101101
}
102102

103103
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {
104-
echo "Checking localhost key.\n";
105104
$coolify_key_name = '@host.docker.internal';
106105
$ssh_keys_directory = Storage::disk('ssh-keys')->files();
107106
$coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
108107

109-
$found = PrivateKey::find(0);
110-
if ($found) {
111-
echo 'Private Key found in database.\n';
112-
if ($coolify_key) {
113-
echo "SSH key found for the Coolify host machine (localhost).\n";
114-
}
115-
} else {
108+
$server = Server::find(0);
109+
$found = $server->privateKey;
110+
if (! $found) {
116111
if ($coolify_key) {
117112
$user = str($coolify_key)->before('@')->after('id.');
118113
$coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
@@ -125,17 +120,7 @@ public function run(): void
125120
]);
126121
$server->update(['user' => $user]);
127122
echo "SSH key found for the Coolify host machine (localhost).\n";
128-
129123
} else {
130-
PrivateKey::create(
131-
[
132-
'id' => 0,
133-
'team_id' => 0,
134-
'name' => 'localhost\'s key',
135-
'description' => 'The private key for the Coolify host machine (localhost).',
136-
'private_key' => 'Paste here you private key!!',
137-
]
138-
);
139124
echo "No SSH key found for the Coolify host machine (localhost).\n";
140125
echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n";
141126
echo "Your localhost connection won't work until then.";

0 commit comments

Comments
 (0)