coolify/app/Actions/Server
Andras Bacsai d9774d2968 Fix: Prevent version downgrades and centralize CDN configuration (#7383)
## Root Cause
Between Nov 25-26, a CDN redirect was added without curl's `-L` flag,
causing version cache corruption and automatic downgrades.

## Three Critical Bugs Fixed

### Bug #1: CheckForUpdatesJob could overwrite newer cached version
- Problem: CDN serving older version would overwrite local cache
- Solution: Smart version merge - keep max Coolify version, update other components
- Location: app/Jobs/CheckForUpdatesJob.php:33-52

### Bug #2: Manual updates bypassed downgrade protection
- Problem: Downgrade guard only applied to auto-updates
- Solution: Always block downgrades for both manual and auto-updates
- Location: app/Actions/Server/UpdateCoolify.php:65-75

### Bug #3: Updates used stale local cache
- Problem: Never validated cache against CDN at update time
- Solution: Fetch fresh CDN data before executing updates
- Location: app/Actions/Server/UpdateCoolify.php:34-49

## Additional Improvement: Centralized CDN Configuration

Added three new config keys for easy CDN management:
- `cdn_url` - Base CDN URL (default: https://cdn.coollabs.io)
- `versions_url` - Full versions.json URL
- `upgrade_script_url` - Full upgrade.sh URL

All configurable via environment variables:
```bash
CDN_URL=https://cdn.coolify.io
VERSIONS_URL=https://custom-cdn.example.com/versions.json
UPGRADE_SCRIPT_URL=https://custom-cdn.example.com/upgrade.sh
```

## Files Modified
- config/constants.php - CDN configuration
- app/Jobs/CheckForUpdatesJob.php - Smart version merge + centralized URL
- app/Actions/Server/UpdateCoolify.php - Downgrade protection + fresh fetch + centralized URLs
- app/Jobs/CheckHelperImageJob.php - Centralized URL
- bootstrap/helpers/shared.php - Centralized URL

## Testing
-  All modified files pass Pint formatting
-  78 unit tests pass (2 pre-existing failures unrelated to changes)

## Impact
- No breaking changes - defaults to current CDN
- Easy CDN migration via environment variables
- Prevents all downgrade scenarios
- Maintains independent Sentinel/Helper/Traefik updates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 15:20:33 +01:00
..
CheckUpdates.php refactor(error-handling): remove ray debugging statements from CheckUpdates and shared helper functions to clean up error reporting 2025-09-08 14:03:27 +02:00
CleanupDocker.php feat: add dev_helper_version to instance settings and update related functionality 2025-11-03 08:38:43 +01:00
ConfigureCloudflared.php Revert "refactor(file-transfer): replace base64 encoding with direct file transfer method across multiple database actions for improved clarity and efficiency" 2025-09-15 17:55:08 +02:00
DeleteServer.php feat: implement Hetzner deletion failure notification system with email and messaging support 2025-10-10 09:35:58 +02:00
InstallDocker.php feat: implement prerequisite validation and installation for server setup 2025-11-21 09:49:33 +01:00
InstallPrerequisites.php feat: implement prerequisite validation and installation for server setup 2025-11-21 09:49:33 +01:00
ResourcesCheck.php Revert "rector: arrrrr" 2025-01-07 15:31:43 +01:00
RestartContainer.php fix: restart sentinel once a day 2024-10-29 10:28:05 +01:00
RunCommand.php Inline many variables. 2024-10-31 18:20:11 +01:00
StartLogDrain.php Revert "refactor(file-transfer): replace base64 encoding with direct file transfer method across multiple database actions for improved clarity and efficiency" 2025-09-15 17:55:08 +02:00
StartSentinel.php feat(sentinel): add support for custom Docker images in StartSentinel and related methods 2025-09-14 19:21:55 +02:00
StopLogDrain.php Revert "rector: arrrrr" 2025-01-07 15:31:43 +01:00
StopSentinel.php pint 2024-10-17 22:08:23 +02:00
UpdateCoolify.php Fix: Prevent version downgrades and centralize CDN configuration (#7383) 2025-11-28 15:20:33 +01:00
UpdatePackage.php chore(core): remove unused function 2025-05-20 13:17:43 +02:00
ValidatePrerequisites.php feat: enhance prerequisite validation to return detailed results 2025-11-21 13:14:48 +01:00
ValidateServer.php feat: enhance prerequisite validation to return detailed results 2025-11-21 13:14:48 +01:00