- Promote scripts/appctl_engine_v2.py to authoritative scripts/appctl_engine.py - Add full two-axis inspection, Homepage synchronization, and schema v1.0 support - Convert scripts/appctl_engine_v2.py into a backward-compatibility shim - Rename tests/unit/test_appctl_engine_v2.py to test_appctl_engine.py and remove xfail marker - Update README.md, docs/appctl.md, and docs/architecture.md to reference appctl_engine - Synchronize todo.txt and mark Milestone P3 as completed in ROADMAP.md
11 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 for the
appctlBash CLI wrapper (scripts/appctl), metadata engine (scripts/appctl_engine.py), and currently consumedapp.yamlmanifest fields. For the platform's overarching control-plane architecture, 5-stage deployment model lifecycle, and phased engineering roadmap, seeREADME.md,ROADMAP.md, and the Architecture Decision Index.
1. How appctl Works
appctl consists of two cooperating scripts:
scripts/appctl(Bash CLI wrapper): Handles command-line arguments, sources secret environment templates, dispatchesdocker composecommands, and provides shell autocompletions.scripts/appctl_engine.py(Python metadata engine): Scans directories in~/Sites, parsesapp.yamlmanifests, computes Git synchronization status against remotes, queries SSL/TLS certificate validity, and compiles the Homepage dashboard configuration.
┌───────────────────────────────┐
│ appctl <command> │
└───────────────┬───────────────┘
│
▼
┌───────────────────────────┐
│ setup_app_env() │
└─────────────┬─────────────┘
│
┌──────────────────────────┴──────────────────────────┐
▼ ▼
[ appctl_engine.py resolve ] [ Source Secrets ]
Resolves aliases, domain, /run/secrets/traefik-deployments.env
and manifest parameters /run/secrets/homeserver.env
│ │
└──────────────────────────┬──────────────────────────┘
▼
┌─────────────────────────────┐
│ Injected Compose Context │
│ • PROXY_NETWORK │
│ • SERVICE_DOMAIN / DOMAIN │
│ • CONTAINER_NAME │
│ • Custom manifest env │
└──────────────┬──────────────┘
▼
┌─────────────────────────────┐
│ docker compose <subcommand> │
└─────────────────────────────┘
2. CLI Command Reference
Status & Inspection
appctl list / appctl status
Lists applications discovered in ~/Sites with container status, Git synchronization badge, routed domain, and filesystem path.
Options:
--fetch(-f): Runsgit fetch --quietacross repositories before computing sync badges.--core(-c): Includes Core infrastructure services (traefik,authelia,lldap,stalwart, etc.) in the output.--ssl(-s): Queries SSL/TLS certificates for each domain and displays status and expiration days.--all(-a): Equivalent to--core.
Example Output:
SERVICE STATUS GIT SYNC DOMAIN DIRECTORY
------- ------ -------- ------ ---------
docs 🟢 Running (1) ✓ Synced docs.roadtotech.me ~/Sites/homelab-docs
jellyfin 🟢 Running (1) ✓ Synced jellyfin.roadtotech.me ~/Sites/homelab-jellyfin
gitea 🟢 Running (2) ⬇ 1 Behind gitea.roadtotech.me ~/Sites/homelab-gitea
mongodb 🔴 Stopped ✓ Synced * mongodb.roadtotech.me ~/Sites/homelab-mongodb
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 homelab domains.
# Check all domains
appctl ssl
# Check a specific service
appctl ssl jellyfin
appctl info <service>
Displays diagnostic information for a workload or Core service:
- Canonical name, directory, and aliases.
- Docker container running status.
- Primary routed domain and Authelia guard status.
- Git tracking details: branch, upstream remote, uncommitted file count.
- Injected environment variable defaults.
- Homepage card configuration.
- 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 callsappctl 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.
appctl restart <service|core>
Restarts the target stack or individual container.
appctl restart docs: Restarts the docs workload.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:
- Checks 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 container names:
appctl logs core traefikorappctl logs stalwart.
appctl config <service|core>
Renders the resolved Docker Compose configuration with all injected variables.
appctl sync
Scans all ~/Sites/*/app.yaml manifests and re-generates config/homepage/services.yaml.
appctl completion [bash]
Outputs the bash autocompletion script.
3. app.yaml Fields Consumed by appctl and GitOps
app.yaml files in ~/Sites are read by appctl_engine.py and gitops_dispatcher.py for the following fields:
# ── Identity & Routing ────────────────────────────────────────────────────────
name: "jellyfin" # Canonical service name (defaults to folder name minus homelab-)
aliases: # Alternate CLI aliases
- "media"
- "movies"
domain: "jellyfin.roadtotech.me" # Primary routed domain (defaults to <name>.roadtotech.me)
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
# ── Injected Environment Defaults ─────────────────────────────────────────────
# Injected into the Compose environment when appctl commands run
env:
MEDIA_PATH: "/media"
JELLYFIN_TZ: "UTC"
JELLYFIN_PUID: "1000"
JELLYFIN_PGID: "1000"
# ── GitOps Deployment Policy ──────────────────────────────────────────────────
# Evaluated by scripts/gitops_dispatcher.py upon webhook reception
deployment:
branch: "main" # Target branch that triggers deployment
strategy: "compose" # Deployment strategy (only 'compose' is permitted)
actions: # Strictly allowlisted actions
- git_pull
- compose_up
# ── Homepage Dashboard Metadata ───────────────────────────────────────────────
homepage:
title: "Jellyfin" # Card title
group: "Media & Productivity" # 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
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/homeserver.envand/run/secrets/traefik-deployments.env(or/run/secrets/rendered/*fallbacks). - Infrastructure Defaults:
PROXY_NETWORK(defaults toproxy-net)CERT_RESOLVER(defaults tomyresolver)DOMAIN_SUFFIX(defaults toroadtotech.me)
- Application Identity:
SERVICE_NAME=<canonical-name>CONTAINER_NAME=<canonical-name>SERVICE_DOMAIN=<resolved-domain>DOMAIN=<resolved-domain>
- Manifest Variables: Declared under the
env:block inapp.yaml. - Local Repository Files: Sourced from
$APP_DIR/.envand$APP_DIR/app.envif present.
5. Homepage Dashboard Compilation
When appctl sync runs:
appctl_engine.pyreads all~/Sites/*/app.yamlfiles.- Core services (
traefik,authelia,lldap,stalwart,snappymail,dozzle) are assigned toCore Infrastructure. - Workload applications with
visible: trueare grouped by theirhomepage.group(ordered:Core Infrastructure,Knowledge & Notes,Media & Productivity,Development & AI,Applications). - Custom icons matching files in
config/homepage/icons/(SVG or PNG) are mapped to/icons/<name>. - The compiled configuration is written to
config/homepage/services.yaml.