refactor: Extract deploy logic to castle-core and add deploy API endpoint

- Extract all deploy logic from CLI into castle-core/deploy.py as a reusable deploy() function
  * Resolves services/jobs to DeployedComponents
  * Generates systemd units and Caddyfile
  * Copies frontend assets and reloads systemd
  * Returns DeployResult with deployed count and messages
- Simplify CLI deploy command to a thin wrapper calling castle_core.deploy()
- Add POST /deploy endpoint to castle-api for remote deployment management
  * Supports optional {name} body param to deploy one or all services
  * Returns deployment result as JSON
- Register deploy router in castle-api main.py
- Update README with new deploy endpoint documentation

This enables full remote management: build, test, lint, and deploy any castle
node over HTTP (e.g. POST http://node:9000/api/deploy)
This commit is contained in:
2026-04-27 22:01:39 -07:00
parent e1a9386177
commit 691216b04e
7 changed files with 539 additions and 387 deletions

76
castle.code-workspace Normal file
View File

@@ -0,0 +1,76 @@
{
"folders": [
{
"name": "root",
"path": "."
},
{
"name": "core",
"path": "core"
},
{
"name": "cli",
"path": "cli"
},
{
"name": "castle-api",
"path": "castle-api"
},
{
"name": "app (frontend)",
"path": "app"
},
{
"name": "docs",
"path": "docs"
}
],
"settings": {
"python.defaultInterpreterPath": "${workspaceFolder:root}/.venv/bin/python",
"python.analysis.typeCheckingMode": "standard",
"python.analysis.extraPaths": [
"${workspaceFolder:core}/src",
"${workspaceFolder:cli}/src",
"${workspaceFolder:castle-api}/src"
],
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit"
}
},
"ruff.configurationPreference": "filesystemFirst",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/.ruff_cache": true,
"**/node_modules": true,
"**/*.egg-info": true
},
"search.exclude": {
"**/.venv": true,
"**/node_modules": true,
"**/uv.lock": true,
"**/pnpm-lock.yaml": true,
"**/dist": true
}
},
"extensions": {
"recommendations": [
"ms-python.python",
"charliermarsh.ruff",
"ms-python.vscode-pylance",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
}