feat: Add support for remote services

- Added base_url field to DeployedComponent for external URL proxying
- Updated Caddyfile generator to proxy to base_url when present instead of requiring local port
- Added runner: remote handling in deploy command (returns empty run_cmd, marks as unmanaged)
- Reformatted long ternary expression in registry.py for readability

This enables castle to manage services that proxy to external endpoints without requiring a local process.
This commit is contained in:
2026-04-27 20:48:25 -07:00
parent a28d40c49e
commit a553525c71
3 changed files with 26 additions and 4 deletions

View File

@@ -122,7 +122,7 @@ def _build_deployed_service(config: CastleConfig, name: str, svc: ServiceSpec) -
env: dict[str, str] = {}
# Data dir convention (for managed services)
managed = True # Services are always managed by default
managed = run.runner != "remote" # Remote services have no local process
if svc.manage and svc.manage.systemd and not svc.manage.systemd.enable:
managed = False
if managed:
@@ -159,6 +159,9 @@ def _build_deployed_service(config: CastleConfig, name: str, svc: ServiceSpec) -
if svc.component and svc.component in config.programs:
stack = config.programs[svc.component].stack
# Remote services proxy to an external base_url
base_url = getattr(run, "base_url", None)
return DeployedComponent(
runner=run.runner,
run_cmd=run_cmd,
@@ -169,6 +172,7 @@ def _build_deployed_service(config: CastleConfig, name: str, svc: ServiceSpec) -
port=port,
health_path=health_path,
proxy_path=proxy_path,
base_url=base_url,
managed=managed,
)
@@ -322,6 +326,8 @@ def _build_run_cmd(run: object, env: dict[str, str]) -> list[str]:
if run.args:
cmd.extend(run.args)
return cmd
case "remote":
return [] # No local process for remote services
case _:
raise ValueError(f"Unsupported runner: {run.runner}")