fixes
This commit is contained in:
		
							parent
							
								
									3156d97969
								
							
						
					
					
						commit
						ac976d0f3a
					
				
							
								
								
									
										24
									
								
								app/Actions/Server/InstallDocker.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								app/Actions/Server/InstallDocker.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Actions\Server; | ||||
| 
 | ||||
| use App\Enums\ActivityTypes; | ||||
| use App\Models\Server; | ||||
| 
 | ||||
| class InstallDocker | ||||
| { | ||||
|     public function __invoke(Server $server) | ||||
|     { | ||||
|         $config = base64_encode('{ "live-restore": true }'); | ||||
|         $activity = remoteProcess([ | ||||
|             "echo Installing Docker...", | ||||
|             "curl https://releases.rancher.com/install-docker/23.0.sh | sh", | ||||
|             "echo Configuring Docker...", | ||||
|             "echo '{$config}' | base64 -d > /etc/docker/daemon.json", | ||||
|             "echo Restarting Docker...", | ||||
|             "systemctl restart docker" | ||||
|         ], $server, ActivityTypes::INLINE->value); | ||||
| 
 | ||||
|         return $activity; | ||||
|     } | ||||
| } | ||||
| @ -1,16 +0,0 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Http\Controllers; | ||||
| 
 | ||||
| use App\Models\Server; | ||||
| use Illuminate\Http\Request; | ||||
| 
 | ||||
| class ServerController extends Controller | ||||
| { | ||||
|     public function show(Server $server) | ||||
|     { | ||||
|         return view('server.show', [ | ||||
|             'server' => $server, | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| @ -3,6 +3,8 @@ | ||||
| namespace App\Http\Livewire\PrivateKey; | ||||
| 
 | ||||
| use App\Models\PrivateKey; | ||||
| use Illuminate\Routing\Route as RoutingRoute; | ||||
| use Illuminate\Support\Facades\Route; | ||||
| use Livewire\Component; | ||||
| 
 | ||||
| class Create extends Component | ||||
| @ -10,6 +12,12 @@ class Create extends Component | ||||
|     public $private_key_value; | ||||
|     public $private_key_name; | ||||
|     public $private_key_description; | ||||
|     public string $currentRoute; | ||||
| 
 | ||||
|     public function mount() | ||||
|     { | ||||
|         $this->currentRoute = Route::current()->uri(); | ||||
|     } | ||||
|     public function createPrivateKey() | ||||
|     { | ||||
|         $this->private_key_value = trim($this->private_key_value); | ||||
| @ -23,6 +31,8 @@ class Create extends Component | ||||
|             'team_id' => session('currentTeam')->id | ||||
|         ]); | ||||
|         session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); | ||||
|         redirect()->route('private-key.show', $new_private_key->uuid); | ||||
|         if ($this->currentRoute !== 'server/new') { | ||||
|             redirect()->route('private-key.show', $new_private_key->uuid); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -2,9 +2,8 @@ | ||||
| 
 | ||||
| namespace App\Http\Livewire\Server; | ||||
| 
 | ||||
| use App\Enums\ActivityTypes; | ||||
| use App\Actions\Server\InstallDocker; | ||||
| use App\Models\Server; | ||||
| use Illuminate\Support\Facades\Validator; | ||||
| use Livewire\Component; | ||||
| 
 | ||||
| class Form extends Component | ||||
| @ -28,12 +27,9 @@ class Form extends Component | ||||
|     } | ||||
|     public function installDocker() | ||||
|     { | ||||
|         $config = base64_encode('{ "live-restore": true }'); | ||||
|         remoteProcess([ | ||||
|             "curl https://releases.rancher.com/install-docker/23.0.sh | sh", | ||||
|             "echo '{$config}' | base64 -d > /etc/docker/daemon.json", | ||||
|             "systemctl restart docker" | ||||
|         ], $this->server, ActivityTypes::INLINE->value); | ||||
|         $activity = resolve(InstallDocker::class)($this->server); | ||||
| 
 | ||||
|         $this->emit('newMonitorActivity', $activity->id); | ||||
|     } | ||||
|     public function checkServer() | ||||
|     { | ||||
|  | ||||
| @ -37,7 +37,7 @@ class DeployApplicationJob implements ShouldQueue | ||||
|     protected string $workdir; | ||||
|     protected string $docker_compose; | ||||
|     public static int $batch_counter = 0; | ||||
| 
 | ||||
|     public $timeout = 3600; | ||||
|     /** | ||||
|      * Create a new job instance. | ||||
|      */ | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| <div class="mt-8"> | ||||
| <div> | ||||
|     @isset($this->activity) | ||||
|         <span>Activity: {{ $this->activity?->id }}</span> | ||||
|         <span>Status: {{ $this->activity?->properties->get('status') }}</span> | ||||
|  | ||||
| @ -6,7 +6,7 @@ | ||||
|         <x-inputs.button type="submit"> | ||||
|             Submit | ||||
|         </x-inputs.button> | ||||
|         <x-inputs.button class="bg-red-500" confirm='Are you sure you would like to delete this private key?' | ||||
|         <x-inputs.button confirm='Are you sure you would like to delete this private key?' | ||||
|             confirmAction="delete('{{ $private_key_uuid }}')"> | ||||
|             Delete | ||||
|         </x-inputs.button> | ||||
|  | ||||
| @ -20,8 +20,9 @@ | ||||
|         <div> | ||||
|             <x-inputs.button type="submit">Submit</x-inputs.button> | ||||
|             <x-inputs.button wire:click.prevent='checkServer'>Check Server</x-inputs.button> | ||||
|             <x-inputs.button class="bg-red-500" confirm="Are you sure you would like to delete this application?" | ||||
|                 confirmAction="delete">Delete | ||||
|             <x-inputs.button wire:click.prevent='installDocker'>Install Docker</x-inputs.button> | ||||
|             <x-inputs.button confirm="Are you sure you would like to delete this application?" confirmAction="delete"> | ||||
|                 Delete | ||||
|             </x-inputs.button> | ||||
|         </div> | ||||
|     </form> | ||||
| @ -34,5 +35,4 @@ | ||||
|     @isset($dockerComposeVersion) | ||||
|         <p>Docker Compose: {{ $dockerComposeVersion }}</p> | ||||
|     @endisset | ||||
| 
 | ||||
| </div> | ||||
|  | ||||
| @ -39,15 +39,6 @@ Route::middleware(['auth'])->group(function () { | ||||
|             'private_keys' => $private_keys->sortBy('name'), | ||||
|         ]); | ||||
|     })->name('dashboard'); | ||||
|     Route::get('/project/{project_uuid}', [ProjectController::class, 'environments'])->name('project.environments'); | ||||
| 
 | ||||
|     Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources'); | ||||
| 
 | ||||
|     Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ProjectController::class, 'application'])->name('project.application'); | ||||
|     Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', [ProjectController::class, 'deployment'])->name('project.deployment'); | ||||
| 
 | ||||
|     Route::get('/server/{server:uuid}', [ServerController::class, 'show'])->name('server.show'); | ||||
| 
 | ||||
| 
 | ||||
|     Route::get('/profile', function () { | ||||
|         return view('profile'); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user