This commit is contained in:
Andras Bacsai 2023-08-17 13:14:46 +02:00
parent d48af9cea4
commit c26002426f
2 changed files with 18 additions and 11 deletions

View File

@ -152,7 +152,7 @@ public function submit()
if ($this->application->publish_directory && $this->application->publish_directory !== '/') {
$this->application->publish_directory = rtrim($this->application->publish_directory, '/');
}
$this->application->fqdn = $domains->implode(',');
$this->application->fqdn = data_get($domains->implode(','), '', null);
$this->application->save();
$this->emit('success', 'Application settings updated!');
} catch (\Exception $e) {

View File

@ -2,14 +2,15 @@
use App\Models\Server;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
function format_docker_command_output_to_json($rawOutput): Collection
{
$outputLines = explode(PHP_EOL, $rawOutput);
return collect($outputLines)
->reject(fn($line) => empty($line))
->map(fn($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR));
->reject(fn ($line) => empty($line))
->map(fn ($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR));
}
function format_docker_labels_to_json($rawOutput): Collection
@ -17,7 +18,7 @@ function format_docker_labels_to_json($rawOutput): Collection
$outputLines = explode(PHP_EOL, $rawOutput);
return collect($outputLines)
->reject(fn($line) => empty($line))
->reject(fn ($line) => empty($line))
->map(function ($outputLine) {
$outputArray = explode(',', $outputLine);
return collect($outputArray)
@ -54,7 +55,7 @@ function get_container_status(Server $server, string $container_id, bool $all_da
if ($all_data) {
return $container[0];
}
return $container[0]['State']['Status'];
return data_get($container[0], 'State.Status', 'exited');
}
function generate_container_name(string $uuid, int $pull_request_id = 0)
@ -67,11 +68,17 @@ function generate_container_name(string $uuid, int $pull_request_id = 0)
}
function get_port_from_dockerfile($dockerfile): int
{
$port = preg_grep('/EXPOSE\s+(\d+)/', explode("\n", $dockerfile));
if (count($port) > 0 && preg_match('/EXPOSE\s+(\d+)/', $port[1], $matches)) {
$port = $matches[1];
} else {
$port = 80;
$dockerfile_array = explode("\n", $dockerfile);
$found_exposed_port = null;
foreach ($dockerfile_array as $line) {
$line_str = Str::of($line)->trim();
if ($line_str->startsWith('EXPOSE')) {
$found_exposed_port = $line_str->replace('EXPOSE', '')->trim();
break;
}
}
return $port;
if ($found_exposed_port) {
return (int)$found_exposed_port->value();
}
return 80;
}