Merge pull request #1008 from coollabsio/servers-and-private-keys

Servers and private keys
This commit is contained in:
Andras Bacsai 2023-03-27 09:49:18 +02:00 committed by GitHub
commit ca0a3974e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 425 additions and 187 deletions

View File

@ -13,7 +13,7 @@ class DispatchRemoteProcess
public function __construct(RemoteProcessArgs $remoteProcessArgs){
$this->activity = activity()
->withProperties($remoteProcessArgs->toArray())
->log("Awaiting command to start...\n\n");
->log("");
}
public function __invoke(): Activity

View File

@ -64,20 +64,24 @@ class RunRemoteProcess
{
$user = $this->activity->getExtraProperty('user');
$destination = $this->activity->getExtraProperty('destination');
$private_key_location = $this->activity->getExtraProperty('private_key_location');
$port = $this->activity->getExtraProperty('port');
$command = $this->activity->getExtraProperty('command');
$delimiter = 'EOF-COOLIFY-SSH';
return 'ssh '
$ssh_command = "ssh "
. "-i {$private_key_location} "
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
. '-o PasswordAuthentication=no '
. '-o RequestTTY=no '
. "-o LogLevel=ERROR "
. "-p {$port} "
. "{$user}@{$destination} "
. " 'bash -se' << \\$delimiter" . PHP_EOL
. $command . PHP_EOL
. $delimiter;
return $ssh_command;
}
protected function handleOutput(string $type, string $output)

View File

@ -10,6 +10,7 @@ class RemoteProcessArgs extends Data
{
public function __construct(
public string $destination,
public string $private_key_location,
public string $command,
public int $port,
public string $user,

View File

@ -2,6 +2,7 @@
namespace App\Http\Livewire;
use App\Models\Server;
use Livewire\Component;
class RunCommand extends Component
@ -14,6 +15,14 @@ class RunCommand extends Component
public $command = 'ls';
public $server = 'testing-host';
public $servers = [];
public function mount()
{
$this->servers = Server::all()->pluck('name')->toArray();
}
public function render()
{
return view('livewire.run-command');
@ -23,14 +32,14 @@ class RunCommand extends Component
{
$this->isKeepAliveOn = true;
$this->activity = remoteProcess($this->command, 'testing-host');
$this->activity = remoteProcess($this->command, $this->server);
}
public function runSleepingBeauty()
{
$this->isKeepAliveOn = true;
$this->activity = remoteProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', 'testing-host');
$this->activity = remoteProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', $this->server);
}
public function runDummyProjectBuild()
@ -40,7 +49,7 @@ class RunCommand extends Component
$this->activity = remoteProcess(<<<EOT
cd projects/dummy-project
~/.docker/cli-plugins/docker-compose build --no-cache
EOT, 'testing-host');
EOT, $this->server);
}
public function polling()

View File

@ -31,5 +31,6 @@ class ExecuteRemoteProcess implements ShouldQueue
]);
$remoteProcess();
// @TODO: Remove file at $this->activity->getExtraProperty('private_key_location') after process is finished
}
}

View File

@ -3,7 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Xaevik\Cuid2\Cuid2;
use Visus\Cuid2\Cuid2;
abstract class BaseModel extends Model
{
@ -15,4 +15,4 @@ abstract class BaseModel extends Model
$model->uuid = (string) new Cuid2();
});
}
}
}

16
app/Models/PrivateKey.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace App\Models;
class PrivateKey extends BaseModel
{
public function private_keyables()
{
return $this->hasMany(PrivateKeyable::class);
}
public function servers()
{
return $this->morphedByMany(Server::class, 'private_keyable');
}
}

11
app/Models/Server.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
class Server extends BaseModel
{
public function privateKeys()
{
return $this->morphToMany(PrivateKey::class, 'private_keyable');
}
}

View File

