Skip to content

Commit b3f6a95

Browse files
authored
Merge pull request coollabsio#3783 from coollabsio/next
v4.0.0-beta.357
2 parents 1c6d47f + 9943199 commit b3f6a95

File tree

82 files changed

+4346
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4346
-150
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ yarn-error.log
2222
/_data
2323
.rnd
2424
/.ssh
25+
.ignition.json

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ _ide_helper_models.php
3232
.rnd
3333
/.ssh
3434
scripts/load-test/*
35+
.ignition.json
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Actions\Application;
4+
5+
use App\Models\Application;
6+
use Lorisleiva\Actions\Concerns\AsAction;
7+
8+
class GenerateConfig
9+
{
10+
use AsAction;
11+
12+
public function handle(Application $application, bool $is_json = false)
13+
{
14+
ray()->clearAll();
15+
return $application->generateConfig(is_json: $is_json);
16+
}
17+
}

app/Console/Commands/ServicesGenerate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public function handle()
3939
$serviceTemplatesJson[$name] = $parsed;
4040
}
4141
}
42-
$serviceTemplatesJson = json_encode($serviceTemplatesJson);
43-
file_put_contents(base_path('templates/service-templates.json'), $serviceTemplatesJson);
42+
$serviceTemplatesJson = json_encode($serviceTemplatesJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
43+
file_put_contents(base_path('templates/service-templates.json'), $serviceTemplatesJson.PHP_EOL);
4444
}
4545

4646
private function process_file($file)

app/Enums/StaticImageTypes.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
enum StaticImageTypes: string
6+
{
7+
case NGINX_ALPINE = 'nginx:alpine';
8+
}

app/Http/Controllers/Api/ApplicationsController.php

Lines changed: 47 additions & 31 deletions
Large diffs are not rendered by default.

app/Livewire/Project/Application/General.php

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Livewire\Project\Application;
44

5+
use App\Actions\Application\GenerateConfig;
56
use App\Models\Application;
67
use Illuminate\Support\Collection;
78
use Livewire\Component;
@@ -243,12 +244,19 @@ public function updatedApplicationBaseDirectory()
243244

244245
public function updatedApplicationFqdn()
245246
{
246-
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
247-
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
248-
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
249-
return str($domain)->trim()->lower();
250-
});
251-
$this->application->fqdn = $this->application->fqdn->unique()->implode(',');
247+
try {
248+
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
249+
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
250+
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
251+
return str($domain)->trim()->lower();
252+
});
253+
$this->application->fqdn = $this->application->fqdn->unique()->implode(',');
254+
$this->application->save();
255+
} catch (\Throwable $e) {
256+
$originalFqdn = $this->application->getOriginal('fqdn');
257+
$this->application->fqdn = $originalFqdn;
258+
return handleError($e, $this);
259+
}
252260
$this->resetDefaultLabels();
253261
}
254262

@@ -287,18 +295,22 @@ public function getWildcardDomain()
287295

288296
public function resetDefaultLabels()
289297
{
290-
if ($this->application->settings->is_container_label_readonly_enabled) {
291-
return;
292-
}
293-
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
294-
$this->ports_exposes = $this->application->ports_exposes;
295-
$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;
296-
$this->application->custom_labels = base64_encode($this->customLabels);
297-
$this->application->save();
298-
if ($this->application->build_pack === 'dockercompose') {
299-
$this->loadComposeFile();
298+
try {
299+
if ($this->application->settings->is_container_label_readonly_enabled) {
300+
return;
301+
}
302+
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
303+
$this->ports_exposes = $this->application->ports_exposes;
304+
$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;
305+
$this->application->custom_labels = base64_encode($this->customLabels);
306+
$this->application->save();
307+
if ($this->application->build_pack === 'dockercompose') {
308+
$this->loadComposeFile();
309+
}
310+
$this->dispatch('configurationChanged');
311+
} catch (\Throwable $e) {
312+
return handleError($e, $this);
300313
}
301-
$this->dispatch('configurationChanged');
302314
}
303315

304316
public function checkFqdns($showToaster = true)
@@ -413,4 +425,16 @@ public function submit($showToaster = true)
413425
$this->dispatch('configurationChanged');
414426
}
415427
}
428+
public function downloadConfig()
429+
{
430+
$config = GenerateConfig::run($this->application, true);
431+
$fileName = str($this->application->name)->slug()->append('_config.json');
432+
433+
return response()->streamDownload(function () use ($config) {
434+
echo $config;
435+
}, $fileName, [
436+
'Content-Type' => 'application/json',
437+
'Content-Disposition' => 'attachment; filename=' . $fileName,
438+
]);
439+
}
416440
}

app/Livewire/Project/New/PublicGitRepository.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ class PublicGitRepository extends Component
3131

3232
public bool $isStatic = false;
3333

34+
public bool $checkCoolifyConfig = true;
35+
3436
public ?string $publish_directory = null;
3537

3638
// In case of docker compose
37-
public ?string $base_directory = null;
39+
public string $base_directory = '/';
3840

3941
public ?string $docker_compose_location = '/docker-compose.yaml';
4042
// End of docker compose
@@ -97,6 +99,7 @@ public function updatedBaseDirectory()
9799
$this->base_directory = '/'.$this->base_directory;
98100
}
99101
}
102+
100103
}
101104

102105
public function updatedDockerComposeLocation()
@@ -275,6 +278,7 @@ public function submit()
275278
'destination_id' => $destination->id,
276279
'destination_type' => $destination_class,
277280
'build_pack' => $this->build_pack,
281+
'base_directory' => $this->base_directory,
278282
];
279283
} else {
280284
$application_init = [
@@ -289,6 +293,7 @@ public function submit()
289293
'source_id' => $this->git_source->id,
290294
'source_type' => $this->git_source->getMorphClass(),
291295
'build_pack' => $this->build_pack,
296+
'base_directory' => $this->base_directory,
292297
];
293298
}
294299

@@ -303,11 +308,15 @@ public function submit()
303308

304309
$application->settings->is_static = $this->isStatic;
305310
$application->settings->save();
306-
307311
$fqdn = generateFqdn($destination->server, $application->uuid);
308312
$application->fqdn = $fqdn;
309313
$application->save();
310-
314+
if ($this->checkCoolifyConfig) {
315+
// $config = loadConfigFromGit($this->repository_url, $this->git_branch, $this->base_directory, $this->query['server_id'], auth()->user()->currentTeam()->id);
316+
// if ($config) {
317+
// $application->setConfig($config);
318+
// }
319+
}
311320
return redirect()->route('project.application.configuration', [
312321
'application_uuid' => $application->uuid,
313322
'environment_name' => $environment->name,

app/Livewire/Project/New/Select.php

Lines changed: 7 additions & 7 deletions
Large diffs are not rendered by default.

app/Livewire/Project/Service/EditDomain.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ public function mount()
2323

2424
public function updatedApplicationFqdn()
2525
{
26-
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
27-
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
28-
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
29-
return str($domain)->trim()->lower();
30-
});
31-
$this->application->fqdn = $this->application->fqdn->unique()->implode(',');
32-
$this->application->save();
26+
try {
27+
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
28+
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
29+
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
30+
return str($domain)->trim()->lower();
31+
});
32+
$this->application->fqdn = $this->application->fqdn->unique()->implode(',');
33+
$this->application->save();
34+
} catch(\Throwable $e) {
35+
return handleError($e, $this);
36+
}
3337
}
3438

3539
public function submit()

0 commit comments

Comments
 (0)