From f7c615c958527ab6318f5c1f66736160cd18ea47 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 24 Mar 2023 15:47:58 +0100 Subject: [PATCH 1/5] Add servers and privatekeys to database --- app/Models/PrivateKey.php | 11 ++++++ app/Models/Server.php | 11 ++++++ ...2023_03_24_140711_create_servers_table.php | 34 +++++++++++++++++++ ...03_24_140853_create_private_keys_table.php | 32 +++++++++++++++++ database/seeders/DatabaseSeeder.php | 2 ++ database/seeders/PrivateKeySeeder.php | 30 ++++++++++++++++ database/seeders/ServerSeeder.php | 26 ++++++++++++++ 7 files changed, 146 insertions(+) create mode 100644 app/Models/PrivateKey.php create mode 100644 app/Models/Server.php create mode 100644 database/migrations/2023_03_24_140711_create_servers_table.php create mode 100644 database/migrations/2023_03_24_140853_create_private_keys_table.php create mode 100644 database/seeders/PrivateKeySeeder.php create mode 100644 database/seeders/ServerSeeder.php diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php new file mode 100644 index 000000000..6da73fc87 --- /dev/null +++ b/app/Models/PrivateKey.php @@ -0,0 +1,11 @@ +morphTo(); + } +} diff --git a/app/Models/Server.php b/app/Models/Server.php new file mode 100644 index 000000000..8e025a75e --- /dev/null +++ b/app/Models/Server.php @@ -0,0 +1,11 @@ +morphMany(PrivateKey::class, 'private_key_morph'); + } +} diff --git a/database/migrations/2023_03_24_140711_create_servers_table.php b/database/migrations/2023_03_24_140711_create_servers_table.php new file mode 100644 index 000000000..0cbd2419a --- /dev/null +++ b/database/migrations/2023_03_24_140711_create_servers_table.php @@ -0,0 +1,34 @@ +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'); + } +}; diff --git a/database/migrations/2023_03_24_140853_create_private_keys_table.php b/database/migrations/2023_03_24_140853_create_private_keys_table.php new file mode 100644 index 000000000..3304ed918 --- /dev/null +++ b/database/migrations/2023_03_24_140853_create_private_keys_table.php @@ -0,0 +1,32 @@ +id(); + $table->string('uuid')->unique(); + $table->string('name'); + $table->string('description')->nullable(); + $table->longText('private_key'); + $table->nullableMorphs('private_key_morph'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('private_keys'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 7b2f6bbcd..19606f85a 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -12,6 +12,8 @@ class DatabaseSeeder extends Seeder $this->call([ UserSeeder::class, TeamSeeder::class, + ServerSeeder::class, + PrivateKeySeeder::class, ]); } } diff --git a/database/seeders/PrivateKeySeeder.php b/database/seeders/PrivateKeySeeder.php new file mode 100644 index 000000000..522c4c703 --- /dev/null +++ b/database/seeders/PrivateKeySeeder.php @@ -0,0 +1,30 @@ + "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-----", + ])->private_key_morph()->associate($server)->save(); + } +} diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.php new file mode 100644 index 000000000..8d1499689 --- /dev/null +++ b/database/seeders/ServerSeeder.php @@ -0,0 +1,26 @@ + 1, + 'name' => "testing-host", + 'description' => "This is a test docker container", + 'ip' => "coolify-testing-host", + 'team_id' => $root_team->id, + ]); + } +} From 789b699556177d84604755022ebe59a3f4dd2857 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 24 Mar 2023 15:48:57 +0100 Subject: [PATCH 2/5] Add run command of predefined server --- app/Http/Livewire/RunCommand.php | 8 ++++--- bootstrap/helpers.php | 24 ++++++++++++------- .../views/livewire/run-command.blade.php | 4 ++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/Http/Livewire/RunCommand.php b/app/Http/Livewire/RunCommand.php index ae189422e..db96b17b7 100755 --- a/app/Http/Livewire/RunCommand.php +++ b/app/Http/Livewire/RunCommand.php @@ -14,6 +14,8 @@ class RunCommand extends Component public $command = 'ls'; + public $server = 'testing-host'; + public function render() { return view('livewire.run-command'); @@ -23,14 +25,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 +42,7 @@ class RunCommand extends Component $this->activity = remoteProcess(<<server); } public function polling() diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index c7517b0db..e2b9e64ed 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -2,9 +2,10 @@ use App\Actions\RemoteProcess\DispatchRemoteProcess; use App\Data\RemoteProcessArgs; +use App\Models\Server; 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). * @TODO Change 'root' to 'coolify' when it's able to run Docker commands without sudo @@ -12,17 +13,22 @@ if (! function_exists('remoteProcess')) { */ function remoteProcess( string $command, - string $destination, - ?int $port = 22, - ?string $user = 'root', - ): Activity - { + string $destination + ): Activity { + $found_server = Server::where('name', $destination)->first(); + if (!$found_server) { + throw new \RuntimeException('Server not found.'); + } + $found_team = auth()->user()->teams->pluck('id')->contains($found_server->team_id); + if (!$found_team) { + throw new \RuntimeException('You do not have access to this server.'); + } return resolve(DispatchRemoteProcess::class, [ 'remoteProcessArgs' => new RemoteProcessArgs( - destination: $destination, + destination: $found_server->ip, command: $command, - port: $port, - user: $user, + port: $found_server->port, + user: $found_server->user, ), ])(); } diff --git a/resources/views/livewire/run-command.blade.php b/resources/views/livewire/run-command.blade.php index 87be7419c..704c467ea 100755 --- a/resources/views/livewire/run-command.blade.php +++ b/resources/views/livewire/run-command.blade.php @@ -1,8 +1,8 @@
From 9e326d15b9d8e6b159fc1fc0938406a2b389cb05 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 24 Mar 2023 16:56:56 +0100 Subject: [PATCH 3/5] Switch Cuid2 to a non-deprecated package --- app/Models/BaseModel.php | 4 +- app/Models/User.php | 2 +- composer.json | 2 +- composer.lock | 309 ++++++++++++++++++++------------------- 4 files changed, 161 insertions(+), 156 deletions(-) diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 22cbfc085..32bf22f89 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -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(); }); } -} \ No newline at end of file +} diff --git a/app/Models/User.php b/app/Models/User.php index 1c958190a..576415ec1 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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 { diff --git a/composer.json b/composer.json index c6447fbeb..64d74332a 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 818e9721b..a880bdcd0 100644 --- a/composer.lock +++ b/composer.lock @@ -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", From f57684b024c7622303b5c1ef2f631aea63c3eca4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 24 Mar 2023 22:15:36 +0100 Subject: [PATCH 4/5] Add Servers and PrivateKeys Add new testhost Remove privatekey injection from Dockerfile --- .../RemoteProcess/RunRemoteProcess.php | 5 ++- app/Data/RemoteProcessArgs.php | 1 + app/Http/Livewire/RunCommand.php | 7 ++++ app/Jobs/ExecuteRemoteProcess.php | 1 + app/Models/PrivateKey.php | 9 +++-- app/Models/Server.php | 4 +-- bootstrap/helpers.php | 34 ++++++++++++++----- ...03_24_140853_create_private_keys_table.php | 2 +- ...4_203356_create_private_keyables_table.php | 30 ++++++++++++++++ database/seeders/PrivateKeySeeder.php | 22 +++++++----- database/seeders/ServerSeeder.php | 7 ++++ docker-compose.yaml | 11 ++++++ docker/dev/Dockerfile | 12 +------ .../views/livewire/run-command.blade.php | 9 +++-- 14 files changed, 116 insertions(+), 38 deletions(-) create mode 100644 database/migrations/2023_03_24_203356_create_private_keyables_table.php diff --git a/app/Actions/RemoteProcess/RunRemoteProcess.php b/app/Actions/RemoteProcess/RunRemoteProcess.php index 69dc35465..4a6352041 100644 --- a/app/Actions/RemoteProcess/RunRemoteProcess.php +++ b/app/Actions/RemoteProcess/RunRemoteProcess.php @@ -64,12 +64,14 @@ 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 ' @@ -78,6 +80,7 @@ class RunRemoteProcess . " 'bash -se' << \\$delimiter" . PHP_EOL . $command . PHP_EOL . $delimiter; + return $ssh_command; } protected function handleOutput(string $type, string $output) diff --git a/app/Data/RemoteProcessArgs.php b/app/Data/RemoteProcessArgs.php index 65ed0e645..139b94c71 100644 --- a/app/Data/RemoteProcessArgs.php +++ b/app/Data/RemoteProcessArgs.php @@ -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, diff --git a/app/Http/Livewire/RunCommand.php b/app/Http/Livewire/RunCommand.php index db96b17b7..f29b5a29d 100755 --- a/app/Http/Livewire/RunCommand.php +++ b/app/Http/Livewire/RunCommand.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire; +use App\Models\Server; use Livewire\Component; class RunCommand extends Component @@ -16,6 +17,12 @@ class RunCommand extends Component public $server = 'testing-host'; + public $servers = []; + + public function mount() + { + $this->servers = Server::all()->pluck('name')->toArray(); + } public function render() { return view('livewire.run-command'); diff --git a/app/Jobs/ExecuteRemoteProcess.php b/app/Jobs/ExecuteRemoteProcess.php index 567c88d9a..3915c2d55 100755 --- a/app/Jobs/ExecuteRemoteProcess.php +++ b/app/Jobs/ExecuteRemoteProcess.php @@ -31,5 +31,6 @@ class ExecuteRemoteProcess implements ShouldQueue ]); $remoteProcess(); + // @TODO: Remove file at $this->activity->getExtraProperty('private_key_location') after process is finished } } diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index 6da73fc87..2f148b1ce 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -4,8 +4,13 @@ namespace App\Models; class PrivateKey extends BaseModel { - public function private_key_morph() + public function private_keyables() { - return $this->morphTo(); + return $this->hasMany(PrivateKeyable::class); + } + + public function servers() + { + return $this->morphedByMany(Server::class, 'private_keyable'); } } diff --git a/app/Models/Server.php b/app/Models/Server.php index 8e025a75e..a703f8003 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -4,8 +4,8 @@ namespace App\Models; class Server extends BaseModel { - public function private_key() + public function privateKeys() { - return $this->morphMany(PrivateKey::class, 'private_key_morph'); + return $this->morphToMany(PrivateKey::class, 'private_keyable'); } } diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index e2b9e64ed..6f9b04cad 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -3,11 +3,12 @@ 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')) { /** - * 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 * */ @@ -15,21 +16,36 @@ if (!function_exists('remoteProcess')) { string $command, string $destination ): Activity { - $found_server = Server::where('name', $destination)->first(); - if (!$found_server) { - throw new \RuntimeException('Server not found.'); - } - $found_team = auth()->user()->teams->pluck('id')->contains($found_server->team_id); - if (!$found_team) { - throw new \RuntimeException('You do not have access to this server.'); - } + $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: $found_server->ip, + private_key_location: $private_key_location, command: $command, 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.'); + } + + } } diff --git a/database/migrations/2023_03_24_140853_create_private_keys_table.php b/database/migrations/2023_03_24_140853_create_private_keys_table.php index 3304ed918..09c6ab0ee 100644 --- a/database/migrations/2023_03_24_140853_create_private_keys_table.php +++ b/database/migrations/2023_03_24_140853_create_private_keys_table.php @@ -17,7 +17,7 @@ return new class extends Migration $table->string('name'); $table->string('description')->nullable(); $table->longText('private_key'); - $table->nullableMorphs('private_key_morph'); + $table->nullableMorphs('private_keys_morph'); $table->timestamps(); }); } diff --git a/database/migrations/2023_03_24_203356_create_private_keyables_table.php b/database/migrations/2023_03_24_203356_create_private_keyables_table.php new file mode 100644 index 000000000..7c110413c --- /dev/null +++ b/database/migrations/2023_03_24_203356_create_private_keyables_table.php @@ -0,0 +1,30 @@ +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'); + } +}; diff --git a/database/seeders/PrivateKeySeeder.php b/database/seeders/PrivateKeySeeder.php index 522c4c703..d3ffc6574 100644 --- a/database/seeders/PrivateKeySeeder.php +++ b/database/seeders/PrivateKeySeeder.php @@ -15,16 +15,20 @@ class PrivateKeySeeder extends Seeder public function run(): void { $server = Server::find(1); - PrivateKey::create([ + $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-----", - ])->private_key_morph()->associate($server)->save(); + "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); } } diff --git a/database/seeders/ServerSeeder.php b/database/seeders/ServerSeeder.php index 8d1499689..22fb68a03 100644 --- a/database/seeders/ServerSeeder.php +++ b/database/seeders/ServerSeeder.php @@ -22,5 +22,12 @@ class ServerSeeder extends Seeder '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, + ]); } } diff --git a/docker-compose.yaml b/docker-compose.yaml index 253554a26..2b1379e2d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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: diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 239bf9fa8..1959a9b12 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -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 diff --git a/resources/views/livewire/run-command.blade.php b/resources/views/livewire/run-command.blade.php index 704c467ea..bac5248e3 100755 --- a/resources/views/livewire/run-command.blade.php +++ b/resources/views/livewire/run-command.blade.php @@ -1,11 +1,14 @@
-
From e604abf47a970e354f66e0e918667d21813abd3f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 27 Mar 2023 09:35:34 +0200 Subject: [PATCH 5/5] remove unnecessary things from demo --- app/Actions/RemoteProcess/DispatchRemoteProcess.php | 2 +- app/Actions/RemoteProcess/RunRemoteProcess.php | 1 + resources/views/livewire/run-command.blade.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Actions/RemoteProcess/DispatchRemoteProcess.php b/app/Actions/RemoteProcess/DispatchRemoteProcess.php index 9c7cb20b2..349c847c4 100644 --- a/app/Actions/RemoteProcess/DispatchRemoteProcess.php +++ b/app/Actions/RemoteProcess/DispatchRemoteProcess.php @@ -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 diff --git a/app/Actions/RemoteProcess/RunRemoteProcess.php b/app/Actions/RemoteProcess/RunRemoteProcess.php index 4a6352041..731eea533 100644 --- a/app/Actions/RemoteProcess/RunRemoteProcess.php +++ b/app/Actions/RemoteProcess/RunRemoteProcess.php @@ -75,6 +75,7 @@ class RunRemoteProcess . '-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 diff --git a/resources/views/livewire/run-command.blade.php b/resources/views/livewire/run-command.blade.php index bac5248e3..6482fc298 100755 --- a/resources/views/livewire/run-command.blade.php +++ b/resources/views/livewire/run-command.blade.php @@ -25,9 +25,9 @@ Activity: {{ $activity?->id ?? 'waiting' }}
{{ data_get($activity, 'description') }}
-
+ {{--
Details:
{{ json_encode(data_get($activity, 'properties'), JSON_PRETTY_PRINT) }}
-
+
--}} @endisset