@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Xaevik\Cuid2\Cuid2;
use Visus\Cuid2\Cuid2;
class User extends Authenticatable
{

View File

@ -2,28 +2,50 @@
use App\Actions\RemoteProcess\DispatchRemoteProcess;
use App\Data\RemoteProcessArgs;
use App\Models\Server;
use Illuminate\Support\Facades\Storage;
use Spatie\Activitylog\Contracts\Activity;
if (! function_exists('remoteProcess')) {
if (!function_exists('remoteProcess')) {
/**
* Run a Coolify Process, which SSH's asynchronously into a machine to run the command(s).
* Run a Remote Process, which SSH's asynchronously into a machine to run the command(s).
* @TODO Change 'root' to 'coolify' when it's able to run Docker commands without sudo
*
*/
function remoteProcess(
string $command,
string $destination,
?int $port = 22,
?string $user = 'root',
): Activity
{
string $destination
): Activity {
$found_server = checkServer($destination);
checkTeam($found_server->team_id);
$temp_file = 'id.rsa_'.'root'.'@'.$found_server->ip;
Storage::disk('local')->put($temp_file, $found_server->privateKeys->first()->private_key, 'private');
$private_key_location = '/var/www/html/storage/app/'.$temp_file;
return resolve(DispatchRemoteProcess::class, [
'remoteProcessArgs' => new RemoteProcessArgs(
destination: $destination,
destination: $found_server->ip,
private_key_location: $private_key_location,
command: $command,
port: $port,
user: $user,
port: $found_server->port,
user: $found_server->user,
),
])();
}
function checkServer(string $destination){
// @TODO: Use UUID instead of name
$found_server = Server::where('name', $destination)->first();
if (!$found_server) {
throw new \RuntimeException('Server not found.');
};
return $found_server;
}
function checkTeam(string $team_id){
$found_team = auth()->user()->teams->pluck('id')->contains($team_id);
if (!$found_team) {
throw new \RuntimeException('You do not have access to this server.');
}
}
}

View File

@ -15,7 +15,7 @@
"spatie/laravel-activitylog": "^4.7",
"spatie/laravel-data": "^3.2",
"spatie/laravel-ray": "^1.32",
"xaevik/cuid2": "^1.7"
"visus/cuid2": "^2.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",

309
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0860841db6def79a62c268b0858d1f8a",
"content-hash": "82e138615877e8bffa63f91428b555d2",
"packages": [
{
"name": "bacon/bacon-qr-code",
@ -1193,16 +1193,16 @@
},
{
"name": "laravel/framework",
"version": "v10.3.3",
"version": "v10.4.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "90f24d9e2860ecf6b5492e966956270ceb98c03d"
"reference": "7d15f7eef442633cff108f83d9fe43d8c3b8b76f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/90f24d9e2860ecf6b5492e966956270ceb98c03d",
"reference": "90f24d9e2860ecf6b5492e966956270ceb98c03d",
"url": "https://api.github.com/repos/laravel/framework/zipball/7d15f7eef442633cff108f83d9fe43d8c3b8b76f",
"reference": "7d15f7eef442633cff108f83d9fe43d8c3b8b76f",
"shasum": ""
},
"require": {
@ -1301,7 +1301,7 @@
"league/flysystem-read-only": "^3.3",
"league/flysystem-sftp-v3": "^3.0",
"mockery/mockery": "^1.5.1",
"orchestra/testbench-core": "^8.0",
"orchestra/testbench-core": "^8.1",
"pda/pheanstalk": "^4.0",
"phpstan/phpdoc-parser": "^1.15",
"phpstan/phpstan": "^1.4.7",
@ -1389,7 +1389,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2023-03-09T14:00:53+00:00"
"time": "2023-03-18T11:34:02+00:00"
},
{
"name": "laravel/sanctum",
@ -1586,16 +1586,16 @@
},
{
"name": "league/commonmark",
"version": "2.3.9",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5"
"reference": "d44a24690f16b8c1808bf13b1bd54ae4c63ea048"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/c1e114f74e518daca2729ea8c4bf1167038fa4b5",
"reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d44a24690f16b8c1808bf13b1bd54ae4c63ea048",
"reference": "d44a24690f16b8c1808bf13b1bd54ae4c63ea048",
"shasum": ""
},
"require": {
@ -1631,7 +1631,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.4-dev"
"dev-main": "2.5-dev"
}
},
"autoload": {
@ -1688,7 +1688,7 @@
"type": "tidelift"
}
],
"time": "2023-02-15T14:07:24+00:00"
"time": "2023-03-24T15:16:10+00:00"
},
{
"name": "league/config",
@ -3255,16 +3255,16 @@
},
{
"name": "psy/psysh",
"version": "v0.11.12",
"version": "v0.11.13",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "52cb7c47d403c31c0adc9bf7710fc355f93c20f7"
"reference": "722317c9f5627e588788e340f29b923e58f92f54"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/52cb7c47d403c31c0adc9bf7710fc355f93c20f7",
"reference": "52cb7c47d403c31c0adc9bf7710fc355f93c20f7",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/722317c9f5627e588788e340f29b923e58f92f54",
"reference": "722317c9f5627e588788e340f29b923e58f92f54",
"shasum": ""
},
"require": {
@ -3325,9 +3325,9 @@
],
"support": {
"issues": "https://github.com/bobthecow/psysh/issues",
"source": "https://github.com/bobthecow/psysh/tree/v0.11.12"
"source": "https://github.com/bobthecow/psysh/tree/v0.11.13"
},
"time": "2023-01-29T21:24:40+00:00"
"time": "2023-03-21T14:22:44+00:00"
},
{
"name": "ralouphie/getallheaders",
@ -3709,16 +3709,16 @@
},
{
"name": "spatie/laravel-data",
"version": "3.2.0",
"version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-data.git",
"reference": "c4f632924870e52beefe982aa50a88ff59250bfd"
"reference": "b6b9d964c37263083e09ade16a9ebe613f4ed5ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-data/zipball/c4f632924870e52beefe982aa50a88ff59250bfd",
"reference": "c4f632924870e52beefe982aa50a88ff59250bfd",
"url": "https://api.github.com/repos/spatie/laravel-data/zipball/b6b9d964c37263083e09ade16a9ebe613f4ed5ec",
"reference": "b6b9d964c37263083e09ade16a9ebe613f4ed5ec",
"shasum": ""
},
"require": {
@ -3780,7 +3780,7 @@
],
"support": {
"issues": "https://github.com/spatie/laravel-data/issues",
"source": "https://github.com/spatie/laravel-data/tree/3.2.0"
"source": "https://github.com/spatie/laravel-data/tree/3.2.1"
},
"funding": [
{
@ -3788,7 +3788,7 @@
"type": "github"
}
],
"time": "2023-03-17T09:48:15+00:00"
"time": "2023-03-24T08:31:07+00:00"
},
{
"name": "spatie/laravel-package-tools",
@ -3852,16 +3852,16 @@
},
{
"name": "spatie/laravel-ray",
"version": "1.32.3",
"version": "1.32.4",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-ray.git",
"reference": "8c7ea86c8092bcfe7a046f640b6ac9e5d7ec98cd"
"reference": "2274653f0a90dd87fbb887437be1c1ea1388a47c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-ray/zipball/8c7ea86c8092bcfe7a046f640b6ac9e5d7ec98cd",
"reference": "8c7ea86c8092bcfe7a046f640b6ac9e5d7ec98cd",
"url": "https://api.github.com/repos/spatie/laravel-ray/zipball/2274653f0a90dd87fbb887437be1c1ea1388a47c",
"reference": "2274653f0a90dd87fbb887437be1c1ea1388a47c",
"shasum": ""
},
"require": {
@ -3921,7 +3921,7 @@
],
"support": {
"issues": "https://github.com/spatie/laravel-ray/issues",
"source": "https://github.com/spatie/laravel-ray/tree/1.32.3"
"source": "https://github.com/spatie/laravel-ray/tree/1.32.4"
},
"funding": [
{
@ -3933,7 +3933,7 @@
"type": "other"
}
],
"time": "2023-03-03T13:37:21+00:00"
"time": "2023-03-23T08:04:54+00:00"
},
{
"name": "spatie/macroable",
@ -6454,6 +6454,65 @@
},
"time": "2023-01-03T09:29:04+00:00"
},
{
"name": "visus/cuid2",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/visus-io/php-cuid2.git",
"reference": "907919cadd8dfeb24ffecf7209ec4988fb9b3fc0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/visus-io/php-cuid2/zipball/907919cadd8dfeb24ffecf7209ec4988fb9b3fc0",
"reference": "907919cadd8dfeb24ffecf7209ec4988fb9b3fc0",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.29",
"ext-ctype": "*",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.7",
"vimeo/psalm": "^5.4"
},
"suggest": {
"ext-gmp": "*"
},
"type": "library",
"autoload": {
"files": [
"src/compat.php"
],
"psr-4": {
"Visus\\Cuid2\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Alan Brault",
"email": "alan.brault@visus.io"
}
],
"description": "A PHP library for generating collision-resistant ids (CUIDs).",
"keywords": [
"cuid",
"identifier"
],
"support": {
"issues": "https://github.com/visus-io/php-cuid2/issues",
"source": "https://github.com/visus-io/php-cuid2/tree/2.0.0"
},
"time": "2023-03-23T19:18:36+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v5.5.0",
@ -6670,62 +6729,6 @@
},
"time": "2022-06-03T18:03:27+00:00"
},
{
"name": "xaevik/cuid2",
"version": "1.7.0",
"source": {
"type": "git",
"url": "git@gitlab.com:xaevik/php-cuid2.git",
"reference": "e435e5005b2e9e9e9d30b64025749c0b7aa5dcf7"
},
"dist": {
"type": "zip",
"url": "https://gitlab.com/api/v4/projects/xaevik%2Fphp-cuid2/repository/archive.zip?sha=e435e5005b2e9e9e9d30b64025749c0b7aa5dcf7",
"reference": "e435e5005b2e9e9e9d30b64025749c0b7aa5dcf7",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.29",
"ext-ctype": "*",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.7",
"vimeo/psalm": "^5.4"
},
"suggest": {
"ext-gmp": "*"
},
"type": "library",
"autoload": {
"files": [
"src/compat.php"
],
"psr-4": {
"Xaevik\\Cuid2\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Alan Brault",
"email": "alan.brault@visus.io"
}
],
"description": "A PHP library for generating collision-resistant ids (CUIDs).",
"keywords": [
"cuid",
"identifier"
],
"abandoned": "visus/cuid2",
"time": "2023-02-21T14:01:02+00:00"
},
{
"name": "zbateson/mail-mime-parser",
"version": "2.4.0",
@ -7342,16 +7345,16 @@
},
{
"name": "laravel/pint",
"version": "v1.6.0",
"version": "v1.7.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/pint.git",
"reference": "e48e3fadd7863d6b7d03464f5c4f211a828b890f"
"reference": "d55381c73b7308e1b8a124084e804193a179092e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/e48e3fadd7863d6b7d03464f5c4f211a828b890f",
"reference": "e48e3fadd7863d6b7d03464f5c4f211a828b890f",
"url": "https://api.github.com/repos/laravel/pint/zipball/d55381c73b7308e1b8a124084e804193a179092e",
"reference": "d55381c73b7308e1b8a124084e804193a179092e",
"shasum": ""
},
"require": {
@ -7404,7 +7407,7 @@
"issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint"
},
"time": "2023-02-21T15:44:57+00:00"
"time": "2023-03-21T10:55:35+00:00"
},
{
"name": "laravel/sail",
@ -7667,16 +7670,16 @@
},
{
"name": "nunomaduro/collision",
"version": "v7.2.0",
"version": "v7.3.3",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/collision.git",
"reference": "8ee125cb0888cf694b559caa015e104f577bb4f0"
"reference": "c680af93e414110b36056029f63120e6bc78f6e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/8ee125cb0888cf694b559caa015e104f577bb4f0",
"reference": "8ee125cb0888cf694b559caa015e104f577bb4f0",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/c680af93e414110b36056029f63120e6bc78f6e3",
"reference": "c680af93e414110b36056029f63120e6bc78f6e3",
"shasum": ""
},
"require": {
@ -7686,19 +7689,19 @@
"symfony/console": "^6.2.7"
},
"conflict": {
"phpunit/phpunit": "<10.0.16"
"phpunit/phpunit": "<10.0.17"
},
"require-dev": {
"brianium/paratest": "^7.1.1",
"brianium/paratest": "^7.1.2",
"laravel/framework": "^10.4.1",
"laravel/pint": "^1.6.0",
"laravel/pint": "^1.7.0",
"laravel/sail": "^1.21.2",
"laravel/sanctum": "^3.2.1",
"laravel/tinker": "^2.8.1",
"nunomaduro/larastan": "^2.5.1",
"orchestra/testbench-core": "^8.1.0",
"pestphp/pest": "^2.0.0",
"phpunit/phpunit": "^10.0.16",
"orchestra/testbench-core": "^8.1.1",
"pestphp/pest": "^2.0.2",
"phpunit/phpunit": "^10.0.17",
"sebastian/environment": "^6.0.0",
"spatie/laravel-ignition": "^2.0.0"
},
@ -7759,33 +7762,33 @@
"type": "patreon"
}
],
"time": "2023-03-19T17:08:17+00:00"
"time": "2023-03-23T21:41:35+00:00"
},
{
"name": "pestphp/pest",
"version": "v2.0.2",
"version": "v2.2.3",
"source": {
"type": "git",
"url": "https://github.com/pestphp/pest.git",
"reference": "9d0cd32e3f9286d03f66636a395632972a66a52e"
"reference": "6c8970e0a3b9bb36544bb1eacba0a4175dbafe97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pestphp/pest/zipball/9d0cd32e3f9286d03f66636a395632972a66a52e",
"reference": "9d0cd32e3f9286d03f66636a395632972a66a52e",
"url": "https://api.github.com/repos/pestphp/pest/zipball/6c8970e0a3b9bb36544bb1eacba0a4175dbafe97",
"reference": "6c8970e0a3b9bb36544bb1eacba0a4175dbafe97",
"shasum": ""
},
"require": {
"brianium/paratest": "^7.1.2",
"nunomaduro/collision": "^7.2.0",
"nunomaduro/collision": "^7.3.3",
"nunomaduro/termwind": "^1.15.1",
"pestphp/pest-plugin": "^2.0.0",
"pestphp/pest-plugin-arch": "^2.0.1",
"pestphp/pest-plugin": "^2.0.1",
"pestphp/pest-plugin-arch": "^2.0.2",
"php": "^8.1.0",
"phpunit/phpunit": "^10.0.17"
"phpunit/phpunit": "^10.0.18"
},
"conflict": {
"phpunit/phpunit": ">10.0.17",
"phpunit/phpunit": ">10.0.18",
"webmozart/assert": "<1.11.0"
},
"require-dev": {
@ -7806,6 +7809,7 @@
"Pest\\Plugins\\Environment",
"Pest\\Plugins\\Help",
"Pest\\Plugins\\Memory",
"Pest\\Plugins\\Only",
"Pest\\Plugins\\Printer",
"Pest\\Plugins\\ProcessIsolation",
"Pest\\Plugins\\Profile",
@ -7845,7 +7849,7 @@
],
"support": {
"issues": "https://github.com/pestphp/pest/issues",
"source": "https://github.com/pestphp/pest/tree/v2.0.2"
"source": "https://github.com/pestphp/pest/tree/v2.2.3"
},
"funding": [
{
@ -7857,20 +7861,20 @@
"type": "github"
}
],
"time": "2023-03-20T17:52:35+00:00"
"time": "2023-03-24T11:26:54+00:00"
},
{
"name": "pestphp/pest-plugin",
"version": "v2.0.0",
"version": "v2.0.1",
"source": {
"type": "git",
"url": "https://github.com/pestphp/pest-plugin.git",
"reference": "e46455b40f620f5d29e1b0bdbc41ae8b7506d4fd"
"reference": "e3a3da262b73bdcbf3fad4dc9846c3c4921f2147"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/e46455b40f620f5d29e1b0bdbc41ae8b7506d4fd",
"reference": "e46455b40f620f5d29e1b0bdbc41ae8b7506d4fd",
"url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/e3a3da262b73bdcbf3fad4dc9846c3c4921f2147",
"reference": "e3a3da262b73bdcbf3fad4dc9846c3c4921f2147",
"shasum": ""
},
"require": {
@ -7878,11 +7882,11 @@
"php": "^8.1"
},
"conflict": {
"pestphp/pest": "<2.0"
"pestphp/pest": "<2.2.3"
},
"require-dev": {
"composer/composer": "^2.5.4",
"pestphp/pest": "^2.0.0",
"composer/composer": "^2.5.5",
"pestphp/pest": "^2.2.3",
"pestphp/pest-dev-tools": "^2.5.0"
},
"type": "composer-plugin",
@ -7910,7 +7914,7 @@
"unit"
],
"support": {
"source": "https://github.com/pestphp/pest-plugin/tree/v2.0.0"
"source": "https://github.com/pestphp/pest-plugin/tree/v2.0.1"
},
"funding": [
{
@ -7926,29 +7930,29 @@
"type": "patreon"
}
],
"time": "2023-03-20T10:01:55+00:00"
"time": "2023-03-24T11:21:05+00:00"
},
{
"name": "pestphp/pest-plugin-arch",
"version": "v2.0.1",
"version": "v2.0.2",
"source": {
"type": "git",
"url": "https://github.com/pestphp/pest-plugin-arch.git",
"reference": "8bb489c635b386188bf725b0fd0415262d633903"
"reference": "02ce3fd7cf795f30be72cb4935f6ad99b077d278"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/8bb489c635b386188bf725b0fd0415262d633903",
"reference": "8bb489c635b386188bf725b0fd0415262d633903",
"url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/02ce3fd7cf795f30be72cb4935f6ad99b077d278",
"reference": "02ce3fd7cf795f30be72cb4935f6ad99b077d278",
"shasum": ""
},
"require": {
"pestphp/pest-plugin": "^2.0.0",
"php": "^8.1",
"ta-tikoma/phpunit-architecture-test": "^0.7.1"
"ta-tikoma/phpunit-architecture-test": "^0.7.2"
},
"require-dev": {
"pestphp/pest": "^2.0.1",
"pestphp/pest": "^2.2.2",
"pestphp/pest-dev-tools": "^2.5.0"
},
"type": "library",
@ -7977,7 +7981,7 @@
"unit"
],
"support": {
"source": "https://github.com/pestphp/pest-plugin-arch/tree/v2.0.1"
"source": "https://github.com/pestphp/pest-plugin-arch/tree/v2.0.2"
},
"funding": [
{
@ -7989,7 +7993,7 @@
"type": "github"
}
],
"time": "2023-03-20T15:14:41+00:00"
"time": "2023-03-24T11:18:19+00:00"
},
{
"name": "phar-io/manifest",
@ -8479,16 +8483,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.0.17",
"version": "10.0.18",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "b75eddcabca052312ae38c8a2bc69ff1a7b89b77"
"reference": "582563ed2edc62d1455cdbe00ea49fe09428eef3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b75eddcabca052312ae38c8a2bc69ff1a7b89b77",
"reference": "b75eddcabca052312ae38c8a2bc69ff1a7b89b77",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/582563ed2edc62d1455cdbe00ea49fe09428eef3",
"reference": "582563ed2edc62d1455cdbe00ea49fe09428eef3",
"shasum": ""
},
"require": {
@ -8560,7 +8564,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.0.17"
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.0.18"
},
"funding": [
{
@ -8576,7 +8580,7 @@
"type": "tidelift"
}
],
"time": "2023-03-20T14:42:33+00:00"
"time": "2023-03-22T06:15:31+00:00"
},
{
"name": "sebastian/cli-parser",
@ -8880,16 +8884,16 @@
},
{
"name": "sebastian/diff",
"version": "5.0.0",
"version": "5.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "70dd1b20bc198da394ad542e988381b44e64e39f"
"reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/70dd1b20bc198da394ad542e988381b44e64e39f",
"reference": "70dd1b20bc198da394ad542e988381b44e64e39f",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/aae9a0a43bff37bd5d8d0311426c87bf36153f02",
"reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02",
"shasum": ""
},
"require": {
@ -8934,7 +8938,8 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/5.0.0"
"security": "https://github.com/sebastianbergmann/diff/security/policy",
"source": "https://github.com/sebastianbergmann/diff/tree/5.0.1"
},
"funding": [
{
@ -8942,7 +8947,7 @@
"type": "github"
}
],
"time": "2023-02-03T07:00:31+00:00"
"time": "2023-03-23T05:12:41+00:00"
},
{
"name": "sebastian/environment",
@ -9794,16 +9799,16 @@
},
{
"name": "ta-tikoma/phpunit-architecture-test",
"version": "0.7.1",
"version": "0.7.2",
"source": {
"type": "git",
"url": "https://github.com/ta-tikoma/phpunit-architecture-test.git",
"reference": "1f4466e8faf8d7edd1ae26656f39bf9447c5fa38"
"reference": "d8616ea630cbbdfd2158973389eaba0b9c7dd4c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/1f4466e8faf8d7edd1ae26656f39bf9447c5fa38",
"reference": "1f4466e8faf8d7edd1ae26656f39bf9447c5fa38",
"url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/d8616ea630cbbdfd2158973389eaba0b9c7dd4c8",
"reference": "d8616ea630cbbdfd2158973389eaba0b9c7dd4c8",
"shasum": ""
},
"require": {
@ -9811,12 +9816,12 @@
"nikic/php-parser": "^4.15.4",
"php": "^8.1.0",
"phpdocumentor/reflection-docblock": "^5.3.0",
"phpunit/phpunit": "^9.6.5|^10.0.16",
"phpunit/phpunit": "^9.6.5|^10.0.18",
"symfony/finder": "^6.2.7"
},
"require-dev": {
"laravel/pint": "^1.6.0",
"phpstan/phpstan": "^1.10.7"
"laravel/pint": "^1.7.0",
"phpstan/phpstan": "^1.10.8"
},
"type": "library",
"autoload": {
@ -9848,9 +9853,9 @@
],
"support": {
"issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues",
"source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.7.1"
"source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.7.2"
},
"time": "2023-03-17T01:38:35+00:00"
"time": "2023-03-24T11:15:54+00:00"
},
{
"name": "theseer/tokenizer",

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('servers', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('name');
$table->string('description')->nullable();
$table->string('ip');
$table->integer('port')->default(22);
$table->string('user')->default('root');
$table->foreignId('team_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('servers');
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('private_keys', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('name');
$table->string('description')->nullable();
$table->longText('private_key');
$table->nullableMorphs('private_keys_morph');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('private_keys');
}
};

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('private_keyables', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('private_key_id');
$table->unsignedBigInteger('private_keyable_id');
$table->string('private_keyable_type');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('private_keyables');
}
};

View File

@ -12,6 +12,8 @@ class DatabaseSeeder extends Seeder
$this->call([
UserSeeder::class,
TeamSeeder::class,
ServerSeeder::class,
PrivateKeySeeder::class,
]);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace Database\Seeders;
use App\Models\PrivateKey;
use App\Models\Server;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class PrivateKeySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$server = Server::find(1);
$server2 = Server::find(2);
$private_key = PrivateKey::create([
"name" => "Testing-host",
"description" => "This is a test docker container",
"private_key" => "-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk
hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA
AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
-----END OPENSSH PRIVATE KEY-----
",
]);
$server->privateKeys()->attach($private_key);
$server2->privateKeys()->attach($private_key);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace Database\Seeders;
use App\Models\Server;
use App\Models\Team;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ServerSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$root_team = Team::find(1);
Server::create([
'id' => 1,
'name' => "testing-host",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host",
'team_id' => $root_team->id,
]);
Server::create([
'id' => 2,
'name' => "testing-host2",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host-2",
'team_id' => $root_team->id,
]);
}
}

