wip: persisting data
This commit is contained in:
parent
829a45f410
commit
259f41bb8a
@ -121,15 +121,25 @@ public function handle(): void
|
||||
$this->execute_in_builder("cp {$this->workdir}/.nixpacks/Dockerfile {$this->workdir}/Dockerfile"),
|
||||
$this->execute_in_builder("rm -f {$this->workdir}/.nixpacks/Dockerfile"),
|
||||
"echo 'Done.'",
|
||||
]);
|
||||
$this->executeNow([
|
||||
"echo -n 'Building image... '",
|
||||
$this->execute_in_builder("docker build -f {$this->workdir}/Dockerfile --build-arg SOURCE_COMMIT={$this->git_commit} --progress plain -t {$this->application->uuid}:{$this->git_commit} {$this->workdir}"),
|
||||
"echo 'Done.'",
|
||||
]);
|
||||
$this->executeNow([
|
||||
"echo -n 'Removing old container... '",
|
||||
$this->execute_in_builder("docker rm -f {$this->application->uuid} >/dev/null 2>&1"),
|
||||
"echo -n 'Deploying... '",
|
||||
$this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d"),
|
||||
"echo 'Done.'",
|
||||
]);
|
||||
$this->executeNow([
|
||||
"echo -n 'Starting new container... '",
|
||||
$this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d >/dev/null 2>&1"),
|
||||
"echo 'Done. 🎉'",
|
||||
"docker stop -t 0 {$this->deployment_uuid} >/dev/null"
|
||||
], setStatus: true);
|
||||
$this->executeNow([
|
||||
"docker stop -t 0 {$this->deployment_uuid} >/dev/null"
|
||||
]);
|
||||
}
|
||||
|
||||
private function execute_in_builder(string $command)
|
||||
|
@ -32,6 +32,10 @@ public function source()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
public function persistentStorages()
|
||||
{
|
||||
return $this->morphMany(LocalPersistentVolume::class, 'resource');
|
||||
}
|
||||
|
||||
public function portsMappings(): Attribute
|
||||
{
|
||||
|
11
app/Models/LocalPersistentVolume.php
Normal file
11
app/Models/LocalPersistentVolume.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class LocalPersistentVolume extends BaseModel
|
||||
{
|
||||
public function application()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@ public function up(): void
|
||||
$table->string('name');
|
||||
|
||||
$table->morphs('destination');
|
||||
$table->foreignId('environment_id');
|
||||
|
||||
$table->foreignId('environment_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public function up(): void
|
||||
$table->string('name');
|
||||
|
||||
$table->morphs('destination');
|
||||
|
||||
$table->foreignId('environment_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
@ -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('local_persistent_volumes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->string('name');
|
||||
$table->string('mount_path');
|
||||
$table->string('host_path')->nullable();
|
||||
$table->string('container_id')->nullable();
|
||||
|
||||
$table->nullableMorphs('resource');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('local_persistent_volumes');
|
||||
}
|
||||
};
|
@ -6,6 +6,7 @@
|
||||
use App\Models\ApplicationSetting;
|
||||
use App\Models\Environment;
|
||||
use App\Models\GithubApp;
|
||||
use App\Models\LocalPersistentVolume;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\SwarmDocker;
|
||||
use Illuminate\Database\Seeder;
|
||||
@ -23,6 +24,8 @@ public function run(): void
|
||||
|
||||
$github_public_source = GithubApp::find(1);
|
||||
$github_private_source = GithubApp::find(2);
|
||||
|
||||
$pv_storage = LocalPersistentVolume::find(1);
|
||||
Application::create([
|
||||
'id' => 1,
|
||||
'name' => 'Public application (from GitHub)',
|
||||
|
@ -18,6 +18,7 @@ public function run(): void
|
||||
ProjectSeeder::class,
|
||||
ProjectSettingSeeder::class,
|
||||
EnvironmentSeeder::class,
|
||||
LocalPersistentVolumeSeeder::class,
|
||||
StandaloneDockerSeeder::class,
|
||||
SwarmDockerSeeder::class,
|
||||
KubernetesSeeder::class,
|
||||
|
23
database/seeders/LocalPersistentVolumeSeeder.php
Normal file
23
database/seeders/LocalPersistentVolumeSeeder.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\LocalPersistentVolume;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LocalPersistentVolumeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
LocalPersistentVolume::create([
|
||||
'name' => 'test-pv',
|
||||
'mount_path' => '/data',
|
||||
'resource_id' => 1,
|
||||
'resource_type' => Application::class,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
<div>
|
||||
<pre style="width: 100%;overflow-y: scroll;" @if ($isKeepAliveOn) wire:poll.750ms="polling" @endif>
|
||||
{{ data_get($activity, 'description') }}
|
||||
</pre>
|
||||
<pre style="width: 100%;overflow-y: scroll;" @if ($isKeepAliveOn) wire:poll.750ms="polling" @endif>{{ data_get($activity, 'description') }}</pre>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user