From 4c3c546c2f65d62ac551cffcb87d42b052cc8c7a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 14 Apr 2023 11:10:31 +0200 Subject: [PATCH] Save compose to local disk --- app/Jobs/DeployApplicationJob.php | 11 +++++++++-- config/filesystems.php | 2 -- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php index d4a313ef7..703ab96df 100644 --- a/app/Jobs/DeployApplicationJob.php +++ b/app/Jobs/DeployApplicationJob.php @@ -9,13 +9,13 @@ use App\Models\CoolifyInstanceSettings; use DateTimeImmutable; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Storage; use Lcobucci\JWT\Encoding\ChainedFormatter; use Lcobucci\JWT\Encoding\JoseEncoder; use Lcobucci\JWT\Signer\Key\InMemory; @@ -23,6 +23,7 @@ use Lcobucci\JWT\Token\Builder; use Spatie\Activitylog\Models\Activity; use Symfony\Component\Yaml\Yaml; +use Illuminate\Support\Str; class DeployApplicationJob implements ShouldQueue { @@ -118,7 +119,8 @@ public function handle(): void $this->execute_in_builder("rm -fr {$this->workdir}/.git") ], hideFromOutput: true); - $docker_compose_base64 = base64_encode($this->generate_docker_compose()); + $docker_compose = $this->generate_docker_compose(); + $docker_compose_base64 = base64_encode($docker_compose); $this->executeNow([ $this->execute_in_builder("echo '{$docker_compose_base64}' | base64 -d > {$this->workdir}/docker-compose.yml") ], hideFromOutput: true); @@ -146,6 +148,11 @@ public function handle(): void "echo 'Done. 🎉'", "docker stop -t 0 {$this->deployment_uuid} >/dev/null" ], setStatus: true); + + dispatch(new ContainerStatusJob($this->application_uuid)); + + // Saving docker-compose.yml + Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', Yaml::dump($docker_compose, 10)); } private function execute_in_builder(string $command) diff --git a/config/filesystems.php b/config/filesystems.php index 15c598e6b..5b579dc62 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -47,7 +47,6 @@ 'ssh-keys' => [ 'driver' => 'local', 'root' => storage_path('app/ssh-keys'), - 'url' => env('APP_URL').'/storage', 'visibility' => 'private', 'throw' => false, ], @@ -55,7 +54,6 @@ 'deployments' => [ 'driver' => 'local', 'root' => storage_path('app/deployments'), - 'url' => env('APP_URL').'/storage', 'visibility' => 'private', 'throw' => false, ],