Skip to content

Commit

Permalink
Merge pull request #4598 from coollabsio/next
Browse files Browse the repository at this point in the history
v4.0.0-beta.381
  • Loading branch information
andrasbacsai authored Jan 17, 2025
2 parents 676f616 + 54d656a commit 916f8e3
Show file tree
Hide file tree
Showing 399 changed files with 61,612 additions and 3,436 deletions.
8 changes: 4 additions & 4 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Coolify Configuration
APP_ID=
APP_NAME=Coolify
APP_KEY=

# PostgreSQL Database Configuration
DB_USERNAME=coolify
DB_PASSWORD=

# Redis Configuration
REDIS_PASSWORD=

# Pusher Configuration
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

ROOT_USERNAME=
ROOT_USER_EMAIL=
ROOT_USER_PASSWORD=
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Special thanks to our biggest sponsors!
* [PFGlabs](https://pfglabs.com/?ref=coolify.io) - Build real project with Golang.
* [Treive](https://trieve.ai/?ref=coolify.io) - An AI-powered search and discovery platform for enhancing information retrieval in large datasets.
* [Blacksmith](https://blacksmith.sh/?ref=coolify.io) - A cloud-native platform for automating infrastructure provisioning and management across multiple cloud providers.
* [Brand Dev](https://brand.dev/?ref=coolify.io) - A web development agency specializing in creating custom digital experiences and brand identities.
* [Brand Dev](https://brand.dev/?ref=coolify.io) - The #1 Brand API for B2B software startups - instantly pull logos, fonts, descriptions, social links, slogans, and so much more from any domain via a single api call.
* [Jobscollider](https://jobscollider.com/remote-jobs?ref=coolify.io) - A job search platform connecting professionals with remote work opportunities across various industries.
* [Hostinger](https://www.hostinger.com/vps/coolify-hosting?ref=coolify.io) - A web hosting provider offering affordable hosting solutions, domain registration, and website building tools.
* [Glueops](https://www.glueops.dev/?ref=coolify.io) - A DevOps consulting company providing infrastructure automation and cloud optimization services.
Expand All @@ -75,6 +75,7 @@ Special thanks to our biggest sponsors!
<a href="https://www.runpod.io/?ref=coolify.io">
<svg style="width:60px;height:60px;background:#fff;" xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 200 200"><g><path d="M74.5 51.1c-25.4 14.9-27 16-29.6 20.2-1.8 3-1.9 5.3-1.9 32.3 0 21.7.3 29.4 1.3 30.6 1.9 2.5 46.7 27.9 48.5 27.6 1.5-.3 1.7-3.1 2-27.7.2-21.9 0-27.8-1.1-29.5-.8-1.2-9.9-6.8-20.2-12.6-10.3-5.8-19.4-11.5-20.2-12.7-1.8-2.6-.9-5.9 1.8-7.4 1.6-.8 6.3 0 21.8 4C87.8 78.7 98 81 99.6 81c4.4 0 49.9-25.9 49.9-28.4 0-1.6-3.4-2.8-24-8.2-13.2-3.5-25.1-6.3-26.5-6.3-1.4.1-12.4 5.9-24.5 13z"></path><path d="m137.2 68.1-3.3 2.1 6.3 3.7c3.5 2 6.3 4.3 6.3 5.1 0 .9-8 6.1-19.4 12.6-10.6 6-20 11.9-20.7 12.9-1.2 1.6-1.4 7.2-1.2 29.4.3 24.8.5 27.6 2 27.9 1.8.3 46.6-25.1 48.6-27.6.9-1.2 1.2-8.8 1.2-30.2s-.3-29-1.2-30.2c-1.6-1.9-12.1-7.8-13.9-7.8-.8 0-2.9 1-4.7 2.1z"></path></g></svg></a>
<a href="https://lightspeed.run/?ref=coolify.io"><img src="https://github.com/lightspeedrun.png" width="60px" alt="Lightspeed.run"/></a>
<a href="https://dartnode.com/?ref=coolify.io"><img src="https://github.com/DartNode-com.png" width="60px" alt="DartNode"/></a>
<a href="https://www.flint.sh/en/home?ref=coolify.io"> <img src="https://github.com/Flint-company.png" width="60px" alt="FlintCompany"/></a>
<a href="https://americancloud.com/?ref=coolify.io"><img src="https://github.com/American-Cloud.png" width="60px" alt="American Cloud"/></a>
<a href="https://cryptojobslist.com/?ref=coolify.io"><img src="https://github.com/cryptojobslist.png" width="60px" alt="CryptoJobsList" /></a>
Expand Down
15 changes: 4 additions & 11 deletions app/Actions/CoolifyTask/RunRemoteProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,9 @@ public function __invoke(): ProcessResult
} else {
if ($processResult->exitCode() == 0) {
$status = ProcessStatus::FINISHED;
}
if ($processResult->exitCode() != 0 && ! $this->ignore_errors) {
} else {
$status = ProcessStatus::ERROR;
}
// if (($processResult->exitCode() == 0 && $this->is_finished) || $this->activity->properties->get('status') === ProcessStatus::FINISHED->value) {
// $status = ProcessStatus::FINISHED;
// }
// if ($processResult->exitCode() != 0 && !$this->ignore_errors) {
// $status = ProcessStatus::ERROR;
// }
}

$this->activity->properties = $this->activity->properties->merge([
Expand All @@ -110,9 +103,6 @@ public function __invoke(): ProcessResult
'status' => $status->value,
]);
$this->activity->save();
if ($processResult->exitCode() != 0 && ! $this->ignore_errors) {
throw new \RuntimeException($processResult->errorOutput(), $processResult->exitCode());
}
if ($this->call_event_on_finish) {
try {
if ($this->call_event_data) {
Expand All @@ -128,6 +118,9 @@ public function __invoke(): ProcessResult
Log::error('Error calling event: '.$e->getMessage());
}
}
if ($processResult->exitCode() != 0 && ! $this->ignore_errors) {
throw new \RuntimeException($processResult->errorOutput(), $processResult->exitCode());
}

return $processResult;
}
Expand Down
6 changes: 1 addition & 5 deletions app/Actions/Database/StartClickhouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public function handle(StandaloneClickhouse $database)
'hard' => 262144,
],
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => "clickhouse-client --password {$this->database->clickhouse_admin_password} --query 'SELECT 1'",
'interval' => '5s',
Expand Down
4 changes: 4 additions & 0 deletions app/Actions/Database/StartDatabaseProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
$type = \App\Models\StandaloneClickhouse::class;
$containerName = "clickhouse-{$database->service->uuid}";
break;
case 'standalone-supabase/postgres':
$type = \App\Models\StandalonePostgresql::class;
$containerName = "supabase-db-{$database->service->uuid}";
break;
}
}
if ($type === \App\Models\StandaloneRedis::class) {
Expand Down
6 changes: 1 addition & 5 deletions app/Actions/Database/StartDragonfly.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public function handle(StandaloneDragonfly $database)
'networks' => [
$this->database->destination->network,
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => "redis-cli -a {$this->database->dragonfly_password} ping",
'interval' => '5s',
Expand Down
6 changes: 1 addition & 5 deletions app/Actions/Database/StartKeydb.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ public function handle(StandaloneKeydb $database)
'networks' => [
$this->database->destination->network,
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => "keydb-cli --pass {$this->database->keydb_password} ping",
'interval' => '5s',
Expand Down
6 changes: 1 addition & 5 deletions app/Actions/Database/StartMariadb.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ public function handle(StandaloneMariadb $database)
'networks' => [
$this->database->destination->network,
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized'],
'interval' => '5s',
Expand Down
6 changes: 1 addition & 5 deletions app/Actions/Database/StartMongodb.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ public function handle(StandaloneMongodb $database)
'networks' => [
$this->database->destination->network,
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => [
'CMD',
Expand Down
6 changes: 1 addition & 5 deletions app/Actions/Database/StartMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ public function handle(StandaloneMysql $database)
'networks' => [
$this->database->destination->network,
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => ['CMD', 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', "-p{$this->database->mysql_root_password}"],
'interval' => '5s',
Expand Down
29 changes: 18 additions & 11 deletions app/Actions/Database/StartPostgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function handle(StandalonePostgresql $database)
$this->database = $database;
$container_name = $this->database->uuid;
$this->configuration_dir = database_configuration_dir().'/'.$container_name;
if (isDev()) {
$this->configuration_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/databases/'.$container_name;
}

$this->commands = [
"echo 'Starting database.'",
Expand All @@ -47,11 +50,7 @@ public function handle(StandalonePostgresql $database)
'networks' => [
$this->database->destination->network,
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => [
'CMD-SHELL',
Expand All @@ -78,7 +77,7 @@ public function handle(StandalonePostgresql $database)
],
],
];
if (! is_null($this->database->limits_cpuset)) {
if (filled($this->database->limits_cpuset)) {
data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
}
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
Expand Down Expand Up @@ -108,7 +107,7 @@ public function handle(StandalonePostgresql $database)
];
}
}
if (! is_null($this->database->postgres_conf) && ! empty($this->database->postgres_conf)) {
if (filled($this->database->postgres_conf)) {
$docker_compose['services'][$container_name]['volumes'][] = [
'type' => 'bind',
'source' => $this->configuration_dir.'/custom-postgres.conf',
Expand Down Expand Up @@ -199,9 +198,12 @@ private function generate_environment_variables()

private function generate_init_scripts()
{
if (is_null($this->database->init_scripts) || count($this->database->init_scripts) === 0) {
$this->commands[] = "rm -rf $this->configuration_dir/docker-entrypoint-initdb.d/*";

if (blank($this->database->init_scripts) || count($this->database->init_scripts) === 0) {
return;
}

foreach ($this->database->init_scripts as $init_script) {
$filename = data_get($init_script, 'filename');
$content = data_get($init_script, 'content');
Expand All @@ -213,17 +215,22 @@ private function generate_init_scripts()

private function add_custom_conf()
{
if (is_null($this->database->postgres_conf) || empty($this->database->postgres_conf)) {
$filename = 'custom-postgres.conf';
$config_file_path = "$this->configuration_dir/$filename";

if (blank($this->database->postgres_conf)) {
$this->commands[] = "rm -f $config_file_path";

return;
}
$filename = 'custom-postgres.conf';

$content = $this->database->postgres_conf;
if (! str($content)->contains('listen_addresses')) {
$content .= "\nlisten_addresses = '*'";
$this->database->postgres_conf = $content;
$this->database->save();
}
$content_base64 = base64_encode($content);
$this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null";
$this->commands[] = "echo '{$content_base64}' | base64 -d | tee $config_file_path > /dev/null";
}
}
6 changes: 1 addition & 5 deletions app/Actions/Database/StartRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ public function handle(StandaloneRedis $database)
'networks' => [
$this->database->destination->network,
],
'labels' => [
'coolify.managed' => 'true',
'coolify.type' => 'database',
'coolify.databaseId' => $this->database->id,
],
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => [
'test' => [
'CMD-SHELL',
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Docker/GetContainersStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function handle(Server $server, ?Collection $containers = null, ?Collecti
$preview->update(['last_online_at' => now()]);
}
} else {
//Notify user that this container should not be there.
// Notify user that this container should not be there.
}
} else {
$application = $this->applications->where('id', $applicationId)->first();
Expand All @@ -125,7 +125,7 @@ public function handle(Server $server, ?Collection $containers = null, ?Collecti
$application->update(['last_online_at' => now()]);
}
} else {
//Notify user that this container should not be there.
// Notify user that this container should not be there.
}
}
} else {
Expand Down
16 changes: 12 additions & 4 deletions app/Actions/Server/CleanupDocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,25 @@ public function handle(Server $server)
"docker images --filter before=$helperImageWithVersion --filter reference=$helperImage | grep $helperImage | awk '{print $3}' | xargs -r docker rmi -f",
];

$serverSettings = $server->settings;
if ($serverSettings->delete_unused_volumes) {
if ($server->settings->delete_unused_volumes) {
$commands[] = 'docker volume prune -af';
}

if ($serverSettings->delete_unused_networks) {
if ($server->settings->delete_unused_networks) {
$commands[] = 'docker network prune -f';
}

$cleanupLog = [];
foreach ($commands as $command) {
instant_remote_process([$command], $server, false);
$commandOutput = instant_remote_process([$command], $server, false);
if ($commandOutput !== null) {
$cleanupLog[] = [
'command' => $command,
'output' => $commandOutput,
];
}
}

return $cleanupLog;
}
}
5 changes: 5 additions & 0 deletions app/Console/Commands/CleanupStuckedResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ private function cleanup_stucked_resources()
$servers = Server::all()->filter(function ($server) {
return $server->isFunctional();
});
if (isCloud()) {
$servers = $servers->filter(function ($server) {
return data_get($server->team->subscription, 'stripe_invoice_paid', false) === true;
});
}
foreach ($servers as $server) {
CleanupHelperContainersJob::dispatch($server);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function handle()
'team_id' => 0,
]);
}
//$this->mail = (new BackupSuccess($backup->frequency, $db->name))->toMail();
// $this->mail = (new BackupSuccess($backup->frequency, $db->name))->toMail();
$this->sendEmail();
break;
// case 'invitation-link':
Expand Down
Loading

0 comments on commit 916f8e3

Please sign in to comment.