fix: show it docker compose has syntax errors
This commit is contained in:
parent
bea490081b
commit
7feb788ed3
@ -31,7 +31,7 @@ class General extends Component
|
|||||||
public ?string $initialDockerComposeLocation = null;
|
public ?string $initialDockerComposeLocation = null;
|
||||||
public ?string $initialDockerComposePrLocation = null;
|
public ?string $initialDockerComposePrLocation = null;
|
||||||
|
|
||||||
public $parsedServices = [];
|
public null|Collection $parsedServices;
|
||||||
public $parsedServiceDomains = [];
|
public $parsedServiceDomains = [];
|
||||||
|
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
@ -118,6 +118,10 @@ class General extends Component
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->parsedServices = $this->application->parseCompose();
|
$this->parsedServices = $this->application->parseCompose();
|
||||||
|
if (is_null($this->parsedServices) || empty($this->parsedServices)) {
|
||||||
|
$this->dispatch('error', "Failed to parse your docker-compose file. Please check the syntax and try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->dispatch('error', $e->getMessage());
|
$this->dispatch('error', $e->getMessage());
|
||||||
}
|
}
|
||||||
@ -160,6 +164,10 @@ class General extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation, 'initialDockerComposePrLocation' => $this->initialDockerComposePrLocation] = $this->application->loadComposeFile($isInit);
|
['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation, 'initialDockerComposePrLocation' => $this->initialDockerComposePrLocation] = $this->application->loadComposeFile($isInit);
|
||||||
|
if (is_null($this->parsedServices)) {
|
||||||
|
$this->dispatch('error', "Failed to parse your docker-compose file. Please check the syntax and try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
$compose = $this->application->parseCompose();
|
$compose = $this->application->parseCompose();
|
||||||
$services = data_get($compose, 'services');
|
$services = data_get($compose, 'services');
|
||||||
if ($services) {
|
if ($services) {
|
||||||
|
@ -879,7 +879,7 @@ class Application extends BaseModel
|
|||||||
if (!$composeFileContent) {
|
if (!$composeFileContent) {
|
||||||
$this->docker_compose_location = $initialDockerComposeLocation;
|
$this->docker_compose_location = $initialDockerComposeLocation;
|
||||||
$this->save();
|
$this->save();
|
||||||
throw new \RuntimeException("Docker Compose file not found at: $workdir$composeFile");
|
throw new \RuntimeException("Docker Compose file not found at: $workdir$composeFile<br><br>Check if you used the right extension (.yaml or .yml) in the compose file name.");
|
||||||
} else {
|
} else {
|
||||||
$this->docker_compose_raw = $composeFileContent;
|
$this->docker_compose_raw = $composeFileContent;
|
||||||
$this->save();
|
$this->save();
|
||||||
|
@ -1232,13 +1232,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
try {
|
try {
|
||||||
$yaml = Yaml::parse($resource->docker_compose_pr_raw);
|
$yaml = Yaml::parse($resource->docker_compose_pr_raw);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \Exception($e->getMessage());
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$yaml = Yaml::parse($resource->docker_compose_raw);
|
$yaml = Yaml::parse($resource->docker_compose_raw);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \Exception($e->getMessage());
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$server = $resource->destination->server;
|
$server = $resource->destination->server;
|
||||||
|
@ -38,7 +38,11 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if ($application->build_pack === 'dockercompose')
|
@if ($application->build_pack === 'dockercompose')
|
||||||
@if (count($parsedServices) > 0 && !$application->settings->is_raw_compose_deployment_enabled)
|
|
||||||
|
@if (
|
||||||
|
!is_null($parsedServices) &&
|
||||||
|
count($parsedServices) > 0 &&
|
||||||
|
!$application->settings->is_raw_compose_deployment_enabled)
|
||||||
<h3 class="pt-6">Domains</h3>
|
<h3 class="pt-6">Domains</h3>
|
||||||
@foreach (data_get($parsedServices, 'services') as $serviceName => $service)
|
@foreach (data_get($parsedServices, 'services') as $serviceName => $service)
|
||||||
@if (!isDatabaseImage(data_get($service, 'image')))
|
@if (!isDatabaseImage(data_get($service, 'image')))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user