Skip to content

Add Docker update support via Watchtower integration#1330

Open
Sebbeben wants to merge 3 commits intoPart-DB:masterfrom
Sebbeben:feature/docker-watchtower-update
Open

Add Docker update support via Watchtower integration#1330
Sebbeben wants to merge 3 commits intoPart-DB:masterfrom
Sebbeben:feature/docker-watchtower-update

Conversation

@Sebbeben
Copy link
Contributor

@Sebbeben Sebbeben commented Mar 25, 2026

Summary

Extends the Update Manager to support Docker-based installations by integrating with Watchtower, a popular container update tool.

  • WatchtowerClient service — communicates with Watchtower's HTTP API to check status and trigger updates
  • Docker update progress page — Stimulus-based polling UI that survives container restarts, with progress indicators and timeout handling
  • Health endpoint (/update-manager/health) — unauthenticated JSON endpoint for post-restart detection (session is lost when container restarts)
  • Docker-specific UI — hides Git-only fields (branch, commit, local changes) for Docker installs, shows Watchtower connection status
  • Pre-update backup — creates database backup before triggering Watchtower
  • CSP fix — replaces javascript:history.back() with proper navigation in error template

How it works

  1. User clicks "Update to latest version" on the Update Manager page
  2. Part-DB creates a database backup
  3. Part-DB calls Watchtower's HTTP API to trigger an update
  4. User is redirected to a progress page that polls the health endpoint
  5. When the container restarts with the new image, the health endpoint responds and the UI shows success

Configuration

Docker users add a Watchtower sidecar to their docker-compose.yml:

watchtower:
  image: containrrr/watchtower
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  environment:
    - WATCHTOWER_HTTP_API_UPDATE=true
    - WATCHTOWER_HTTP_API_TOKEN=your-secret-token
    - WATCHTOWER_LABEL_ENABLE=true
  ports:
    - "8080:8080"

And set environment variables for Part-DB:

WATCHTOWER_API_URL=http://watchtower:8080
WATCHTOWER_API_TOKEN=your-secret-token

If Watchtower is not configured, the Update Manager gracefully shows an informational message explaining how to enable Docker updates.

Files changed

File Purpose
src/Services/System/WatchtowerClient.php New — Watchtower HTTP API client
src/Controller/UpdateManagerController.php Docker update actions + health endpoint
src/Services/System/UpdateChecker.php Watchtower status in update info
src/Services/System/UpdateExecutor.php Docker update validation
src/Services/System/InstallationType.php Docker supports auto-update
src/EventSubscriber/MaintenanceModeSubscriber.php Whitelist health endpoint
assets/controllers/docker_update_progress_controller.js New — Stimulus polling controller
templates/admin/update_manager/docker_progress.html.twig New — Progress page template
templates/admin/update_manager/index.html.twig Docker-specific UI sections
templates/bundles/TwigBundle/Exception/error.html.twig CSP fix for back link
translations/messages.en.xlf Translation keys for Docker update UI

Test plan

  • PHPStan passes (verified, 0 errors)
  • Tested on Docker installation (Orange Pi ARM64) with Watchtower sidecar
  • Verified update progress UI survives container restart
  • Verified graceful degradation when Watchtower is not installed
  • Verified health endpoint is accessible without authentication
  • Verified CSRF protection on all mutating endpoints

Screenshots

Update Manager - Docker Installation

update_manager_docker

Update in Progress

updating

Update Complete

update_complete note: this is when i was developing and thats why it says updating from v2.9.0 -> v2.9.0

Enable web-based updates for Docker installations by integrating with
Watchtower's HTTP API. The Update Manager now detects Docker installs,
shows Watchtower connection status, and provides a one-click update flow
with progress UI that survives container restarts.

- Add WatchtowerClient service for Watchtower HTTP API communication
- Add Docker update progress page with Stimulus controller for polling
- Add health endpoint for post-restart detection (unauthenticated)
- Show Docker-specific UI (hide Git-only fields, show Watchtower status)
- Create database backup before triggering Docker updates
- Fix CSP violation in error page (javascript:history.back -> proper link)
- Add translation keys for all Docker update UI strings
Without defaults, Symfony throws EnvNotFoundException when
WatchtowerClient is constructed in non-Docker environments
(including CI test runners).
@codecov
Copy link

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 44.89796% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.39%. Comparing base (4206b70) to head (2626478).

Files with missing lines Patch % Lines
src/Controller/UpdateManagerController.php 0.00% 38 Missing ⚠️
src/Services/System/UpdateExecutor.php 10.00% 9 Missing ⚠️
src/Services/System/UpdateChecker.php 60.00% 4 Missing ⚠️
src/Services/System/InstallationType.php 0.00% 2 Missing ⚠️
src/EventSubscriber/MaintenanceModeSubscriber.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1330      +/-   ##
============================================
- Coverage     56.45%   56.39%   -0.06%     
- Complexity     8323     8351      +28     
============================================
  Files           611      612       +1     
  Lines         26731    26824      +93     
============================================
+ Hits          15091    15128      +37     
- Misses        11640    11696      +56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Covers all public methods with mocked HTTP client:
- isConfigured with various empty/set combinations
- isAvailable with success, error, and exception scenarios
- triggerUpdate with success, failure, and not-configured cases
- URL trailing slash normalization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant