Merge branch 'next' into proxy-fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\EnvironmentVariable;
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneClickhouse;
|
||||
use App\Models\StandaloneDocker;
|
||||
@@ -48,7 +49,7 @@ function create_standalone_redis($environment_id, $destination_uuid, ?array $oth
|
||||
}
|
||||
$database = new StandaloneRedis;
|
||||
$database->name = generate_database_name('redis');
|
||||
$database->redis_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$redis_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
@@ -57,6 +58,20 @@ function create_standalone_redis($environment_id, $destination_uuid, ?array $oth
|
||||
}
|
||||
$database->save();
|
||||
|
||||
EnvironmentVariable::create([
|
||||
'key' => 'REDIS_PASSWORD',
|
||||
'value' => $redis_password,
|
||||
'standalone_redis_id' => $database->id,
|
||||
'is_shared' => false,
|
||||
]);
|
||||
|
||||
EnvironmentVariable::create([
|
||||
'key' => 'REDIS_USERNAME',
|
||||
'value' => 'default',
|
||||
'standalone_redis_id' => $database->id,
|
||||
'is_shared' => false,
|
||||
]);
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,10 +335,11 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
|
||||
if (preg_match('/coolify\.traefik\.middlewares=(.*)/', $item, $matches)) {
|
||||
return explode(',', $matches[1]);
|
||||
}
|
||||
|
||||
return null;
|
||||
})->flatten()
|
||||
->filter()
|
||||
->unique();
|
||||
->filter()
|
||||
->unique();
|
||||
}
|
||||
foreach ($domains as $loop => $domain) {
|
||||
try {
|
||||
@@ -388,7 +389,7 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
|
||||
if ($path !== '/') {
|
||||
// Middleware handling
|
||||
$middlewares = collect([]);
|
||||
if ($is_stripprefix_enabled && !str($image)->contains('ghost')) {
|
||||
if ($is_stripprefix_enabled && ! str($image)->contains('ghost')) {
|
||||
$labels->push("traefik.http.middlewares.{$https_label}-stripprefix.stripprefix.prefixes={$path}");
|
||||
$middlewares->push("{$https_label}-stripprefix");
|
||||
}
|
||||
@@ -402,7 +403,7 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
|
||||
$labels = $labels->merge($redirect_to_non_www);
|
||||
$middlewares->push($to_non_www_name);
|
||||
}
|
||||
if ($redirect_direction === 'www' && !str($host)->startsWith('www.')) {
|
||||
if ($redirect_direction === 'www' && ! str($host)->startsWith('www.')) {
|
||||
$labels = $labels->merge($redirect_to_www);
|
||||
$middlewares->push($to_www_name);
|
||||
}
|
||||
@@ -417,7 +418,7 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
|
||||
$middlewares = collect([]);
|
||||
if ($is_gzip_enabled) {
|
||||
$middlewares->push('gzip');
|
||||
}
|
||||
}
|
||||
if (str($image)->contains('ghost')) {
|
||||
$middlewares->push('redir-ghost');
|
||||
}
|
||||
|
||||
@@ -241,6 +241,7 @@ function generate_default_proxy_configuration(Server $server)
|
||||
'ports' => [
|
||||
'80:80',
|
||||
'443:443',
|
||||
'443:443/udp',
|
||||
],
|
||||
'labels' => [
|
||||
'coolify.managed=true',
|
||||
|
||||
@@ -126,7 +126,7 @@ function refreshSession(?Team $team = null): void
|
||||
}
|
||||
function handleError(?Throwable $error = null, ?Livewire\Component $livewire = null, ?string $customErrorMessage = null)
|
||||
{
|
||||
ray($error);
|
||||
loggy($error);
|
||||
if ($error instanceof TooManyRequestsException) {
|
||||
if (isset($livewire)) {
|
||||
return $livewire->dispatch('error', "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds.");
|
||||
@@ -142,6 +142,10 @@ function handleError(?Throwable $error = null, ?Livewire\Component $livewire = n
|
||||
return 'Duplicate entry found. Please use a different name.';
|
||||
}
|
||||
|
||||
if ($error instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if ($error instanceof Throwable) {
|
||||
$message = $error->getMessage();
|
||||
} else {
|
||||
@@ -164,10 +168,10 @@ function get_route_parameters(): array
|
||||
function get_latest_sentinel_version(): string
|
||||
{
|
||||
try {
|
||||
$response = Http::get('https://cdn.coollabs.io/sentinel/versions.json');
|
||||
$response = Http::get('https://cdn.coollabs.io/coolify/versions.json');
|
||||
$versions = $response->json();
|
||||
|
||||
return data_get($versions, 'sentinel.version');
|
||||
return data_get($versions, 'coolify.sentinel.version');
|
||||
} catch (\Throwable $e) {
|
||||
//throw $e;
|
||||
ray($e->getMessage());
|
||||
@@ -1338,13 +1342,6 @@ function isAnyDeploymentInprogress()
|
||||
exit(0);
|
||||
}
|
||||
|
||||
function generateSentinelToken()
|
||||
{
|
||||
$token = Str::random(64);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
function isBase64Encoded($strValue)
|
||||
{
|
||||
return base64_encode(base64_decode($strValue, true)) === $strValue;
|
||||
@@ -3569,6 +3566,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
]);
|
||||
} else {
|
||||
if ($value->startsWith('$')) {
|
||||
$isRequired = false;
|
||||
if ($value->contains(':-')) {
|
||||
$value = replaceVariables($value);
|
||||
$key = $value->before(':');
|
||||
@@ -3583,11 +3581,13 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
|
||||
$key = $value->before(':');
|
||||
$value = $value->after(':?');
|
||||
$isRequired = true;
|
||||
} elseif ($value->contains('?')) {
|
||||
$value = replaceVariables($value);
|
||||
|
||||
$key = $value->before('?');
|
||||
$value = $value->after('?');
|
||||
$isRequired = true;
|
||||
}
|
||||
if ($originalValue->value() === $value->value()) {
|
||||
// This means the variable does not have a default value, so it needs to be created in Coolify
|
||||
@@ -3598,6 +3598,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
], [
|
||||
'is_build_time' => false,
|
||||
'is_preview' => false,
|
||||
'is_required' => $isRequired,
|
||||
]);
|
||||
// Add the variable to the environment so it will be shown in the deployable compose file
|
||||
$environment[$parsedKeyValue->value()] = $resource->environment_variables()->where('key', $parsedKeyValue)->where($nameOfId, $resource->id)->first()->value;
|
||||
@@ -3611,6 +3612,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
'value' => $value,
|
||||
'is_build_time' => false,
|
||||
'is_preview' => false,
|
||||
'is_required' => $isRequired,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -3787,7 +3789,6 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
||||
service_name: $serviceName,
|
||||
image: $image,
|
||||
predefinedPort: $predefinedPort
|
||||
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -3985,13 +3986,14 @@ function instanceSettings()
|
||||
return InstanceSettings::get();
|
||||
}
|
||||
|
||||
function loadConfigFromGit(string $repository, string $branch, string $base_directory, int $server_id, int $team_id) {
|
||||
function loadConfigFromGit(string $repository, string $branch, string $base_directory, int $server_id, int $team_id)
|
||||
{
|
||||
|
||||
$server = Server::find($server_id)->where('team_id', $team_id)->first();
|
||||
if (!$server) {
|
||||
if (! $server) {
|
||||
return;
|
||||
}
|
||||
$uuid = new Cuid2();
|
||||
$uuid = new Cuid2;
|
||||
$cloneCommand = "git clone --no-checkout -b $branch $repository .";
|
||||
$workdir = rtrim($base_directory, '/');
|
||||
$fileList = collect([".$workdir/coolify.json"]);
|
||||
@@ -4009,6 +4011,33 @@ function loadConfigFromGit(string $repository, string $branch, string $base_dire
|
||||
try {
|
||||
return instant_remote_process($commands, $server);
|
||||
} catch (\Exception $e) {
|
||||
// continue
|
||||
// continue
|
||||
}
|
||||
}
|
||||
|
||||
function loggy($message = null, array $context = [])
|
||||
{
|
||||
if (! isDev()) {
|
||||
return;
|
||||
}
|
||||
if (function_exists('ray') && config('app.debug')) {
|
||||
ray($message, $context);
|
||||
}
|
||||
if (is_null($message)) {
|
||||
return app('log');
|
||||
}
|
||||
|
||||
return app('log')->debug($message, $context);
|
||||
}
|
||||
function sslipDomainWarning(string $domains)
|
||||
{
|
||||
$domains = str($domains)->trim()->explode(',');
|
||||
$showSslipHttpsWarning = false;
|
||||
$domains->each(function ($domain) use (&$showSslipHttpsWarning) {
|
||||
if (str($domain)->contains('https') && str($domain)->contains('sslip')) {
|
||||
$showSslipHttpsWarning = true;
|
||||
}
|
||||
});
|
||||
|
||||
return $showSslipHttpsWarning;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user