From fd488a561a17ffe4204378876227244b684d7365 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 17 Oct 2023 12:35:04 +0200 Subject: [PATCH] feat: use docker login credentials from server --- app/Jobs/ApplicationDeploymentJob.php | 9 +++++++-- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index e5f068d61..ff4228ac5 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -71,6 +71,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private $log_model; private Collection $saved_outputs; + private string $serverUser = 'root'; + private string $serverUserHomeDir = '/root'; + public $tries = 1; public function __construct(int $application_deployment_queue_id) { @@ -92,7 +95,7 @@ public function __construct(int $application_deployment_queue_id) } $this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first(); $this->server = $this->destination->server; - + $this->serverUser = $this->server->user; $this->basedir = "/artifacts/{$this->deployment_uuid}"; $this->workdir = "{$this->basedir}" . rtrim($this->application->base_directory, '/'); $this->configuration_dir = application_configuration_dir() . "/{$this->application->uuid}"; @@ -160,6 +163,8 @@ public function handle(): void return "--add-host $name:$ip"; })->implode(' '); + // Get user home directory + $this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server); try { if ($this->application->dockerfile) { $this->deploy_simple_dockerfile(); @@ -458,7 +463,7 @@ private function prepare_builder_image() { $pull = "--pull=always"; $helperImage = config('coolify.helper_image'); - $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; + $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}"; $this->execute_remote_command( [ diff --git a/config/sentry.php b/config/sentry.php index 0436da59d..f0fda5f19 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.87', + 'release' => '4.0.0-beta.88', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 58b3026ae..8de2939a1 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@