ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(linked-panel): accept compose file path in project_path from remote runner
Juan Denisb0ccd2f5b54f
diff --git a/backend/app/services/linked_panel_agent.py b/backend/app/services/linked_panel_agent.pyindex d1e5481d..4347a3d2 100644--- a/backend/app/services/linked_panel_agent.py+++ b/backend/app/services/linked_panel_agent.py@@ -261,15 +261,31 @@ def handle_file_write(params):return {'path': real, 'size': len(content)}-def handle_compose_up(params):- from app.services.docker_service import DockerService+def _resolve_compose_target(params):+ """Normalize the compose target the master sends.++ The deployment runner forwards the plan's ``compose_file`` (the YAML+ file path) in the ``project_path`` field, while DockerService wants a+ project DIRECTORY plus an optional compose_file. Accept both shapes.+ """project_path = params.get('project_path')if not project_path:- raise RuntimeError('docker:compose:up requires project_path')+ raise RuntimeError('docker compose command requires project_path')+ compose_file = None+ if os.path.isfile(project_path):+ compose_file = os.path.basename(project_path)+ project_path = os.path.dirname(project_path)+ return project_path, compose_file+++def handle_compose_up(params):+ from app.services.docker_service import DockerService+ project_path, compose_file = _resolve_compose_target(params)result = DockerService.compose_up(project_path,detach=bool(params.get('detach', True)),build=bool(params.get('build', False)),+ compose_file=compose_file,)if not result.get('success'):raise RuntimeError(result.get('error') or 'docker compose up failed')@@ -278,21 +294,18 @@ def handle_compose_up(params):def handle_compose_ps(params):from app.services.docker_service import DockerService- project_path = params.get('project_path')- if not project_path:- raise RuntimeError('docker:compose:ps requires project_path')- return DockerService.compose_ps(project_path)+ project_path, compose_file = _resolve_compose_target(params)+ return DockerService.compose_ps(project_path, compose_file=compose_file)def handle_compose_logs(params):from app.services.docker_service import DockerService- project_path = params.get('project_path')- if not project_path:- raise RuntimeError('docker:compose:logs requires project_path')+ project_path, compose_file = _resolve_compose_target(params)result = DockerService.compose_logs(project_path,service=params.get('service') or None,tail=int(params.get('tail', 100)),+ compose_file=compose_file,)if not result.get('success'):raise RuntimeError(result.get('error') or 'docker compose logs failed')diff --git a/backend/tests/test_linked_panel.py b/backend/tests/test_linked_panel.pyindex 51e384c0..15702dbf 100644--- a/backend/tests/test_linked_panel.py+++ b/backend/tests/test_linked_panel.py@@ -195,8 +195,9 @@ def test_compose_up_maps_params_and_raises_on_failure(monkeypatch):class FakeDocker:@staticmethod- def compose_up(project_path, detach=True, build=False):- seen.update(path=project_path, detach=detach, build=build)+ def compose_up(project_path, detach=True, build=False, compose_file=None):+ seen.update(path=project_path, detach=detach, build=build,+ compose_file=compose_file)return {'success': True, 'output': 'ok'}monkeypatch.setattr(@@ -204,11 +205,12 @@ def test_compose_up_maps_params_and_raises_on_failure(monkeypatch):data = agent.handle_compose_up({'project_path': '/var/serverkit/apps/x', 'detach': True, 'build': True})assert data['success'] is True- assert seen == {'path': '/var/serverkit/apps/x', 'detach': True, 'build': True}+ assert seen == {'path': '/var/serverkit/apps/x', 'detach': True,+ 'build': True, 'compose_file': None}class FailingDocker(FakeDocker):@staticmethod- def compose_up(project_path, detach=True, build=False):+ def compose_up(project_path, detach=True, build=False, compose_file=None):return {'success': False, 'error': 'build exploded'}monkeypatch.setattr(@@ -217,6 +219,26 @@ def test_compose_up_maps_params_and_raises_on_failure(monkeypatch):agent.handle_compose_up({'project_path': '/x'})+def test_compose_target_accepts_compose_file_path(tmp_path, monkeypatch):+ """The deployment runner sends the compose FILE in project_path — the+ handler must split it into (dir, compose_file) for DockerService."""+ compose = tmp_path / 'docker-compose.yml'+ compose.write_text('services: {}')+ seen = {}++ class FakeDocker:+ @staticmethod+ def compose_up(project_path, detach=True, build=False, compose_file=None):+ seen.update(path=project_path, compose_file=compose_file)+ return {'success': True}++ monkeypatch.setattr(+ 'app.services.docker_service.DockerService', FakeDocker)+ agent.handle_compose_up({'project_path': str(compose)})+ assert seen['path'] == str(tmp_path)+ assert seen['compose_file'] == 'docker-compose.yml'++def test_unknown_action_reported_via_dispatch(monkeypatch):posted = {}monkeypatch.setattr(agent.requests, 'post',