coreapps keeps copies of the app's service folder, .env and compose file during an update. If it fails before the app answers, it tears down needs the update added, restores the copies, starts the old version and removes the new image. Data isn't rolled back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
513 lines
30 KiB
Markdown
513 lines
30 KiB
Markdown
# Plan
|
|
|
|
coreapp-dev is a software development kit for building apps that run as
|
|
Docker containers on Federated Core. It is a CoreDesktop sibling project:
|
|
people install it with `sibling add <url>`, and CoreDesktop's `update` keeps
|
|
it current (format: `~/Projects/coredesktop/skills/sibling-project-format.md`).
|
|
Delete an item once it's done; git history keeps the record.
|
|
|
|
## Now: a working Core in a local VM
|
|
|
|
What we know about the CoreServer image (2026-12-02): it's Arch Linux, boots
|
|
with BIOS or UEFI, and needs a display device (it stalls at "Loading initial
|
|
ramdisk" with `--graphics none`). All passwords are locked; cloud-init
|
|
(NoCloud) installs root's SSH keys. `/` is a fixed 10 GiB btrfs partition;
|
|
the extra disk space goes to `/federated`, which the image's own
|
|
`grow-federated.service` grows on first boot.
|
|
|
|
The Core `dev.fedcom.net` was provisioned on 2026-12-03 in the VM
|
|
(10.123.0.10). It's reachable from the internet at 77.216.180.150
|
|
through corerelay, which also carries its outbound traffic.
|
|
|
|
What we learned provisioning (2026-12-02/03):
|
|
- Federated Core finds its public IP with `dig @resolver4.opendns.com
|
|
myip.opendns.com` and publishes it in DNS, so the Core's outbound traffic
|
|
must leave through the relay (first attempt published the home IP)
|
|
- The Core is the authoritative DNS server for its domain (ns1/ns2.<domain>
|
|
point at `ip`), so 53 tcp/udp must be forwarded, plus 25 143 465 587 993
|
|
4190 9980 besides 22 80 443
|
|
- The domain is picked round-robin (dev.federatedcomputer.cloud,
|
|
dev.federatedcomputer.net, dev.fedcom.net, ...)
|
|
- The progress stream from core-create is server-sent events; it takes 5+
|
|
minutes, a full install about 40
|
|
- Deleting a Core makes the platform SSH into its IP and tear it down, so
|
|
never put a new VM behind an IP whose old Core still exists. A failed Core
|
|
has no delete button; Federated has to remove it
|
|
- The Core's containers use 192.168.0.0/16 and send replies for any
|
|
192.168.x.x address onto their own bridge, so the VM network is
|
|
10.123.0.0/24 (moved there on 2026-12-03 from 192.168.123.0/24)
|
|
- libvirt's DHCP `<host>` reservations are ignored on this workstation:
|
|
libvirt writes the hosts file readable by root only and dnsmasq reads it as
|
|
`nobody`. The reservation is a `dnsmasq:option` in the network instead
|
|
- Before core-create on a fresh VM: `systemctl is-active docker`, opendns
|
|
sees the VPS IP, and the hairpin (`/dev/tcp/<vps-ip>/22` from the VM)
|
|
|
|
- [ ] The Core shows as Active in the dashboard
|
|
- [ ] Tell Federated (2026-12-03):
|
|
- Apps send mail as `fcore` (an `inetOrgPerson` in the `admins` group)
|
|
with the Core's admin password (`MAIL_PASSWORD=$ADMINPASS` in e.g.
|
|
`lib/bookstack.sh`), so every app holds the admin password. The
|
|
mail server also has no `SPOOF_PROTECTION`, so any account can send
|
|
as any address. coreapps gives each app its own sending-only
|
|
account instead (see Coreapps, step 4)
|
|
- On this image, disabling systemd-resolved isn't enough: networkd's
|
|
`systemd-networkd-resolve-hook.socket` starts it at boot, it takes
|
|
port 53 and pdns can't start after a reboot. coreapp-dev masks it
|
|
through cloud-init; the installer should mask it too
|
|
- Every Core timer (upgrade-federated, free-up-space, backuptool,
|
|
dumpcerts, fix-nextcloud, nextcloud-maintenance) has
|
|
`Requires=<its service>` in `[Unit]`, so its job also runs at every
|
|
boot, about 5 s in, not just on its schedule. Evidence (2026-12-03):
|
|
boots at 18:01:20 and 18:14:08 UTC; all four checked jobs started at
|
|
18:01:25 and 18:14:13. Consequences:
|
|
- upgrade-federated runs before the network is online (it has no
|
|
`After=network-online.target`): `git pull` fails with "Could not
|
|
resolve host: gitea.federated.computer", then `send_alert_upgrade`
|
|
emails ALERTS_EMAIL ("upgrade failed to run on <ip> - couldn't
|
|
pull from git") and posts a Matrix alert, and it exits 2
|
|
(`/federated/logs/upgrade.log`). So every reboot sends a false
|
|
alert
|
|
- free-up-space runs `docker system prune -f` and
|
|
`docker image prune -a --filter until=24h` while containers are
|
|
still starting: at 18:01:25 it deleted the pdns container that
|
|
had failed to start (port 53) and its image
|
|
(`/federated/logs/freeupspace.log`). Any app container that is
|
|
stopped at boot time goes the same way
|
|
- `/federated/bin/upgrade` has an API token in it, readable by anyone
|
|
with the image; `lib/functions.sh` has the monitoring registrar's
|
|
bearer token, and `uninstallapp`'s `set -x` prints it
|
|
- `bin/start` doesn't know apps outside its fixed lists, so a new
|
|
app in the generic format isn't started by `installapp`
|
|
|
|
## Next: the SDK (build, deploy and test an app on the Core)
|
|
|
|
### How the Core runs apps (studied 2026-12-03 on dev.fedcom.net)
|
|
|
|
- `/federated` is a git checkout of Federated's `Core` repo, updated by
|
|
`/federated/bin/upgrade` (`git pull`). Untracked folders survive pulls.
|
|
- Installed apps live in `/federated/apps/<app>/`: `docker-compose.yml`,
|
|
`.env` (mode 600), secrets in files, data under `data/`.
|
|
- Every container is on the external Docker network `core`
|
|
(192.168.0.0/16) with a fixed `ipv4_address`. Federated's apps use
|
|
192.168.0.7 to .121.
|
|
- traefik (`providers.docker`, `exposedByDefault=false`) routes by labels:
|
|
`traefik.enable=true`, `routers.<app>.rule=Host(`<app>.<domain>`)`,
|
|
`entrypoints=websecure`, `tls.certresolver=letsencrypt` (DNS challenge
|
|
through the Core's own pdns, so any hostname gets a certificate), and
|
|
`services.<app>.loadbalancer.server.port` when the port isn't 80.
|
|
- DNS: the zone has `*.<domain>` CNAME `www.<domain>` (the public IP), so
|
|
every app hostname already resolves. Some apps also add their own A record.
|
|
- `/federated/bin/installapp [-n] <app>` installs an app from either
|
|
- `lib/<app>.sh` with `config_<app>`, `start_<app>`, `uninstall_<app>` and
|
|
optionally `configsso_<app>` (Authelia OIDC) and `email_<app>`; or
|
|
- the newer generic format, `services/<app>/`:
|
|
- `service`: `NAME`, `DESCRIPTION`, `DOCS`, `CONTAINER`, `VERSION`,
|
|
`INTERNAL_IP`, `DEPENDS`, `PORTS`, `MONITOR="https://<app>.@DOMAIN@|http_2xx"`
|
|
- `docker-compose.yml.in` and `env.in`: templates. `@DOMAIN@` and other
|
|
variables from `/etc/federated`; `@IMAGE_VERSION@`;
|
|
`@NAME:RANDOM:LLLL...@` makes a random value (L = letter or digit)
|
|
- `icon.png`
|
|
- `install`: `. /federated/lib/helpers.sh` and `installGeneric <app>`
|
|
(fills in the templates into `/federated/apps/<app>/`); installapp
|
|
then runs `/federated/bin/start <app>`
|
|
- optional `uninstall`, `timers/`, `services/` (systemd units)
|
|
- installapp installs `DEPENDS` first; `uninstallapp <app>` reverses it.
|
|
- superpanel's catalog lists `services/*/service`, so an app installed this
|
|
way shows up in the Core's dashboard.
|
|
|
|
### Design
|
|
|
|
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).
|
|
|
|
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. 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). 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). Like Federated's
|
|
apps, it keeps a copy in `/federated/apps/<name>/.<name>.oidc-client.yml`
|
|
(mode 600): Authelia's start (`reconcile_authelia_sso`, also
|
|
`bin/reconcile-authelia-sso`) appends any client whose copy exists but
|
|
whose first line is missing from `idproviders.yml`. So uninstalling
|
|
deletes the copy before restarting Authelia, or the client would come
|
|
back. Tested 2026-12-03: a removed block is restored by reconcile; an
|
|
uninstalled app's client stays gone `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)
|
|
- `/data` is a bind mount Docker creates as root, so an app running as
|
|
another user couldn't write there. The installer gives it to the image's
|
|
user (`Config.User`, resolved with `id` in the image if it's a name)
|
|
- 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
|
|
|
|
### How Federated adds an app to every Core
|
|
|
|
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
|
|
|
|
## Coreapps: apps from the developer's own repository
|
|
|
|
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: the first free one in
|
|
192.168.5.0/24, the range Federated's Core developer set aside for
|
|
custom apps (since 2026-12-03; apps installed in 192.168.200.x before
|
|
move on their next update)
|
|
- 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 (2026-12-03): `coreapp publish` builds the image, pushes
|
|
`image:version` to the registry in `coreapp.toml`, never replacing a
|
|
published version, and tags the commit `v<version>`; new apps also get
|
|
`.gitea/workflows/publish.yml`, which does the same on a `v*` tag.
|
|
Federated's Gitea is 1.27.2 with its container registry on the same
|
|
host; the Core's own `gitearunner` registers with the Core's Gitea only,
|
|
so whether developers on gitea.federated.computer have a runner that can
|
|
use Docker is unknown. Tested against a local registry. `docker
|
|
manifest inspect` reported "no such manifest" for an image that existed,
|
|
so the check uses `docker buildx imagetools inspect`, and any error but
|
|
"not found" stops the publish
|
|
- Tested 2026-12-03 by David: `coreapp publish` of
|
|
`gitea.federated.computer/david/pub-test:0.1.0` worked (package and
|
|
tag `v0.1.0` in Gitea). The account `david` isn't visible anonymously
|
|
(its profile, repository and API answer 404 without a login), so its
|
|
packages probably can't be pulled without one either: see "Private
|
|
repositories and packages" under step 3
|
|
- [ ] Run the workflow on a repository with a runner
|
|
|
|
3. Install from a repository (2026-12-03): `coreapps plan|install
|
|
<https://host/owner/repo>[@tag]` and `coreapps update <name>`; on the
|
|
workstation `coreapp install <url>` (shows the app, its source and needs,
|
|
asks) and `coreapp update <name>`. The installer fetches only the tag's
|
|
commit (depth 1, no blobs but `coreapp.toml` and `icon.png`, which must be
|
|
regular files; a link is ignored), with git limited to https, no password
|
|
prompts and no system or root git settings. The default tag is the newest
|
|
numeric release (`v1.2.3`, compared as numbers); `version` must match the
|
|
tag; the image is always pulled for a repository install (never a
|
|
same-named image built on the Core). The marker records `source`, `tag`
|
|
and `commit`; installing the same name from another repository is
|
|
refused. Tested on dev.fedcom.net with a stand-in repository (file://,
|
|
the https rule relaxed for the test) and nginx 1.27/1.28 as the image:
|
|
plan, install, update, "already newest", the other-repository refusal,
|
|
remove; and, on the workstation, tag selection, the version check, the
|
|
link icon and URL checks. Found and fixed: docker lists
|
|
`docker.io/library/nginx` as `nginx`, so old images weren't deleted;
|
|
`remove` force-deleted images, which could untag one another app uses
|
|
- End to end with a real repository and registry: done with David's
|
|
private pub-test (below)
|
|
- Private repositories and packages (2026-12-03; Coreapps are "private"
|
|
apps, so their repositories usually are): `coreapps login <host>
|
|
<user>` (token on stdin), `logout`, `logins`; on the workstation
|
|
`coreapp login <host>` asks for user and token. Tokens by host in
|
|
`/etc/coreapps/credentials` (dir 700, file 600, outside `/opt/coreapps`,
|
|
which deploys replace). git gets the token as an `http.<url>.extraHeader`
|
|
in its environment, for that host only (never in a URL or an error);
|
|
docker gets it in a config made for each pull, so no docker login stays
|
|
on the Core. `login` checks the token with the host's registry
|
|
(`/v2/`, then its token endpoint) and saves nothing if it's rejected.
|
|
Tested 2026-12-03: a wrong token for gitea.federated.computer is
|
|
rejected, file modes, logout, bad input, and David's private
|
|
repository and image without a token both stop with "coreapp login"
|
|
hints. Found: David's packages can't be pulled without a login
|
|
(`unauthorized: reqPackageAccess`)
|
|
- Tested 2026-12-03 by David: `coreapp login gitea.federated.computer`
|
|
with a read-only token, then `coreapp install
|
|
https://gitea.federated.computer/david/pub-test` from the private
|
|
repository and package: installed at `https://pub-test.dev.fedcom.net/`
|
|
(HTTP 200), `list` shows the source `@v0.1.0`, no docker login left
|
|
on the Core
|
|
- [ ] Tokens per host+owner, if a Core needs several accounts on one host
|
|
- [ ] Superpanel would manage these tokens
|
|
- [ ] Downgrades: installing an older tag is allowed (`@v1.0.0`); an app's
|
|
data may not survive that. Refuse, or warn?
|
|
- [ ] Pin the image digest at install (from the registry at that moment)
|
|
so a re-pushed tag can't change what's installed
|
|
4. Email (2026-12-03): `needs = ["email"]` (`coreapp new --email`) gives
|
|
the app its own mail account for sending: an LDAP entry
|
|
`uid=coreapp-<name>,ou=people` with `objectClass: account`,
|
|
`simpleSecurityObject`, `PostfixBookMailAccount`, `mail:
|
|
coreapp-<name>@<domain>`, `mailEnabled: FALSE` (no mailbox), `description:
|
|
coreapps: <name>` (whose it is), password from `.env` set with
|
|
`ldappasswd` (hashed by the server). Not a person, so Authelia
|
|
(`objectClass=person`), Nextcloud (`inetOrgPerson`) and Superpanel don't
|
|
see it; Federated's shared `fcore` account is an `inetOrgPerson` in
|
|
`admins`, hidden only by Superpanel's `HIDDEN_USERS`, and apps get the
|
|
admin password with it. Its own address so a person's mail login (by
|
|
mail or uid) never finds two entries. `SMTP_*` settings: mail.<domain>,
|
|
587, STARTTLS, user, password, `SMTP_FROM=<name>@<domain>`. Setup leaves
|
|
an entry that isn't the app's alone and the installer warns. Tested on
|
|
dev.fedcom.net: login from the core network with a valid certificate,
|
|
sender and a local recipient accepted (nothing sent), wrong password
|
|
refused (535), password stored `{SSHA}`, Authelia sign-in refused (401),
|
|
not in Nextcloud or Superpanel users, teardown, a foreign entry left
|
|
alone (with a warning), email added to an existing app on update
|
|
- [ ] Send a real message, to an address outside the Core (through the
|
|
relay)
|
|
- [ ] Spoofing: the mail server has no `SPOOF_PROTECTION`, so any
|
|
authenticated account (Federated's apps' `fcore` too) can send as any
|
|
address. Tell Federated; with it on, an app could only send as its
|
|
account's address
|
|
- MySQL (2026-12-03): `needs = ["mysql"]` (`coreapp new --mysql`): a
|
|
user and database `coreapp_<name>` (utf8mb4) on `pdnsmysql` (MariaDB
|
|
12.1, shared with PowerDNS), as Federated's apps do (e.g.
|
|
`lib/bookstack.sh`); same `DB_*` names as postgres, so an app has one
|
|
or the other. Root's password is read inside the container
|
|
(`$MYSQL_ROOT_PASSWORD`), not by the script, so it isn't in the
|
|
`set -x` log (Federated's `functions.sh` logs it anyway as
|
|
`MYSQL_ROOTPASSWORD=`, for every install: see "Logs"). Tested on
|
|
dev.fedcom.net: both needs refused, install, a table made and read from
|
|
the core network, no access to `powerdns`, wrong password refused,
|
|
remove drops the user and database, reinstall
|
|
- [ ] AI needs (findings below; needs Federated), then other services:
|
|
PowerDNS records beyond the wildcard, if an app needs other hostnames
|
|
5. The skill (moved ahead of 2-4, 2026-12-03): `skills/coreapp/SKILL.md`,
|
|
linked into `~/.claude/skills/coreapp` by `update.sh`, so any Claude Code
|
|
agent on this computer can use it. Rehearsed with a small app
|
|
(`memo-board`)
|
|
- [ ] Test it with David's candidate app: an agent in that repository
|
|
uses the skill; what it struggles with becomes fixes
|
|
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:
|
|
- Done 2026-12-03: a failed update rolls back. coreapps keeps copies of
|
|
`services/<name>/`, `.env` and `docker-compose.yml`; if anything fails
|
|
until the app answers (or on Ctrl-C), it runs the teardown of needs the
|
|
update added, puts the copies back, starts the old version and removes
|
|
the new image. Data (`/data`, database contents) isn't rolled back: a new
|
|
version that migrated its database can leave the old one unable to run.
|
|
Tested on dev.fedcom.net
|
|
- [ ] Back up the app's database (and `/data`?) before an update, to roll
|
|
back data too; or a `coreapps rollback` that restores it on request
|
|
- [ ] 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)
|
|
|
|
### Guidance from Federated's Core developer (2026-12-03)
|
|
|
|
Their points, and where coreapp-dev stands:
|
|
- Apps as `lib/<app>.sh` (config, start, uninstall, sso functions) for
|
|
`installapp`, `uninstallapp` and `installapp-sso`: not done. The
|
|
installer uses the generic `services/<app>/` format (`installGeneric`),
|
|
which `installapp` also supports. A `lib/<app>.sh` from an app's
|
|
repository would be root code from its author; the installer could
|
|
generate one from its own templates instead
|
|
- `services/<app>/service` for version, internal IP, container and image:
|
|
done
|
|
- MySQL apps use the `pdnsmysql` container (MariaDB, 192.168.0.10, also
|
|
PowerDNS's database), PostgreSQL apps `postgresql`: postgres is done;
|
|
done (`mysql` need, Coreapps step 4)
|
|
- Authelia through `installapp-sso` / `configsso_<app>`: needs a
|
|
`lib/<app>.sh`, so not used; the sso need does the same, and keeps the
|
|
client copy Federated's apps keep
|
|
- Base directory `/federated/custom` (`custom/lib/<app>.sh`,
|
|
`custom/apps/<app>/`, `custom/services/<app>/service`): it doesn't exist
|
|
yet and no Core script knows it, so installapp, uninstallapp,
|
|
installapp-sso, start, stop, upgrade, the catalog and Superpanel (its
|
|
container mounts `/federated/apps` only) would need to learn it. Decided
|
|
2026-12-03 (David): go on with `/opt/coreapps` and today's paths, and tell
|
|
Federated what Superpanel needs later
|
|
- Internal IPs in 192.168.5.0/24: done
|
|
|
|
Superpanel lists our apps in its catalog (`catalog.json`) but not in its
|
|
installed-apps list (`applist.json`, made by
|
|
`superpanel-generate-applist-dashboard`), so they probably don't show on
|
|
its dashboard or in "Disk Usage by App". [ ] Find out why
|
|
|
|
### The installer in /federated/bin/coreapps/ (wanted, 2026-12-03)
|
|
|
|
David wants the installer on the Core in `/federated/bin/coreapps/`
|
|
instead of `/opt/coreapps`. What may need to change on the Core, for
|
|
Federated (checked on dev.fedcom.net):
|
|
|
|
1. **It has to come from the Core repo.** `/federated` is a git checkout
|
|
that `upgrade` pulls nightly. An untracked `bin/coreapps/` survives pulls
|
|
until the repo gets files of the same name; then `git pull` refuses, and
|
|
the upgrade fails (`bin/upgrade` already has a workaround for exactly
|
|
this with `bin/sync-calcomusers`). So Federated commits `bin/coreapps/`
|
|
to the Core repo, and Cores get it and its updates through `upgrade`
|
|
2. **coreapp-dev stops copying it there.** `coreapp deploy` replaces
|
|
`/opt/coreapps` on every deploy. Doing that in `/federated/bin/coreapps/`
|
|
would modify tracked files and break the next `git pull` the same way.
|
|
Instead coreapp-dev would use the Core's copy, and keep `/opt/coreapps`
|
|
only as an override for testing installer changes
|
|
3. **Layout.** Everything else in `/federated/bin` is a single executable
|
|
that Federated's scripts call by full path. A folder there means the
|
|
command is `/federated/bin/coreapps/coreapps`. Alternatives: the
|
|
command as `/federated/bin/coreapps` with its templates and needs in
|
|
`/federated/lib/coreapps/` (where Federated keeps shared files), or a
|
|
wrapper. Decide with Federated
|
|
4. **Python.** The installer needs Python 3.11 or newer (`tomllib`); the
|
|
Core's scripts are otherwise bash. The image has 3.14 today; Federated
|
|
would have to keep python3 in the image
|
|
5. **Superpanel has to run it as root on the host.** Superpanel runs
|
|
`installapp`/`uninstallapp` already (strings in its binary) but its
|
|
container only mounts `/federated/lib` (read-only), `/federated/apps`,
|
|
`/federated/logs` and the Docker socket, not `/federated/bin` or
|
|
`/federated/services`. How it reaches the host now is still to find out.
|
|
The Coreapps screen would call `coreapps plan`, `install`, `remove` and
|
|
`list` the same way
|
|
6. **Where the apps' files go.** The installer writes
|
|
`/federated/services/<name>/` (untracked, like the test apps now show in
|
|
`git status`). It works, and Superpanel's catalog and
|
|
`installapp`/`uninstallapp` find them there, but they're untracked files
|
|
in Federated's checkout. Federated may prefer a separate folder (e.g.
|
|
`/federated/coreapps/<name>/`) with `installapp`, `uninstallapp` and
|
|
`superpanel-generate-catalog` taught to look there too, and `.gitignore`
|
|
covering whatever stays in `services/`
|
|
7. **Starting and stopping.** `bin/start` and `bin/stop` only know the
|
|
fixed `CORE_APPS`/`EXTRA_APPS` lists, so `installapp` doesn't start a
|
|
coreapp and `start all`/`stop` skip them (the installer starts them
|
|
itself). They should also handle apps marked `.coreapp`
|
|
8. **The nightly upgrade.** `upgrade_federated` goes through installed
|
|
apps; for a coreapp `VERSION` equals `IMAGE_VERSION`, so nothing happens,
|
|
which is right (coreapps updates them). But `upgrade_app` reads the
|
|
current image with `cut -d: -f2`, which breaks on an image whose registry
|
|
has a port (`gitea.example.com:5000/owner/app`): it would think the image
|
|
changed and rewrite the compose file wrongly. Either skip apps marked
|
|
`.coreapp`, or parse the image properly
|
|
9. **free-up-space.** Its `docker image prune -a --filter until=24h` deletes
|
|
images of stopped apps. Published apps can be pulled again; a
|
|
`localhost/` dev image can't. Fine for published apps; for dev it means
|
|
a stopped test app may need `coreapp deploy` again
|
|
10. **Monitoring, billing.** `installapp` records non-hidden apps in
|
|
`ADDON_APPS` on non-enterprise tiers, and would register `MONITOR` URLs
|
|
(the installer writes none). Federated decides whether third-party apps
|
|
are billed as add-ons, and whether published apps get monitored
|
|
11. **Logs.** The installer keeps the Core scripts' output (which contains
|
|
secrets because of their `set -x`) in `/federated/logs/coreapps/`
|
|
(mode 700). Federated may want that elsewhere, or fewer secrets in the
|
|
traces (see "Tell Federated")
|
|
|
|
### 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
|
|
|
|
- [ ] Tag the first release once install and VM creation work end to end
|