Apps are a coreapp.toml; a trusted installer makes the Core side
An app's repository now has only coreapp.toml, its Dockerfile, its code and an icon: no install scripts or compose file, so installing an app from someone else's repository can't run their code as root on a Core. core/coreapps runs on the Core (coreapp deploy puts it in /opt/coreapps). It checks the manifest, refuses Federated's app names and the Core's hostnames, picks a free address on that Core, writes the generic app format from its own templates, sets up the needs (postgres, sso) and installs through installapp. Updates keep the address, secrets and data, add settings for new needs and delete old images; dropping a need is refused. remove rebuilds Superpanel's catalog afterwards. PLAN.md: the Coreapps direction and steps, and what the Core offers apps (Superpanel's AI features, mcpserver, hermes, email, PowerDNS). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -109,94 +109,182 @@ What we learned provisioning (2026-12-02/03):
|
||||
- superpanel's catalog lists `services/*/service`, so an app installed this
|
||||
way shows up in the Core's dashboard.
|
||||
|
||||
### Design (proposed)
|
||||
### Design
|
||||
|
||||
An app is a folder in the generic format, kept anywhere on the workstation
|
||||
(its own git repo). A `coreapp` command, run inside that folder, works
|
||||
against the Core in the local VM (`coreapp-vm ip`):
|
||||
An app is a folder (its own git repo) on the workstation; `coreapp`, run
|
||||
inside it, works against the Core in the local VM (`coreapp-vm ip`): `new`,
|
||||
`deploy` (build, `docker save | ssh docker load`, install or update),
|
||||
`check`, `status`, `logs`, `shell`, `list`, `remove`. Since 2026-12-03 the
|
||||
folder has only `coreapp.toml`, the Dockerfile, the code and an icon; the
|
||||
Core side is made by the installer (see Coreapps below).
|
||||
|
||||
- `coreapp new <name>`: scaffold the folder: `service`,
|
||||
`docker-compose.yml.in` with the traefik labels, `env.in`, `install`, a
|
||||
placeholder `icon.png`, a `Dockerfile` with a minimal web server, and a
|
||||
README. Its `INTERNAL_IP` comes from 192.168.200.0/24, well away from
|
||||
Federated's 192.168.0.x, and different for each app made on this machine.
|
||||
- `coreapp deploy`: build the image locally (`docker build`), copy it to the
|
||||
Core (`docker save | ssh docker load`, no registry needed), copy the folder
|
||||
to `/federated/services/<name>/`, then `installapp -n <name>` the first
|
||||
time. Later deploys re-render `docker-compose.yml` but keep `.env` (its
|
||||
random secrets), and restart the app.
|
||||
- `coreapp status`, `coreapp logs [-f]`, `coreapp shell`: on the Core.
|
||||
- `coreapp check`: the app answers at `https://<name>.<domain>/` as its
|
||||
`MONITOR` line says, with a valid certificate.
|
||||
- `coreapp remove`: `uninstallapp <name>` and remove its services folder.
|
||||
|
||||
Built and tested 2026-12-03 with a test app `hello` (busybox httpd):
|
||||
new, deploy (first install and redeploy), check, status, logs, remove all
|
||||
work against dev.fedcom.net; `https://hello.dev.fedcom.net/` answers through
|
||||
the relay.
|
||||
Built 2026-12-03 and tested against dev.fedcom.net: plain apps, a
|
||||
database (`--postgres`), sign-in (`--sso`), both. David signed in to
|
||||
sso-demo and team-visits in a browser.
|
||||
|
||||
What we learned:
|
||||
- `/federated/bin/start <app>` only starts apps in the fixed `CORE_APPS` /
|
||||
`EXTRA_APPS` lists in `lib/functions.sh`; for anything else it prints its
|
||||
usage. So `installapp` installs a new app but doesn't start it, and
|
||||
`start all` skips it. `coreapp deploy` starts it with the same
|
||||
`docker compose ... up -d`; `restart: always` covers reboots
|
||||
`start all` skips it. The installer starts it with the same
|
||||
`docker compose ... up -d`; `restart: always` covers reboots. `bin/stop`
|
||||
doesn't know them either, so when a dependency (postgresql, authelia) is
|
||||
upgraded, coreapps' apps keep running; they reconnect
|
||||
- `installapp` / `uninstallapp` call `update_monitors`, which registers or
|
||||
removes the app's `MONITOR` URL with Federated's external monitoring
|
||||
(blackboxregistrar.monitoreast.fedcom.net). Dev apps get registered too
|
||||
- `uninstallapp` runs with `set -x`; its trace includes the monitoring
|
||||
registrar's bearer token (in plain text in `lib/functions.sh`) and the
|
||||
Core's email addresses. coreapp keeps the trace in
|
||||
`~/.local/share/coreapp-dev/logs/` (mode 600)
|
||||
- `uninstallapp` only stops a generic app if the app has an `uninstall`
|
||||
script (sourced, so no `exit`); the template has one
|
||||
(blackboxregistrar.monitoreast.fedcom.net). Decided 2026-12-03: apps in
|
||||
development aren't registered, so the installer writes no `MONITOR`
|
||||
- `installapp` and `uninstallapp` run with `set -x`; the trace includes the
|
||||
monitoring registrar's bearer token (in plain text in `lib/functions.sh`),
|
||||
the Core's email addresses and the app's secrets. The installer keeps
|
||||
their output in `/federated/logs/coreapps/` (mode 600)
|
||||
- `uninstallapp` only stops a generic app if it has an `uninstall` script
|
||||
(sourced, so no `exit`)
|
||||
- `uninstallapp` makes Superpanel's catalog before the services folder is
|
||||
deleted, so the installer makes it again afterwards
|
||||
- Databases: the app's own user and database (`coreapp_<name>`, because
|
||||
PostgreSQL reserves `pg_*` and Federated's apps have their own names) on
|
||||
the Core's PostgreSQL, made with `docker exec postgresql psql -U postgres`
|
||||
as Federated's installers do. `postgresql.<domain>` resolves to the
|
||||
container on the `core` network (Docker's DNS); outside it, it's the
|
||||
public IP
|
||||
- Sign-in: the OIDC client `coreapp-<name>` goes in Authelia's
|
||||
`idproviders.yml` between `### coreapp-<name> begin/end` markers (secret
|
||||
hashed with the running Authelia's `authelia crypto hash generate
|
||||
pbkdf2`), checked with `authelia validate-config` before Authelia
|
||||
restarts (the old file is put back if the check fails). `installapp`'s
|
||||
`apply_authelia_2fa_policy` applies the Core's 2FA policy to it. The app
|
||||
reaches `https://authelia.<domain>` through traefik (`extra_hosts` to
|
||||
traefik's address; Federated's apps use the public IP, which here would
|
||||
loop out through the relay)
|
||||
- Image names must include the registry: `coreapp/x` means Docker Hub, so a
|
||||
Core that had to pull it (after its boot-time prune, say) would get
|
||||
whatever is published there. Dev images are `localhost/coreapp/<name>`,
|
||||
which can't be pulled
|
||||
|
||||
- Decided 2026-12-03: apps in development are not registered with
|
||||
Federated's monitoring. `coreapp deploy` drops `MONITOR` from the copy of
|
||||
`service` on the Core
|
||||
- [ ] Document the app format fully in the README (done in each app's README)
|
||||
Databases (2026-12-03): `coreapp new --postgres <name>` adds
|
||||
`DEPENDS="postgresql"`, DB_* settings in `env.in` (random password), an
|
||||
`install` that creates the user and database on the Core's PostgreSQL
|
||||
(`docker exec postgresql psql -U postgres`, as Federated's own installers
|
||||
do) and an `uninstall` that drops them, and a Python example (psycopg)
|
||||
that counts visits. Tested with `guest-book`: deploy, the count goes up,
|
||||
a redeploy and a reboot of the Core keep the data, remove drops the database
|
||||
and user. `postgresql.<domain>` resolves to the PostgreSQL container on the
|
||||
`core` network (Docker's DNS); outside it, it's the public IP.
|
||||
### How Federated adds an app to every Core
|
||||
|
||||
Sign-in (2026-12-03): `coreapp new --sso <name>`. Its `install` registers
|
||||
the OIDC client `coreapp-<name>` in Authelia's `idproviders.yml` between
|
||||
`### coreapp-<name> begin/end` markers (secret from `.env`, hashed with the
|
||||
running Authelia's `authelia crypto hash generate pbkdf2`), checks the
|
||||
result with `authelia validate-config`, restores the old file if that fails,
|
||||
and restarts Authelia; `uninstall` removes the block. `installapp`'s
|
||||
`apply_authelia_2fa_policy` then applies the Core's 2FA policy to it.
|
||||
The app reaches `https://authelia.<domain>` through traefik
|
||||
(`extra_hosts` to `@TRAEFIK_IP@`, which the template's `install` and
|
||||
coreapp's redeploy both provide; Federated's apps use the public IP, which
|
||||
here would loop out through the relay). The example is a standard-library
|
||||
Python OIDC client (code flow with PKCE).
|
||||
Tested with `sso-demo`: install, redeploy, remove and reinstall each leave
|
||||
one (or no) client block, a valid config, and the other clients and
|
||||
Nextcloud working; `/login` redirects to Authelia with PKCE.
|
||||
From the Core repo's history, e.g. immich:
|
||||
- The Core repo (`gitea.federated.computer/Federated_Computer/Core`) gets
|
||||
`services/<app>/` in the generic format, with `CONTAINER` a public image
|
||||
(most are on Docker Hub; Federated's own under `federatedcomputer/`) and
|
||||
an `INTERNAL_IP` in 192.168.0.x not used by another app
|
||||
- `lib/functions.sh`: the app goes into `EXTRA_APPS`, or `bin/start` and
|
||||
`start all` won't start it
|
||||
- `services/superpanel/tiers.json`: the tiers (good, better, best) that
|
||||
include it
|
||||
- Work happens on branches with pull requests into `master`; Cores run the
|
||||
`release` branch, which `upgrade` pulls nightly
|
||||
|
||||
A real sign-in to sso-demo with a Core account in a browser worked
|
||||
(2026-12-03, tested by David).
|
||||
- `bin/stop` and `bin/start` don't know apps outside Federated's lists, so
|
||||
when a dependency (postgresql, authelia) is upgraded, coreapp apps keep
|
||||
running instead of being stopped and restarted; they reconnect
|
||||
Both together (2026-12-03): overlays no longer replace `service`; each
|
||||
names the Core apps it needs in `.depends`, merged into `DEPENDS`. The
|
||||
sign-in code is a module (`oidc.py`) any example imports;
|
||||
`templates/postgres-sso` is the combined example (sign-in, each person's
|
||||
visits in PostgreSQL). Tested with `team-visits`: database, Authelia client
|
||||
`coreapp-team-visits`, `DEPENDS="postgresql authelia"`, `/login` to Authelia.
|
||||
## Coreapps: apps from the developer's own repository
|
||||
|
||||
Signing in to team-visits and sso-demo (with the oidc.py code) in a browser
|
||||
worked (2026-12-03, tested by David).
|
||||
- [ ] Later: apps published for other Cores (registry, submitting to
|
||||
Federated)
|
||||
Decided 2026-12-03 (David): a developer publishes an app to their own Gitea
|
||||
repository. A Core's owner installs it in Superpanel, in a new Coreapps
|
||||
screen (Superpanel doesn't have one yet), by giving the repository's URL.
|
||||
A Claude Code skill helps developers make apps that use the Core's
|
||||
services: Traefik, Authelia, PowerDNS (`<app>.<domain>`), email and the AI
|
||||
features.
|
||||
|
||||
Rules that follow from it:
|
||||
- An app from any URL must not run code as root on the Core. So the app's
|
||||
repository has no `install` scripts or compose file: only `coreapp.toml`,
|
||||
an image and an icon. The installer (`core/coreapps`, trusted, written by
|
||||
us or Federated) checks the manifest and makes everything else from its
|
||||
own templates. Values from the manifest go into shell-sourced and YAML
|
||||
files, so each is limited to safe characters
|
||||
- Images are built outside the Core (CI in the developer's Gitea, pushed to
|
||||
its container registry); the Core only pulls `image:version`
|
||||
- Each Core picks the app's address itself (192.168.200.10-250, free on
|
||||
that Core)
|
||||
- Apps live in `/federated/services/<name>/` with a `.coreapp` marker, so
|
||||
Superpanel's catalog and the Core's `installapp`/`uninstallapp` see them.
|
||||
That folder is Federated's git checkout; untracked folders survive
|
||||
`git pull`, but a `git clean` would delete them. Ask Federated
|
||||
|
||||
Steps:
|
||||
1. Done 2026-12-03: `coreapp.toml` and the installer. `coreapp deploy`
|
||||
puts the installer in `/opt/coreapps` on the Core and runs
|
||||
`coreapps install`. Tested on dev.fedcom.net: new apps with no needs,
|
||||
postgres, and postgres + sso (`trial-app`); updates (a new version,
|
||||
adding a need, the three apps deployed before coreapp.toml); refusals
|
||||
(Federated's app names, the Core's hostnames, dropping a need, bad
|
||||
manifest values); remove (database, Authelia client, image and catalog
|
||||
entry gone)
|
||||
- [ ] David: sign in to `https://trial-app.dev.fedcom.net/` in a browser
|
||||
2. [ ] Publishing: a Gitea Actions workflow in new apps that builds the image
|
||||
on a version tag and pushes it to the repository's Gitea registry; and
|
||||
`coreapp publish` for developers without a runner. Pin the image by
|
||||
digest in what the Core installs? Private registries need a pull token
|
||||
3. [ ] Install from a URL on the Core: `coreapps install <repo-url>[@tag]`
|
||||
(git clone at the tag, read `coreapp.toml` and `icon.png` only, pull the
|
||||
image). Show the source and what the app needs before installing
|
||||
4. [ ] Email and AI needs (findings below), then other services: PowerDNS
|
||||
records beyond the wildcard, if an app needs other hostnames
|
||||
5. [ ] The skill: a Claude Code skill in coreapp-dev (installed by
|
||||
`update.sh`) that teaches `coreapp.toml`, the needs, the `coreapp`
|
||||
commands and testing against the VM
|
||||
6. [ ] The Coreapps screen in Superpanel (Federated's code: needs their
|
||||
agreement). Until then, the installer could run as a small web app behind
|
||||
Authelia, for admins only
|
||||
|
||||
Later:
|
||||
- [ ] Uninstalling a need without removing the app (now refused)
|
||||
- [ ] `bin/start` / `bin/stop` don't know coreapps' apps (see "Tell
|
||||
Federated"); `restart: always` covers reboots
|
||||
- [ ] Trust: a list of reviewed apps, or signed releases, and a warning in
|
||||
Superpanel for others
|
||||
- [ ] Monitoring for published apps (dev apps aren't registered)
|
||||
|
||||
### What the Core offers apps (studied 2026-12-03)
|
||||
|
||||
Superpanel (`federatedcomputer/superpanel` 26.12.01, a Go binary, at
|
||||
192.168.0.85; its `.env` has LDAP, SMTP, Authelia client and
|
||||
`STORE_DB_URL`). Its AI features:
|
||||
- `/ai/settings` (and `/models`): the LLM provider and model (Anthropic,
|
||||
OpenAI, OpenRouter, custom), stored in Hermes's `.env`
|
||||
(`HERMES_LLM_PROVIDER`, `HERMES_LLM_API_KEY`, `HERMES_LLM_MODEL`). The
|
||||
AI Settings toggle runs `installapp hermes`
|
||||
- `/ai/terminal` (`/stream`): a chat with Hermes, through Hermes's API
|
||||
(`HERMES_API_URL=http://192.168.0.92:8642`, `/v1/chat/completions`,
|
||||
bearer `HERMES_API_KEY`)
|
||||
- `/api/mcp-apps`: which apps the AI can use; `/api/mcp/validate`: the
|
||||
forward-auth check for `mcphub.<domain>`, with per-user tokens in
|
||||
`superpanel/data/mcp_tokens`
|
||||
- On dev.fedcom.net hermes and mcpserver aren't installed
|
||||
|
||||
hermes (`nousresearch/hermes-agent`, 192.168.0.92, no traefik route): the
|
||||
agent. It uses mcpserver-hub (`http://192.168.0.91:8080/sse`) for tools.
|
||||
|
||||
mcpserver (`federatedcomputer/mcpserver` 1.8.8, 192.168.0.90 per-app
|
||||
endpoints at `mcpserver.<domain>` with basic auth; mcpserver-hub at .91,
|
||||
`mcphub.<domain>`, one endpoint for all apps, auth through Superpanel). It
|
||||
only knows a fixed list of apps (`MCPSERVER_APPS` in `lib/mcpserver.sh`,
|
||||
"keep in sync with APPS in the mcpserver image's entrypoint.py"): listmonk,
|
||||
nextcloud, espocrm, baserow, bookstack, n8n, immich, gitea, plane, erpnext,
|
||||
kimai, matomo, wordpress, vaultwarden. An app is linked with
|
||||
`installapp-mcpserver <app>`, which calls `config_mcpserver_<app>` in the
|
||||
app's lib file. So a coreapp can't offer tools to the AI today.
|
||||
|
||||
What an `ai` need could be:
|
||||
- The app offers tools: it serves MCP (streamable HTTP) on a path, and the
|
||||
hub lists it. Needs mcpserver to accept a generic upstream (a URL and a
|
||||
token per app) instead of its fixed list. Ask Federated
|
||||
- The app uses the model: through Hermes's OpenAI-compatible API. But that
|
||||
key is Superpanel's (full agent, all tools); an app would need its own,
|
||||
limited key, or the provider's key, which is the owner's money. Decide
|
||||
with Federated
|
||||
|
||||
Email (docker-mailserver 16.0.1 at 192.168.0.16, accounts in LDAP): Core
|
||||
apps send through `mail.<domain>:587` (STARTTLS) as `fcore` (or `admin`)
|
||||
with the Core's admin password (`MAIL_PASSWORD=$ADMINPASS`, e.g. in
|
||||
`lib/bookstack.sh`; `SMTPUSER` in `get_appvars`). A coreapp must not get
|
||||
the admin password, so an `email` need has to create its own mail account
|
||||
for the app (an LDAP user allowed to send as `<app>@<domain>`). To study:
|
||||
how `lib/mail.sh` and Superpanel create accounts.
|
||||
|
||||
PowerDNS: `*.<domain>` already points every app hostname at the Core, and
|
||||
traefik gets certificates through the DNS challenge, so apps need nothing
|
||||
from PowerDNS for `<app>.<domain>`.
|
||||
|
||||
## SDK packaging
|
||||
|
||||
|
||||
Reference in New Issue
Block a user