mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-17 04:59:30 +00:00
fix: raw compose make dirs
fix: raw compose add coolify labels
This commit is contained in:
@@ -374,6 +374,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
$this->cleanup_git();
|
$this->cleanup_git();
|
||||||
$this->application->loadComposeFile(isInit: false);
|
$this->application->loadComposeFile(isInit: false);
|
||||||
if ($this->application->settings->is_raw_compose_deployment_enabled) {
|
if ($this->application->settings->is_raw_compose_deployment_enabled) {
|
||||||
|
$this->application->parseRawCompose();
|
||||||
$yaml = $composeFile = $this->application->docker_compose_raw;
|
$yaml = $composeFile = $this->application->docker_compose_raw;
|
||||||
} else {
|
} else {
|
||||||
$composeFile = $this->application->parseCompose(pull_request_id: $this->pull_request_id);
|
$composeFile = $this->application->parseCompose(pull_request_id: $this->pull_request_id);
|
||||||
@@ -413,7 +414,21 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$this->write_deployment_configurations();
|
$this->write_deployment_configurations();
|
||||||
|
|
||||||
// Start compose file
|
// Start compose file
|
||||||
|
if ($this->application->settings->is_raw_compose_deployment_enabled) {
|
||||||
|
if ($this->docker_compose_custom_start_command) {
|
||||||
|
$this->execute_remote_command(
|
||||||
|
["cd {$this->basedir} && {$this->docker_compose_custom_start_command}", "hidden" => true],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$server_workdir = $this->application->workdir();
|
||||||
|
ray("SOURCE_COMMIT={$this->commit} docker compose --project-directory {$server_workdir} -f {$server_workdir}{$this->docker_compose_location} up -d");
|
||||||
|
$this->execute_remote_command(
|
||||||
|
["SOURCE_COMMIT={$this->commit} docker compose --project-directory {$server_workdir} -f {$server_workdir}{$this->docker_compose_location} up -d", "hidden" => true],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if ($this->docker_compose_custom_start_command) {
|
if ($this->docker_compose_custom_start_command) {
|
||||||
$this->execute_remote_command(
|
$this->execute_remote_command(
|
||||||
[executeInDocker($this->deployment_uuid, "cd {$this->basedir} && {$this->docker_compose_custom_start_command}"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "cd {$this->basedir} && {$this->docker_compose_custom_start_command}"), "hidden" => true],
|
||||||
@@ -423,6 +438,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"), "hidden" => true],
|
[executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"), "hidden" => true],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->application_deployment_queue->addLogEntry("New container started.");
|
$this->application_deployment_queue->addLogEntry("New container started.");
|
||||||
}
|
}
|
||||||
private function deploy_dockerfile_buildpack()
|
private function deploy_dockerfile_buildpack()
|
||||||
|
|||||||
@@ -263,8 +263,12 @@ class General extends Component
|
|||||||
}
|
}
|
||||||
if ($this->application->build_pack === 'dockercompose') {
|
if ($this->application->build_pack === 'dockercompose') {
|
||||||
$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);
|
$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);
|
||||||
|
if ($this->application->settings->is_raw_compose_deployment_enabled) {
|
||||||
|
$this->application->parseRawCompose();
|
||||||
|
} else {
|
||||||
$this->parsedServices = $this->application->parseCompose();
|
$this->parsedServices = $this->application->parseCompose();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->application->custom_labels = base64_encode($this->customLabels);
|
$this->application->custom_labels = base64_encode($this->customLabels);
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
$showToaster && $this->dispatch('success', 'Application settings updated!');
|
$showToaster && $this->dispatch('success', 'Application settings updated!');
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
use Spatie\Activitylog\Models\Activity;
|
use Spatie\Activitylog\Models\Activity;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
class Application extends BaseModel
|
class Application extends BaseModel
|
||||||
@@ -476,6 +477,10 @@ class Application extends BaseModel
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public function workdir()
|
||||||
|
{
|
||||||
|
return application_configuration_dir() . "/{$this->uuid}";
|
||||||
|
}
|
||||||
public function isLogDrainEnabled()
|
public function isLogDrainEnabled()
|
||||||
{
|
{
|
||||||
return data_get($this, 'settings.is_log_drain_enabled', false);
|
return data_get($this, 'settings.is_log_drain_enabled', false);
|
||||||
@@ -710,6 +715,64 @@ class Application extends BaseModel
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function parseRawCompose()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$yaml = Yaml::parse($this->docker_compose_raw);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new \Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
$services = data_get($yaml, 'services');
|
||||||
|
$commands = collect([]);
|
||||||
|
$services = collect($services)->map(function ($service) use ($commands) {
|
||||||
|
$serviceVolumes = collect(data_get($service, 'volumes', []));
|
||||||
|
if ($serviceVolumes->count() > 0) {
|
||||||
|
foreach ($serviceVolumes as $volume) {
|
||||||
|
$workdir = $this->workdir();
|
||||||
|
$type = null;
|
||||||
|
$source = null;
|
||||||
|
if (is_string($volume)) {
|
||||||
|
$source = Str::of($volume)->before(':');
|
||||||
|
if ($source->startsWith('./') || $source->startsWith('/') || $source->startsWith('~')) {
|
||||||
|
$type = Str::of('bind');
|
||||||
|
}
|
||||||
|
} else if (is_array($volume)) {
|
||||||
|
$type = data_get_str($volume, 'type');
|
||||||
|
$source = data_get_str($volume, 'source');
|
||||||
|
}
|
||||||
|
if ($type->value() === 'bind') {
|
||||||
|
if ($source->value() === "/var/run/docker.sock") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($source->value() === '/tmp' || $source->value() === '/tmp/') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($source->startsWith('.')) {
|
||||||
|
$source = $source->after('.');
|
||||||
|
$source = $workdir . $source;
|
||||||
|
}
|
||||||
|
$commands->push("mkdir -p $source > /dev/null 2>&1 || true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$labels = collect(data_get($service, 'labels', []));
|
||||||
|
if (!$labels->contains('coolify.managed')) {
|
||||||
|
$labels->push('coolify.managed=true');
|
||||||
|
}
|
||||||
|
if (!$labels->contains('coolify.applicationId')) {
|
||||||
|
$labels->push('coolify.applicationId=' . $this->id);
|
||||||
|
}
|
||||||
|
if (!$labels->contains('coolify.type')) {
|
||||||
|
$labels->push('coolify.type=application');
|
||||||
|
}
|
||||||
|
data_set($service, 'labels', $labels->toArray());
|
||||||
|
return $service;
|
||||||
|
});
|
||||||
|
data_set($yaml, 'services', $services->toArray());
|
||||||
|
$this->docker_compose_raw = Yaml::dump($yaml, 10, 2);
|
||||||
|
|
||||||
|
instant_remote_process($commands, $this->destination->server, false);
|
||||||
|
}
|
||||||
function parseCompose(int $pull_request_id = 0)
|
function parseCompose(int $pull_request_id = 0)
|
||||||
{
|
{
|
||||||
if ($this->docker_compose_raw) {
|
if ($this->docker_compose_raw) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class LocalFileVolume extends BaseModel
|
class LocalFileVolume extends BaseModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<div class="group">
|
<div class="group">
|
||||||
@if (data_get($application, 'fqdn') ||
|
@if (
|
||||||
|
(data_get($application, 'fqdn') ||
|
||||||
collect(json_decode($this->application->docker_compose_domains))->count() > 0 ||
|
collect(json_decode($this->application->docker_compose_domains))->count() > 0 ||
|
||||||
data_get($application, 'previews', collect([]))->count() > 0 ||
|
data_get($application, 'previews', collect([]))->count() > 0 ||
|
||||||
data_get($application, 'ports_mappings_array'))
|
data_get($application, 'ports_mappings_array')) &&
|
||||||
|
data_get($application, 'settings.is_raw_compose_deployment_enabled') !== true)
|
||||||
<label tabindex="0" class="flex items-center gap-2 cursor-pointer hover:text-white"> Open Application
|
<label tabindex="0" class="flex items-center gap-2 cursor-pointer hover:text-white"> Open Application
|
||||||
<x-chevron-down />
|
<x-chevron-down />
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user