path deployments

This commit is contained in:
Andras Bacsai 2023-05-16 15:27:47 +02:00
parent 28cf89627d
commit 8651d02651
5 changed files with 17 additions and 8 deletions

View File

@ -46,6 +46,9 @@ public function resources()
if (!$environment) { if (!$environment) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
return view('project.resources', ['project' => $project, 'environment' => $environment]); return view('project.resources', [
'project' => $project,
'environment' => $environment
]);
} }
} }

View File

@ -73,7 +73,11 @@ public function mount()
} }
public function submit() public function submit()
{ {
try {
$this->validate(); $this->validate();
$this->application->save(); $this->application->save();
} catch (\Exception $e) {
return generalErrorHandler($e, $this);
}
} }
} }

View File

@ -383,9 +383,11 @@ private function set_labels_for_applications()
$path = $url->getPath(); $path = $url->getPath();
$labels[] = 'traefik.enable=true'; $labels[] = 'traefik.enable=true';
if ($path === '/') { if ($path === '/') {
$labels[] = "traefik.http.routers.container.rule=Host(`{$host}`) && PathPrefix(`{$path}`)"; $labels[] = "traefik.http.routers.{$this->application->uuid}.rule=Host(`{$host}`) && Path(`{$path}`)";
} else { } else {
$labels[] = "traefik.http.routers.container.rule=Host(`{$host}`) && PathPrefix(`{$path}`)"; $labels[] = "traefik.http.routers.{$this->application->uuid}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
$labels[] = "traefik.http.routers.{$this->application->uuid}.middlewares={$this->application->uuid}-stripprefix";
$labels[] = "traefik.http.middlewares.{$this->application->uuid}-stripprefix.stripprefix.prefixes={$path}";
} }
} }
return $labels; return $labels;

View File

@ -33,7 +33,7 @@ function generalErrorHandler(\Throwable $e, $that = null, $isJson = false)
} }
} catch (\Throwable $error) { } catch (\Throwable $error) {
if ($that) { if ($that) {
$that->emit('error', $error->getMessage()); return $that->emit('error', $error->getMessage());
} elseif ($isJson) { } elseif ($isJson) {
return response()->json([ return response()->json([
'code' => $error->getCode(), 'code' => $error->getCode(),

View File

@ -6,8 +6,8 @@
@if ($environment->applications->count() === 0) @if ($environment->applications->count() === 0)
<p>No resources yet.</p> <p>No resources yet.</p>
@endif @endif
<div class="flex"> <div class="flex gap-2">
@foreach ($environment->applications as $application) @foreach ($environment->applications->sortBy('name') as $application)
<a class="box" <a class="box"
href="{{ route('project.application.configuration', [$project->uuid, $environment->name, $application->uuid]) }}"> href="{{ route('project.application.configuration', [$project->uuid, $environment->name, $application->uuid]) }}">
{{ $application->name }} {{ $application->name }}