- Update docs/appctl.md to cover core_manifest.py, Schema v1.0, Class A/B source provenance, and two-axis status output. - Align docs/architecture.md, docs/secrets-and-state.md, and docs/operations.md with P1 mail topology (Stalwart on smtp.<domain>, SnappyMail in ~/Sites, workload state under ~/var/lib/homelab/<app>/). - Remove external vault path references from docs/decisions/README.md and scrub remaining personal domains/usernames across docs/ and SECURITY.md. - Extend platform genericism security invariant test to guard docs/ and root markdown/flake files.
14 KiB
📦 Workload Orchestration & app.yaml Reference (appctl)
The appctl tool is the command-line orchestrator and metadata engine for the Homelab Core platform. It coordinates interactions between independent workload repositories in ~/Sites and platform services in ~/Core.
Note
Implementation Reference: This document serves as the current implementation manual (Milestone P3) for the
appctlBash CLI wrapper (scripts/appctl), metadata/provenance engine (scripts/appctl_engine.py), and Pydantic v2 manifest parser (scripts/core_manifest.py). For the platform's planned Milestone P4 control-plane daemon transition and phased engineering roadmap, seeROADMAP.mdand the Architecture Decision Index.
1. How appctl Works
appctl consists of three cooperating modules in scripts/:
scripts/appctl(Bash CLI wrapper): Parses CLI arguments, sources runtime secret templates, injects validated workload environment variables, dispatchesdocker composecommands, and provides shell autocompletions.scripts/appctl_engine.py(Discovery, Provenance & TLS Engine): Scans~/Sites/*, evaluates two-axis status (local deployment checkout state vs. upstream software provenance), inspects live container health and TLS certificates, and compiles the Homepage dashboard configuration.scripts/core_manifest.py(Schema v1.0 Parser & Validator): Enforces fail-closed Pydantic v2 validation (ConfigDict(extra="forbid")) onapp.yamlmanifests, validates upstream Git transport schemes (https://,ssh://,git@), classifies reference mutability (branch, tag, commit SHA), and blocks reserved host environment keys (PATH,LD_PRELOAD,IFS,CORE_DIR,SITES_DIR, etc.).
┌───────────────────────────────┐
│ appctl <command> │
└───────────────┬───────────────┘
│
▼
┌───────────────────────────┐
│ setup_app_env() │
└─────────────┬─────────────┘
│
┌──────────────────────────┴──────────────────────────┐
▼ ▼
[ appctl_engine.py resolve ] [ Source Secrets ]
• Parses app.yaml via core_manifest.py /run/secrets/traefik-deployments.env
• Fails closed on manifest_error /run/secrets/homeserver.env
│ │
└──────────────────────────┬──────────────────────────┘
▼
┌─────────────────────────────┐
│ Injected Compose Context │
│ • PROXY_NETWORK │
│ • SERVICE_DOMAIN / DOMAIN │
│ • CONTAINER_NAME │
│ • Validated manifest env │
└──────────────┬──────────────┘
▼
┌─────────────────────────────┐
│ docker compose <subcommand> │
└─────────────────────────────┘
2. CLI Command Reference
Status & Inspection
appctl list / appctl status
Lists applications discovered in ~/Sites using two-axis inspection:
DEPLOYMENT(Axis 1 — Local Checkout): Inspects the local~/Sites/<app>Git working tree (✓ Synced,* Dirty,⬇ Behind,⚠️ Non-Git).PROVENANCE(Axis 2 — Upstream Software): Evaluates upstream software provenance for Class A (Source-Backed) vs. Class B (— Image-Only) workloads.
Options:
--fetch(-f): Queries upstream Git remotes (git ls-remotewith a 10s timeout) and fetches local deployment tracking branches before computing provenance badges.--core(-c/--all/-a): Appends Core infrastructure services (traefik,authelia,lldap,stalwart,homepage,dozzle,watchtower) to the output.--ssl(-s): Queries SSL/TLS certificates over port 443 for each public domain and appends aCERTcolumn.
Example Output:
SERVICE DEPLOYMENT PROVENANCE STATUS DOMAIN
------- ---------- ---------- ------ ------
docs ✓ Synced (main) ✓ Synced 🟢 Running (1) docs.example.com
jellyfin ✓ Synced (main) — Image-Only 🟢 Running (1) jellyfin.example.com
gitea ✓ Synced (main) ⬆ Update Available 🟢 Running (2) gitea.example.com
mongodb * Dirty (1) (main) — Image-Only 🔴 Stopped mongodb.example.com
appctl ssl [service]
Inspects SSL/TLS certificates over port 443. If a service is specified, shows detailed issuer, subject, and expiration data; otherwise, inspects all non-internal homelab domains.
# Check all domains
appctl ssl
# Check a specific service
appctl ssl jellyfin
appctl info <service> [--ssl]
Displays comprehensive two-axis diagnostics for a workload or Core service:
- Canonical name, directory path, aliases, and workload class (
Class A (Source-Backed)vs.Class B (Image-Only)). - Primary routed domain, networks, and Authelia guard status.
- Axis 1 (Local Deployment Checkout): Branch, commit hash, dirty file count, and sync status.
- Axis 2 (Upstream Software Provenance): Upstream Git URL, tracked ref (
branch,tag, orcommit), resolved remote commit, and running container OCI revision label. - Injected environment variable defaults and Homepage card metadata.
- SSL certificate details (when
--sslis passed).
appctl info docs --ssl
Lifecycle Management
appctl up <service|core>
Starts the specified service stack in detached mode (--remove-orphans).
- For a workload in
~/Sites: starts containers and triggersappctl sync. - For
core: starts the entire Core Compose stack using/run/secrets/homeserver.env. - For an individual Core service (e.g.,
appctl up traefik): starts that specific container.
appctl down <service|core>
Stops and removes containers defined in the target's Compose file (or stops the targeted Core container).
appctl restart <service|core>
Restarts the target stack or individual container:
appctl restart docs: Recreates thedocsworkload stack and syncs Homepage.appctl restart core: Restarts all Core Compose services.appctl restart traefik: Restarts only the Traefik container.
appctl update <service|core>
Performs a sequential update workflow:
- Verifies that the local Git working tree is clean (aborts if uncommitted changes exist).
- Runs
git pull --ff-onlyto fast-forward the current branch. - Runs
docker compose pullto fetch updated container images. - Runs
docker compose up -d --remove-orphansto recreate containers. - Runs
appctl syncto update the Homepage dashboard.
appctl pull <service|core>
Pulls latest container images and recreates the target service.
appctl logs <service|core>
Streams container logs (docker compose logs -f). Supports passing specific container names (appctl logs core traefik or appctl logs stalwart).
appctl config <service|core>
Validates the manifest and renders the resolved Docker Compose configuration with all injected variables. Fails closed if app.yaml is missing or invalid.
appctl sync
Scans all valid ~/Sites/*/app.yaml manifests and compiles config/homepage/services.yaml.
appctl completion [bash]
Outputs the bash autocompletion script.
3. app.yaml Schema v1.0 Contract
Workload manifests in ~/Sites/<app>/app.yaml are validated by scripts/core_manifest.py using strict Pydantic v2 models (extra="forbid"). Any unknown field, invalid transport URL, or prohibited deployment action causes validation to fail closed.
schema_version: "1.0" # Schema version (only "1.0" is supported)
# ── Identity & Routing ────────────────────────────────────────────────────────
name: "jellyfin" # Canonical name: ^[a-zA-Z0-9][a-zA-Z0-9._-]*$
aliases: # Optional CLI aliases
- "media"
- "movies"
domain: "jellyfin.example.com" # Primary routed domain (defaults to <name>.${HOMELAB_DOMAIN})
description: "Media Streaming Server"
# ── Platform Integration ──────────────────────────────────────────────────────
visible: true # Display on Homepage dashboard (default: true)
auth: false # Authelia ForwardAuth protection (default: false)
networks: # Docker networks to join (default: [proxy-net])
- proxy-net
# ── Upstream Software Provenance (Optional: Defines Class A vs. Class B) ─────
# Omit 'source' for Class B (Image-Only third-party workloads).
# Include 'source' for Class A (Source-Backed workloads):
source:
url: "https://github.com/example/jellyfin-app.git" # Strictly https://, ssh://, or git@host:path
ref: "main" # Branch, v* tag, or 40-char commit SHA
# ── Injected Environment Defaults ─────────────────────────────────────────────
# Keys must match ^[a-zA-Z_][a-zA-Z0-9_]*$ and cannot override reserved host keys
# (PATH, LD_PRELOAD, IFS, SHELL, USER, HOME, CORE_DIR, SITES_DIR, etc.)
env:
MEDIA_PATH: "/media"
JELLYFIN_TZ: "UTC"
# ── GitOps Deployment Policy ──────────────────────────────────────────────────
# Evaluated by scripts/gitops_dispatcher.py upon webhook admission
deployment:
branch: "main" # Target branch that triggers deployment
strategy: "compose" # Only 'compose' strategy is permitted
actions: # Strictly allowlisted: git_pull, compose_pull,
- git_pull # compose_up, compose_build, compose_restart
- compose_up
# ── Homepage Dashboard Metadata ───────────────────────────────────────────────
homepage:
title: "Jellyfin" # Card title
group: "Media & Productivity" # Dashboard group name
icon: "jellyfin.png" # Icon name (matched against config/homepage/icons/)
container: "jellyfin" # Container name for live status widget
weight: 10 # Card sort weight (lower sorts first)
4. Environment Injection & Resolution Precedence
When appctl executes commands against a workload, environment variables are resolved in this sequence:
- Global Secrets & Templates: Sourced from
/run/secrets/rendered/homeserver.envand/run/secrets/rendered/traefik-deployments.env(with/run/secrets/*fallbacks). - Canonical Root Domain Lock:
HOMELAB_DOMAINis locked at startup using precedenceHOMELAB_DOMAIN -> DOMAIN_SUFFIX -> DOMAINso per-workloadDOMAINexports cannot corrupt the platform apex domain. - Infrastructure Defaults:
PROXY_NETWORK(defaults toproxy-net)CERT_RESOLVER(defaults tomyresolver)DOMAIN_SUFFIX(defaults to$HOMELAB_DOMAIN)
- Application Identity:
SERVICE_NAME=<canonical-name>CONTAINER_NAME=<canonical-name>SERVICE_DOMAIN=<resolved-domain>DOMAIN=<resolved-domain>
- Manifest Variables: Validated key-value pairs from the
env:block inapp.yaml(emitted via null-delimited stream without shelleval). - Local Repository Files: Sourced from
$APP_DIR/.envand$APP_DIR/app.envif present.
5. Homepage Dashboard Compilation
When appctl sync runs:
appctl_engine.pyscans all~/Sites/*/app.yamlmanifests (skipping any workload with amanifest_error).- Core services (
traefik,authelia,lldap,stalwart,homepage,dozzle,watchtower) are assigned toCore Infrastructure. - Workload applications with
visible: trueare grouped by theirhomepage.group(ordered:Core Infrastructure,Knowledge & Notes,Media & Productivity,Development & AI,Applications) and sorted by(weight, title). - Custom icons matching files in
config/homepage/icons/(.svgor.png) are mapped to/icons/<name>. - The compiled configuration is written to
config/homepage/services.yaml.