View File

@ -53,6 +53,17 @@ services:
- ./docker/testing-host/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf
networks:
- coolify
testing-host2:
container_name: coolify-testing-host-2
image: coolify-testing-host
build:
dockerfile: Dockerfile
context: ./docker/testing-host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./docker/testing-host/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf
networks:
- coolify
volumes:
db-coolify:

View File

@ -56,16 +56,6 @@ RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.2
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
USER sail
RUN mkdir -p ~/.ssh
RUN echo "-----BEGIN OPENSSH PRIVATE KEY-----\n\
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW\n\
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk\n\
hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA\n\
AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV\n\
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==\n\
-----END OPENSSH PRIVATE KEY-----" >> ~/.ssh/id_ed25519
RUN chmod 0600 ~/.ssh/id_ed25519
USER root
@ -78,7 +68,7 @@ RUN chmod +x /usr/local/bin/start-container
RUN mkdir -p ~/.docker/cli-plugins
RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-$DOCKER_VERSION -o /usr/bin/docker
RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-compose-linux-$DOCKER_COMPOSE_VERSION -o ~/.docker/cli-plugins/docker-compose -o /home/sail/.docker/cli-plugins/docker-compose
RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/pack-$PACK_VERSION -o /usr/local/bin/pack
RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/pack-$PACK_VERSION -o /usr/local/bin/pack
RUN curl -sSL https://nixpacks.com/install.sh | bash
RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker /usr/local/bin/pack

