Merge branch 'next' into fix/filebrowser-template

This commit is contained in:
Andras Bacsai
2024-09-30 14:16:01 +02:00
committed by GitHub
11 changed files with 215 additions and 47 deletions

View File

@@ -46,9 +46,6 @@ class StartDragonfly
'networks' => [ 'networks' => [
$this->database->destination->network, $this->database->destination->network,
], ],
'ulimits' => [
'memlock' => '-1',
],
'labels' => [ 'labels' => [
'coolify.managed' => 'true', 'coolify.managed' => 'true',
], ],

View File

@@ -11,6 +11,8 @@ use Livewire\Component;
class ExecuteContainerCommand extends Component class ExecuteContainerCommand extends Component
{ {
public $selected_container = 'default';
public $container; public $container;
public Collection $containers; public Collection $containers;
@@ -83,11 +85,14 @@ class ExecuteContainerCommand extends Component
$containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true); $containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true);
} }
foreach ($containers as $container) { foreach ($containers as $container) {
$payload = [ // if container state is running
'server' => $server, if (data_get($container, 'State') === 'running') {
'container' => $container, $payload = [
]; 'server' => $server,
$this->containers = $this->containers->push($payload); 'container' => $container,
];
$this->containers = $this->containers->push($payload);
}
} }
} elseif (data_get($this->parameters, 'database_uuid')) { } elseif (data_get($this->parameters, 'database_uuid')) {
if ($this->resource->isRunning()) { if ($this->resource->isRunning()) {
@@ -100,7 +105,6 @@ class ExecuteContainerCommand extends Component
} }
} elseif (data_get($this->parameters, 'service_uuid')) { } elseif (data_get($this->parameters, 'service_uuid')) {
$this->resource->applications()->get()->each(function ($application) { $this->resource->applications()->get()->each(function ($application) {
ray($application);
if ($application->isRunning()) { if ($application->isRunning()) {
$this->containers->push([ $this->containers->push([
'server' => $this->resource->server, 'server' => $this->resource->server,
@@ -131,9 +135,14 @@ class ExecuteContainerCommand extends Component
#[On('connectToContainer')] #[On('connectToContainer')]
public function connectToContainer() public function connectToContainer()
{ {
if ($this->selected_container === 'default') {
$this->dispatch('error', 'Please select a container.');
return;
}
try { try {
$container_name = data_get($this->container, 'container.Names'); $container = collect($this->containers)->firstWhere('container.Names', $this->selected_container);
if (is_null($container_name)) { if (is_null($container)) {
throw new \RuntimeException('Container not found.'); throw new \RuntimeException('Container not found.');
} }
$server = data_get($this->container, 'server'); $server = data_get($this->container, 'server');
@@ -141,11 +150,11 @@ class ExecuteContainerCommand extends Component
if ($server->isForceDisabled()) { if ($server->isForceDisabled()) {
throw new \RuntimeException('Server is disabled.'); throw new \RuntimeException('Server is disabled.');
} }
$this->dispatch(
$this->dispatch('send-terminal-command', 'send-terminal-command',
true, isset($container),
$container_name, data_get($container, 'container.Names'),
$server->uuid, data_get($container, 'server.uuid')
); );
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@@ -126,11 +126,6 @@ class EnvironmentVariable extends Model
$env = $this->get_real_environment_variables($this->value, $resource); $env = $this->get_real_environment_variables($this->value, $resource);
return data_get($env, 'value', $env); return data_get($env, 'value', $env);
if (is_string($env)) {
return $env;
}
return $env->value;
} }
); );
} }

View File

@@ -85,4 +85,17 @@ class InstanceSettings extends Model implements SendsEmail
return "[{$instanceName}]"; return "[{$instanceName}]";
} }
public function helperVersion(): Attribute
{
return Attribute::make(
get: function () {
if (isDev()) {
return 'latest';
}
return $this->helper_version;
}
);
}
} }

View File

@@ -1236,8 +1236,6 @@ function parseLineForSudo(string $command, Server $server): string
function get_public_ips() function get_public_ips()
{ {
try { try {
echo "Refreshing public ips!\n";
$settings = \App\Models\InstanceSettings::get();
[$first, $second] = Process::concurrently(function (Pool $pool) { [$first, $second] = Process::concurrently(function (Pool $pool) {
$pool->path(__DIR__)->command('curl -4s https://ifconfig.io'); $pool->path(__DIR__)->command('curl -4s https://ifconfig.io');
$pool->path(__DIR__)->command('curl -6s https://ifconfig.io'); $pool->path(__DIR__)->command('curl -6s https://ifconfig.io');
@@ -1251,7 +1249,7 @@ function get_public_ips()
return; return;
} }
$settings->update(['public_ipv4' => $ipv4]); InstanceSettings::get()->update(['public_ipv4' => $ipv4]);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
echo "Error: {$e->getMessage()}\n"; echo "Error: {$e->getMessage()}\n";
@@ -1266,7 +1264,7 @@ function get_public_ips()
return; return;
} }
$settings->update(['public_ipv6' => $ipv6]); InstanceSettings::get()->update(['public_ipv6' => $ipv6]);
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
echo "Error: {$e->getMessage()}\n"; echo "Error: {$e->getMessage()}\n";
@@ -3828,6 +3826,21 @@ function convertComposeEnvironmentToArray($environment)
{ {
$convertedServiceVariables = collect([]); $convertedServiceVariables = collect([]);
if (isAssociativeArray($environment)) { if (isAssociativeArray($environment)) {
if ($environment instanceof Collection) {
$changedEnvironment = collect([]);
$environment->each(function ($value, $key) use ($changedEnvironment) {
$parts = explode('=', $value, 2);
if (count($parts) === 2) {
$key = $parts[0];
$realValue = $parts[1] ?? '';
$changedEnvironment->put($key, $realValue);
} else {
$changedEnvironment->put($key, $value);
}
});
return $changedEnvironment;
}
$convertedServiceVariables = $environment; $convertedServiceVariables = $environment;
} else { } else {
foreach ($environment as $value) { foreach ($environment as $value) {

View File

@@ -48,6 +48,7 @@
"zircote/swagger-php": "^4.10" "zircote/swagger-php": "^4.10"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^3.13",
"fakerphp/faker": "^v1.21.0", "fakerphp/faker": "^v1.21.0",
"laravel/dusk": "^v8.0", "laravel/dusk": "^v8.0",
"laravel/pint": "^1.16", "laravel/pint": "^1.16",

154
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "96f8146407d0e6e897ff097c5eccd3a4", "content-hash": "42c28ab141b70fcabf75b51afa96c670",
"packages": [ "packages": [
{ {
"name": "amphp/amp", "name": "amphp/amp",
@@ -11823,6 +11823,90 @@
} }
], ],
"packages-dev": [ "packages-dev": [
{
"name": "barryvdh/laravel-debugbar",
"version": "v3.13.5",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "92d86be45ee54edff735e46856f64f14b6a8bb07"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/92d86be45ee54edff735e46856f64f14b6a8bb07",
"reference": "92d86be45ee54edff735e46856f64f14b6a8bb07",
"shasum": ""
},
"require": {
"illuminate/routing": "^9|^10|^11",
"illuminate/session": "^9|^10|^11",
"illuminate/support": "^9|^10|^11",
"maximebf/debugbar": "~1.22.0",
"php": "^8.0",
"symfony/finder": "^6|^7"
},
"require-dev": {
"mockery/mockery": "^1.3.3",
"orchestra/testbench-dusk": "^5|^6|^7|^8|^9",
"phpunit/phpunit": "^9.6|^10.5",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.13-dev"
},
"laravel": {
"providers": [
"Barryvdh\\Debugbar\\ServiceProvider"
],
"aliases": {
"Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Barryvdh\\Debugbar\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "PHP Debugbar integration for Laravel",
"keywords": [
"debug",
"debugbar",
"laravel",
"profiler",
"webprofiler"
],
"support": {
"issues": "https://github.com/barryvdh/laravel-debugbar/issues",
"source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.13.5"
},
"funding": [
{
"url": "https://fruitcake.nl",
"type": "custom"
},
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2024-04-12T11:20:37+00:00"
},
{ {
"name": "brianium/paratest", "name": "brianium/paratest",
"version": "v7.4.3", "version": "v7.4.3",
@@ -12301,6 +12385,74 @@
}, },
"time": "2024-09-03T15:00:28+00:00" "time": "2024-09-03T15:00:28+00:00"
}, },
{
"name": "maximebf/debugbar",
"version": "v1.22.5",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "1b5cabe0ce013134cf595bfa427bbf2f6abcd989"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/1b5cabe0ce013134cf595bfa427bbf2f6abcd989",
"reference": "1b5cabe0ce013134cf595bfa427bbf2f6abcd989",
"shasum": ""
},
"require": {
"php": "^7.2|^8",
"psr/log": "^1|^2|^3",
"symfony/var-dumper": "^4|^5|^6|^7"
},
"require-dev": {
"dbrekelmans/bdi": "^1",
"phpunit/phpunit": "^8|^9",
"symfony/panther": "^1|^2.1",
"twig/twig": "^1.38|^2.7|^3.0"
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
"monolog/monolog": "Log using Monolog",
"predis/predis": "Redis storage"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.22-dev"
}
},
"autoload": {
"psr-4": {
"DebugBar\\": "src/DebugBar/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "maxime.bouroumeau@gmail.com",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Debug bar in the browser for php application",
"homepage": "https://github.com/maximebf/php-debugbar",
"keywords": [
"debug",
"debugbar"
],
"support": {
"issues": "https://github.com/maximebf/php-debugbar/issues",
"source": "https://github.com/maximebf/php-debugbar/tree/v1.22.5"
},
"time": "2024-09-09T08:05:55+00:00"
},
{ {
"name": "mockery/mockery", "name": "mockery/mockery",
"version": "1.6.12", "version": "1.6.12",

View File

@@ -19,7 +19,6 @@ class PopulateSshKeysDirectorySeeder extends Seeder
PrivateKey::chunk(100, function ($keys) { PrivateKey::chunk(100, function ($keys) {
foreach ($keys as $key) { foreach ($keys as $key) {
echo 'Storing key: '.$key->name."\n";
$key->storeInFileSystem(); $key->storeInFileSystem();
} }
}); });

View File

@@ -101,18 +101,13 @@ class ProductionSeeder extends Seeder
} }
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) { if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {
echo "Checking localhost key.\n";
$coolify_key_name = '@host.docker.internal'; $coolify_key_name = '@host.docker.internal';
$ssh_keys_directory = Storage::disk('ssh-keys')->files(); $ssh_keys_directory = Storage::disk('ssh-keys')->files();
$coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name)); $coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
$found = PrivateKey::find(0); $server = Server::find(0);
if ($found) { $found = $server->privateKey;
echo 'Private Key found in database.\n'; if (! $found) {
if ($coolify_key) {
echo "SSH key found for the Coolify host machine (localhost).\n";
}
} else {
if ($coolify_key) { if ($coolify_key) {
$user = str($coolify_key)->before('@')->after('id.'); $user = str($coolify_key)->before('@')->after('id.');
$coolify_key = Storage::disk('ssh-keys')->get($coolify_key); $coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
@@ -125,17 +120,7 @@ class ProductionSeeder extends Seeder
]); ]);
$server->update(['user' => $user]); $server->update(['user' => $user]);
echo "SSH key found for the Coolify host machine (localhost).\n"; echo "SSH key found for the Coolify host machine (localhost).\n";
} else { } else {
PrivateKey::create(
[
'id' => 0,
'team_id' => 0,
'name' => 'localhost\'s key',
'description' => 'The private key for the Coolify host machine (localhost).',
'private_key' => 'Paste here you private key!!',
]
);
echo "No SSH key found for the Coolify host machine (localhost).\n"; echo "No SSH key found for the Coolify host machine (localhost).\n";
echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n"; echo "Please read the following documentation (point 3) to fix it: https://coolify.io/docs/knowledge-base/server/openssh/\n";
echo "Your localhost connection won't work until then."; echo "Your localhost connection won't work until then.";

View File

@@ -20,9 +20,11 @@
@if (count($containers) > 0) @if (count($containers) > 0)
<form class="flex flex-col gap-2 justify-center pt-4 xl:items-end xl:flex-row" <form class="flex flex-col gap-2 justify-center pt-4 xl:items-end xl:flex-row"
wire:submit="$dispatchSelf('connectToContainer')"> wire:submit="$dispatchSelf('connectToContainer')">
<x-forms.select label="Container" id="container" required> <x-forms.select label="Container" id="container" required wire:model="selected_container">
<option disabled selected>Select container</option>
@foreach ($containers as $container) @foreach ($containers as $container)
@if ($loop->first)
<option disabled value="default">Select a container</option>
@endif
<option value="{{ data_get($container, 'container.Names') }}"> <option value="{{ data_get($container, 'container.Names') }}">
{{ data_get($container, 'container.Names') }} {{ data_get($container, 'container.Names') }}
({{ data_get($container, 'server.name') }}) ({{ data_get($container, 'server.name') }})

2
storage/debugbar/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore