feat: auto-update system, background command execution, standard classes refactor, and more#58
Conversation
Introduce centralized ContainerInfo and StackInfo PHP classes in util.php that normalize container identity and stack metadata across the codebase. PHP changes: - ContainerInfo: PascalCase->camelCase normalization, fromDockerInspect(), fromUpdateResponse(), mergeUpdateStatus(), toArray(), toUpdateArray(), automatic isPinned derivation from @sha256: in image reference - StackInfo: eager identity (project, sanitizedName, path, composeSource, composeFilePath, isIndirect, overrideInfo) with lazy metadata getters (getName, getDescription, getEnvFilePath, getIconUrl, getWebUIUrl, getDefaultProfiles, getAutostart, getStartedAt, getProfiles), getDefinedServices(), buildComposeArgs(), pruneOrphanOverrideServices() Migrated PHP callers: - exec.php: getStackContainers, checkStackUpdates, checkAllStacksUpdates - exec_functions.php: buildComposeArgs() now thin deprecated wrapper - compose_util_functions.php: echoComposeCommand, echoComposeCommandMultiple - compose_list.php: all inline metadata reads replaced with StackInfo - dashboard_stacks.php: metadata reads replaced with StackInfo JS changes: - Added createContainerInfo(), createStackInfo(), mergeStackUpdateStatus() factory functions for consistent client-side normalization - Migrated buildStackInfoFromCache() to use createStackInfo() - Migrated checkStackUpdates() inline construction to createStackInfo() - Migrated updateParentStackFromContainers() to mergeStackUpdateStatus() - Replaced both PascalCase normalization blocks with createContainerInfo() - Updated mergeUpdateStatus() to use createContainerInfo() for name matching Tests: - ContainerInfoTest: 22 tests covering both factories, merge, serialization - StackInfoTest: 33 tests covering identity, compose resolution, metadata, caching, and buildComposeArgs - All 304 existing tests pass (0 failures, 7 pre-existing skips)
- Remove unnecessary Object.assign merging of PascalCase originals - Align JS createContainerInfo shell default to '/bin/bash' - Add @ to file_get_contents in StackInfo constructor - Make OverrideInfo::getDefinedServices() private - Fix htmlspecialchars(null) deprecation in compose_list.php - Remove extra blank doc-comment lines in OverrideInfo::resolve()
- Add OverrideInfo::fromStackInfo() as primary factory that accepts pre-resolved StackInfo fields, eliminating duplicate filesystem I/O - Extract resolveOverride() as shared core for both factory paths - Deprecate OverrideInfo::fromStack() (kept for backward compat) - Remove $composeRoot, getProjectPath(), getDefinedServices() from OverrideInfo — these were stack-level concerns - Simplify pruneOrphanServices() to accept string[] instead of resolving services internally - Add getMainFileServices() to StackInfo for pruning without override - Replace remaining OverrideInfo::fromStack() calls in exec.php with StackInfo::fromProject() - Fix addStack passing display name instead of folder basename - Add StackInfo::clearCache() to test setUp methods
Move stack directory creation logic from the exec.php addStack handler into a new StackInfo::createNew() static factory method. This centralizes folder naming, collision avoidance, compose/indirect file wiring, metadata writes, and override initialization inside the domain class that already models these artifacts. - Add StackInfo::createNew() with folder sanitization, collision handling, indirect support, and metadata file creation - Move sanitizeFolderName() to util.php (backward-compat stub in exec_functions.php) - Reduce addStack case to input validation + factory call + JSON response - Add 10 unit tests covering createNew() scenarios (basic, indirect, collision, description, caching, override init)
- Prevent compounded random suffixes on folder name collisions by always appending a single random suffix to the base name - Add safety cap to collision attempts to avoid infinite loops - Validate empty and whitespace stack names, throwing clear exceptions - Add tests for empty name, whitespace name, and collision suffix behavior
…nd improved HTML escaping
- sanitizeFolderName: block path traversal (/, \, ..) - StackInfo::createNew: add defense-in-depth path validation - Fix error message trailing period mismatch with tests - Use COMPOSE_FILE_NAMES[0] instead of hard-coded compose.yaml - Sanitize exception messages returned to client (hide filesystem paths)
- Introduced deploy.ps1 script for building and deploying the compose.manager package to Unraid servers. - Created autoupdate.php to handle configuration retrieval, saving, and cron job management for auto-updates. - Implemented autoupdate_runner.php to execute scheduled updates based on autoupdate.json configuration. - Added compose_projects.php to list available Docker Compose projects. - Developed compose_autoupdate.sh script to perform the actual Docker Compose update process. - Created unit tests for autoupdate_runner.php and autoupdate.php to ensure functionality and error handling.
…t listing in exec.php
…kInfo integration
- Fix path boundary check in isAllowedAutoUpdatePath() to prevent false positives (e.g. /mnt/compose_root_evil matching /mnt/compose_root) - Switch cron install/remove/status to use crontab marker blocks instead of /etc/cron.d, which is not persistent across Unraid reboots - Fix scheduling timing: use last_run tracking so any configured time triggers correctly regardless of the 15-minute cron polling interval - Validate and sanitize time format in autoupdate_runner.php before use - Validate stack paths in autoupdate_runner.php against compose_root before executing scheduled updates - Validate stack path keys in saveConfig to prevent security bypass - Add flock-based locking to compose_autoupdate.sh to prevent race conditions with concurrent stack operations - Remove unused PLUGIN_ROOT variable from compose_autoupdate.sh - Fix JSON double-parse in loadUpdatesUI() and refreshCronStatus() since jQuery auto-parses JSON responses from Content-Type headers - Escape time value in Updates tab table rows to prevent stored XSS
Owner
Author
|
I will wait one more week before merge. Only bug fixes from here out. If you have any issues with the beta please comment here over posting an issue. |
…ing and improved logging
…w tab with 502 instead of logs
… visibility, used docker mangers css for this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR promotes the
devbeta track to stable. It has been running in production on the beta channel with good results.Issues Addressed
bd01b65,ca35b2a,90d8f68, and follow-up commits)52a7666,6a2dfa6)81f0a74,009b427)52a7666,6a2dfa6)5c9386f,444c8e8)Update & RebuildandForce Update & Rebuildfor stacks withbuild:directives (7e385d1)d5cbc5c,03488f2)What's New
Auto-Update System
A full auto-update feature for Docker Compose stacks - compares pinned/digest hashes, runs on a configurable cron schedule, and exposes full UI controls.
autoupdate.jsonconfig with JSON validation and safe crontab removalBackground Compose Command Execution (Background Actions)
Compose commands (up, down, pull, etc.) now run in the background with async logging and browser notifications, so the UI is no longer blocked during long operations.
Standard Classes Refactor (
ContainerInfo/StackInfo)Introduces proper PHP classes to normalize container and stack data throughout the backend.
StackInfocaching with cache management methodsStackInfo::createNew()internalized with improved folder naming and input validationOverrideInfodecoupled from stack identity resolutiontoUpdateArrayso update badges retain contextOverride Management
OverrideInfoclasspruneOrphanOverrideServices()automatically removes stale service entries from override files on compose upSecurity
isIndirect()path validation hardened with additional checksisValidPath()/isAllowedPath()methods toUtilUI Fixes
Build & CI
versions.envin build scriptsSkipTestsparameter added to build script for faster iterationFORCE_JAVASCRIPT_ACTIONS_TO_NODE24standardized across all workflowsTests
AutoupdateTestaligned with path validation and encoding changesphpunit.xmlfailOnWarningset to false to unblock CI