wip: persisting data
This commit is contained in:
@@ -121,15 +121,25 @@ class DeployApplicationJob implements ShouldQueue
|
||||
$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 @@ class Application extends BaseModel
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user