LibrePortal/scripts/cli/commands/instance/cli_instance_header.sh
librelad 376610cd11 feat(apps): scoped multi-instance support (run two of an app)
Lets a *multi-instance-capable* app run as several fully isolated instances
on one box (e.g. two Bookstack/WordPress sites, or a "family" + "work"
Nextcloud) — distinct data, DB, subdomain, backups and update cadence.

Design: an instance is just another app. It gets its own slug (<type>_<id>),
its own CFG_<SLUG>_* namespace, deployed dir, DB row, IP/port allocation and
host, so the entire existing pipeline (scan, install, services, routing,
updater, backups) treats it like any app with zero changes. All
instance-specific rewriting is confined to a clone of the type's template;
the shipped template and the core engine are untouched.

Gating: opt-in per app via CFG_<TYPE>_MULTI_INSTANCE=true. Only Bookstack
carries it for now (the validated reference). The other 31 apps are
unaffected — the feature is invisible unless the flag is present.

- scripts/instance/instance_create.sh — clone + re-namespace config, rewrite
  compose identity (container_name / Traefik routers / backup labels) and
  per-app tools, set a hostname-safe subdomain (PORT field 10), then hand off
  to dockerInstallApp. Plus instanceList / instanceRemove.
- libreportal instance create|remove|list — new CLI category; mutations route
  through the task system (no new mutating API endpoint).
- WebUI: "instance of <type>" badge + a "New instance" card action on capable
  apps, and a create modal (name + domain# + subdomain, live host preview)
  that dispatches the standard task. Capability/instance-of read straight off
  the already-exposed app config.

Known follow-ups (documented): flip the flag on more apps after a compose
identity check (Nextcloud next); per-app tools are best-effort isolated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-06-04 23:34:52 +01:00

26 lines
1.3 KiB
Bash

#!/bin/bash
# Instance Commands Header
# Shows available instance commands and help information
cliShowInstanceHelp()
{
echo ""
echo "Available Instance Commands (* is required):"
echo ""
echo " Run more than one copy of a multi-instance-capable app (e.g. two"
echo " Bookstack/WordPress sites). Each instance is a full, isolated app:"
echo " its own data, DB, subdomain, backups and update cadence. Only apps"
echo " with CFG_<TYPE>_MULTI_INSTANCE=true can be instanced."
echo ""
echo " libreportal instance create [type*] [name*] [domain#] [subdomain]"
echo " - Provision + install a new instance."
echo " type = base app slug (e.g. bookstack)"
echo " name - instance name (e.g. blog)"
echo " domain# - which CFG_DOMAIN_n to route on (default 1)"
echo " subdomain- host label (default <type>-<name>)"
echo " libreportal instance remove [slug*] - Uninstall + remove an instance (e.g. bookstack_blog)"
echo " libreportal instance list [type] - List instances (all, or just for one app type)"
echo ""
}