Implement a per-application setting (`docker_images_to_keep`) in `application_settings` table to control how many Docker images are preserved during cleanup. The cleanup process now: - Respects per-application retention settings (default: 2 images) - Preserves the N most recent images per application for easy rollback - Always deletes PR images and keeps the currently running image - Dynamically excludes application images from general Docker image prune - Cleans up non-Coolify unused images to prevent disk bloat Fixes issues where cleanup would delete all images needed for rollback. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ApplicationSetting extends Model
|
|
{
|
|
protected $casts = [
|
|
'is_static' => 'boolean',
|
|
'is_spa' => 'boolean',
|
|
'is_build_server_enabled' => 'boolean',
|
|
'is_preserve_repository_enabled' => 'boolean',
|
|
'is_container_label_escape_enabled' => 'boolean',
|
|
'is_container_label_readonly_enabled' => 'boolean',
|
|
'use_build_secrets' => 'boolean',
|
|
'inject_build_args_to_dockerfile' => 'boolean',
|
|
'include_source_commit_in_build' => 'boolean',
|
|
'is_auto_deploy_enabled' => 'boolean',
|
|
'is_force_https_enabled' => 'boolean',
|
|
'is_debug_enabled' => 'boolean',
|
|
'is_preview_deployments_enabled' => 'boolean',
|
|
'is_pr_deployments_public_enabled' => 'boolean',
|
|
'is_git_submodules_enabled' => 'boolean',
|
|
'is_git_lfs_enabled' => 'boolean',
|
|
'is_git_shallow_clone_enabled' => 'boolean',
|
|
'docker_images_to_keep' => 'integer',
|
|
];
|
|
|
|
protected $guarded = [];
|
|
|
|
public function isStatic(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
set: function ($value) {
|
|
if ($value) {
|
|
$this->application->ports_exposes = 80;
|
|
}
|
|
$this->application->save();
|
|
|
|
return $value;
|
|
}
|
|
);
|
|
}
|
|
|
|
public function application()
|
|
{
|
|
return $this->belongsTo(Application::class);
|
|
}
|
|
}
|