feat(sentinel): add support for custom Docker images in StartSentinel and related methods
This commit is contained in:
		| @@ -10,7 +10,7 @@ class StartSentinel | |||||||
| { | { | ||||||
|     use AsAction; |     use AsAction; | ||||||
| 
 | 
 | ||||||
|     public function handle(Server $server, bool $restart = false, ?string $latestVersion = null) |     public function handle(Server $server, bool $restart = false, ?string $latestVersion = null, ?string $customImage = null) | ||||||
|     { |     { | ||||||
|         if ($server->isSwarm() || $server->isBuildServer()) { |         if ($server->isSwarm() || $server->isBuildServer()) { | ||||||
|             return; |             return; | ||||||
| @@ -44,7 +44,9 @@ class StartSentinel | |||||||
|         ]; |         ]; | ||||||
|         if (isDev()) { |         if (isDev()) { | ||||||
|             // data_set($environments, 'DEBUG', 'true');
 |             // data_set($environments, 'DEBUG', 'true');
 | ||||||
|             // $image = 'sentinel';
 |             if ($customImage && ! empty($customImage)) { | ||||||
|  |                 $image = $customImage; | ||||||
|  |             } | ||||||
|             $mountDir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/sentinel'; |             $mountDir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/sentinel'; | ||||||
|         } |         } | ||||||
|         $dockerEnvironments = '-e "'.implode('" -e "', array_map(fn ($key, $value) => "$key=$value", array_keys($environments), $environments)).'"'; |         $dockerEnvironments = '-e "'.implode('" -e "', array_map(fn ($key, $value) => "$key=$value", array_keys($environments), $environments)).'"'; | ||||||
|   | |||||||
| @@ -63,6 +63,8 @@ class Show extends Component | |||||||
| 
 | 
 | ||||||
|     public bool $isSentinelDebugEnabled; |     public bool $isSentinelDebugEnabled; | ||||||
| 
 | 
 | ||||||
|  |     public ?string $sentinelCustomDockerImage = null; | ||||||
|  | 
 | ||||||
|     public string $serverTimezone; |     public string $serverTimezone; | ||||||
| 
 | 
 | ||||||
|     public function getListeners() |     public function getListeners() | ||||||
| @@ -267,7 +269,8 @@ class Show extends Component | |||||||
|     { |     { | ||||||
|         try { |         try { | ||||||
|             $this->authorize('manageSentinel', $this->server); |             $this->authorize('manageSentinel', $this->server); | ||||||
|             $this->server->restartSentinel(); |             $customImage = isDev() ? $this->sentinelCustomDockerImage : null; | ||||||
|  |             $this->server->restartSentinel($customImage); | ||||||
|             $this->dispatch('success', 'Restarting Sentinel.'); |             $this->dispatch('success', 'Restarting Sentinel.'); | ||||||
|         } catch (\Throwable $e) { |         } catch (\Throwable $e) { | ||||||
|             return handleError($e, $this); |             return handleError($e, $this); | ||||||
| @@ -300,7 +303,8 @@ class Show extends Component | |||||||
|         try { |         try { | ||||||
|             $this->authorize('manageSentinel', $this->server); |             $this->authorize('manageSentinel', $this->server); | ||||||
|             if ($value === true) { |             if ($value === true) { | ||||||
|                 StartSentinel::run($this->server, true); |                 $customImage = isDev() ? $this->sentinelCustomDockerImage : null; | ||||||
|  |                 StartSentinel::run($this->server, true, null, $customImage); | ||||||
|             } else { |             } else { | ||||||
|                 $this->isMetricsEnabled = false; |                 $this->isMetricsEnabled = false; | ||||||
|                 $this->isSentinelDebugEnabled = false; |                 $this->isSentinelDebugEnabled = false; | ||||||
|   | |||||||
| @@ -1252,13 +1252,13 @@ $schema://$host { | |||||||
|         return str($this->ip)->contains(':'); |         return str($this->ip)->contains(':'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function restartSentinel(bool $async = true) |     public function restartSentinel(?string $customImage = null, bool $async = true) | ||||||
|     { |     { | ||||||
|         try { |         try { | ||||||
|             if ($async) { |             if ($async) { | ||||||
|                 StartSentinel::dispatch($this, true); |                 StartSentinel::dispatch($this, true, null, $customImage); | ||||||
|             } else { |             } else { | ||||||
|                 StartSentinel::run($this, true); |                 StartSentinel::run($this, true, null, $customImage); | ||||||
|             } |             } | ||||||
|         } catch (\Throwable $e) { |         } catch (\Throwable $e) { | ||||||
|             return handleError($e); |             return handleError($e); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andras Bacsai
					Andras Bacsai