From 5877cead8912e4fd10fdd49557efc298e9973047 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 8 Jan 2025 23:16:15 +0100 Subject: [PATCH] feat: move volume data cloning to a Job --- app/Jobs/VolumeCloneJob.php | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/Jobs/VolumeCloneJob.php diff --git a/app/Jobs/VolumeCloneJob.php b/app/Jobs/VolumeCloneJob.php new file mode 100644 index 000000000..95ac14197 --- /dev/null +++ b/app/Jobs/VolumeCloneJob.php @@ -0,0 +1,39 @@ +onQueue('high'); + } + + public function handle() + { + try { + instant_remote_process([ + "docker volume create $this->targetVolume", + "docker run --rm -v $this->sourceVolume:/source -v $this->targetVolume:/target alpine sh -c 'cp -a /source/. /target/ && chown -R 1000:1000 /target'", + ], $this->server); + } catch (\Exception $e) { + logger()->error("Failed to copy volume data for {$this->sourceVolume}: ".$e->getMessage()); + throw $e; + } + } +}