This commit is contained in:
Andras Bacsai 2023-04-14 10:00:42 +02:00
parent 09ab64105d
commit c8434acd0d
14 changed files with 98 additions and 21 deletions

View File

@ -5,6 +5,7 @@
/public/storage
/storage/*.key
/vendor
.env.example
.env
.env.backup
.env.production
@ -19,5 +20,5 @@ yarn-error.log
/.vscode
/.npm
/.bash_history
/_volumes/*
/_volumes

2
.gitignore vendored
View File

@ -19,4 +19,4 @@ yarn-error.log
/.vscode
/.npm
/.bash_history
/_volumes/*
/_volumes

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Livewire;
use App\Models\Server;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Process;
use Livewire\Component;
class CheckUpdate extends Component
{
public $updateAvailable = false;
public $latestVersion = '4.0.0-nightly.1';
protected $currentVersion;
protected $image = 'ghcr.io/coollabsio/coolify';
public function checkUpdate()
{
$response = Http::get('https://get.coollabs.io/versions.json');
$versions = $response->json();
// $this->latestVersion = data_get($versions, 'coolify.main.version');
$this->currentVersion = config('coolify.version');
version_compare($this->currentVersion, $this->latestVersion, '<') ? $this->updateAvailable = true : $this->updateAvailable = false;
}
public function render()
{
return view('livewire.check-update');
}
}

View File

@ -3,6 +3,7 @@
namespace App\Providers;
use Illuminate\Queue\Events\JobProcessed;
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\ServiceProvider;
@ -13,6 +14,13 @@ class AppServiceProvider extends ServiceProvider
*/
public function register(): void
{
// @TODO: Is this the best place to run the seeder?
// if (env('APP_ENV') === 'production') {
// dump('Seed default data.');
// Process::run('php artisan db:seed --class=ProductionSeeder --force');
// } else {
// dump('Not in production environment.');
// }
//
}

View File

@ -11,6 +11,8 @@
|
*/
use Illuminate\Support\Facades\Artisan;
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);

View File

@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use App\Models\PrivateKey;
use App\Models\Project;
use App\Models\Team;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
class ProductionSeeder extends Seeder
{
public function run(): void
{
$coolify_key = Storage::disk('local')->get('ssh-keys/coolify.dsa');
if (PrivateKey::where('name', 'Coolify Host')->doesntExist()) {
PrivateKey::create([
"id" => 0,
"name" => "Coolify Host",
"description" => "This is the private key for the server where Coolify is hosted.",
"private_key" => $coolify_key,
]);
} else {
dump('Coolify SSH Key already exists.');
}
}
}

View File

@ -16,9 +16,17 @@ public function run(): void
{
$root_team = Team::find(1);
$private_key_1 = PrivateKey::find(1);
Server::create([
'id' => 1,
'name' => "localhost",
'description' => "This is the local machine",
'user' => 'root',
'ip' => "host.docker.internal",
'team_id' => $root_team->id,
'private_key_id' => $private_key_1->id,
]);
Server::create([
'id' => 2,
'name' => "testing-local-docker-container",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host",
@ -26,21 +34,13 @@ public function run(): void
'private_key_id' => $private_key_1->id,
]);
Server::create([
'id' => 2,
'id' => 3,
'name' => "testing-local-docker-container-2",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host-2",
'team_id' => $root_team->id,
'private_key_id' => $private_key_1->id,
]);
Server::create([
'id' => 3,
'name' => "localhost",
'description' => "This is the local machine",
'user' => 'root',
'ip' => "coolify-testing-host",
'team_id' => $root_team->id,
'private_key_id' => $private_key_1->id,
]);
}
}

View File

@ -13,13 +13,13 @@ class ServerSettingSeeder extends Seeder
*/
public function run(): void
{
$server_1 = Server::find(1)->load(['settings']);
$server_1->settings->is_build_server = true;
$server_1->settings->save();
$server_2 = Server::find(2)->load(['settings']);
$server_2->settings->is_build_server = true;
$server_2->settings->save();
$server_3 = Server::find(3)->load(['settings']);
$server_3->settings->is_build_server = true;
$server_3->settings->save();
}
}

View File

@ -15,11 +15,11 @@ class StandaloneDockerSeeder extends Seeder
*/
public function run(): void
{
$server_3 = Server::find(3);
$server_1 = Server::find(1);
StandaloneDocker::create([
'id' => 1,
'network' => 'coolify',
'server_id' => $server_3->id,
'server_id' => $server_1->id,
]);
}
}

View File

@ -16,10 +16,10 @@ class SwarmDockerSeeder extends Seeder
*/
public function run(): void
{
$server_1 = Server::find(1);
$server_2 = Server::find(2);
SwarmDocker::create([
'id' => 1,
'server_id' => $server_1->id,
'server_id' => $server_2->id,
]);
}
}

View File

@ -2,6 +2,8 @@ version: '3.8'
services:
coolify:
working_dir: /var/www/html
extra_hosts:
- 'host.docker.internal:host-gateway'
networks:
- coolify
depends_on:

View File

@ -14,5 +14,6 @@
@csrf
<button type="submit">Logout</button>
</form>
<livewire:check-update>
@endauth
</nav>

View File

@ -0,0 +1,4 @@
<div>
<button wire:click='checkUpdate'>Updates</button>
{{ $updateAvailable ? 'Update available' : 'No updates' }}
</div>

View File

@ -32,6 +32,9 @@
Route::get('/profile', function () {
return view('profile');
});
Route::get('/update', function () {
return view('update');
});
Route::get('/demo', function () {
return view('demo');
});