View File

@ -1,11 +1,14 @@
<div>
<div>
<label for="command">
<input autofocus class="py-2 rounded ring-1" id="command" wire:model="command" type="text"
wire:keydown.enter="runCommand" />
<input autofocus id="command" wire:model.defer="command" type="text" wire:keydown.enter="runCommand" />
<select wire:model.defer="server">
@foreach ($servers as $server)
<option value="{{ $server }}">{{ $server }}</option>
@endforeach
</select>
</label>
<button wire:click="runCommand">Run command</button>
<button wire:click="runSleepingBeauty">Run sleeping beauty</button>
<button wire:click="runDummyProjectBuild">Build DummyProject</button>
</div>
@ -22,9 +25,9 @@
Activity: <span>{{ $activity?->id ?? 'waiting' }}</span>
</div>
<pre style="width: 100%;overflow-y: scroll;" @if ($isKeepAliveOn || $manualKeepAlive) wire:poll.750ms="polling" @endif>{{ data_get($activity, 'description') }}</pre>
<div>
{{-- <div>
<div>Details:</div>
<pre style="width: 100%;overflow-y: scroll;">{{ json_encode(data_get($activity, 'properties'), JSON_PRETTY_PRINT) }}</pre>
</div>
</div> --}}
@endisset
</div>