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:
@@ -10,6 +10,7 @@ a temporary folder. Run these on a machine or VM you don't mind changing.
|
||||
cd ~/Projects/coreapp-dev
|
||||
for f in install.sh update.sh uninstall.sh bin/coreapp-vm bin/coreapp libvirt/network-hook.sh; do bash -n "$f"; done
|
||||
shellcheck -x install.sh update.sh uninstall.sh bin/coreapp-vm bin/coreapp libvirt/network-hook.sh
|
||||
python3 -m py_compile core/coreapps && rm -rf core/__pycache__
|
||||
```
|
||||
|
||||
## install.sh
|
||||
@@ -140,77 +141,123 @@ On a machine you can rebuild (it removes the network every VM uses):
|
||||
`~/.config/coreapp-dev`.
|
||||
4. `bash install.sh` puts everything back.
|
||||
|
||||
## The installer (coreapps), off the Core
|
||||
|
||||
`coreapps manifest <dir>` checks a `coreapp.toml` without a Core. With a
|
||||
folder holding a valid one (`coreapp new x` makes one), each of these
|
||||
changes is refused with a message saying what's allowed, and exit 1:
|
||||
|
||||
- `port = "8080"` (a string), `port = 0`
|
||||
- `image = "coreapp/x"` (no registry, which would mean Docker Hub)
|
||||
- `title = "A $(reboot)"`, a `description` with `"` or `` ` ``
|
||||
- `name = "x-"`, `name = "X"`, `name = "mail"` (one of the Core's hostnames)
|
||||
- an unknown setting (`extra = 1`), `needs = ["redis"]`
|
||||
- a missing `version`
|
||||
|
||||
`needs = ["sso", "postgres"]` is accepted and printed in setup order
|
||||
(`needs=postgres sso`). `coreapps plan <dir>` off the Core (not root) says
|
||||
to run it as root on the Core.
|
||||
|
||||
## Apps (coreapp)
|
||||
|
||||
Against a Core in the VM (`coreapp-vm list` shows it running). These install
|
||||
a test app on that Core. It must not be registered with Federated's
|
||||
monitoring: `/federated/services/hello/service` on the Core has no
|
||||
`MONITOR` line, and `~/.local/share/coreapp-dev/logs/hello-install.log` has
|
||||
no `blackboxregistrar` request.
|
||||
test apps on that Core. None may be registered with Federated's monitoring:
|
||||
the generated `/federated/services/<name>/service` has no `MONITOR` line.
|
||||
The Core's own scripts trace secrets, so their output goes to
|
||||
`/federated/logs/coreapps/<name>-<install|update|remove>.log` on the Core
|
||||
(folder mode 700, files 600), never to the terminal unless a step fails.
|
||||
|
||||
1. `cd $(mktemp -d) && coreapp new hello`: `./hello` has `service`,
|
||||
1. `cd $(mktemp -d) && coreapp new hello`: `./hello` has `coreapp.toml`,
|
||||
`Dockerfile`, `.dockerignore`, `icon.png`, `www/`, `README.md` and
|
||||
nothing else, with no `{{...}}` left (`grep -r '{{' hello` prints
|
||||
nothing). `coreapp new hello` again refuses; so does `coreapp new x-`.
|
||||
2. `cd hello && coreapp deploy`: updates `/opt/coreapps` on the Core,
|
||||
builds, copies the image, prints `Installing hello at 192.168.200.x`
|
||||
(the first free address there) and `Installed: https://hello.<domain>/`.
|
||||
On the Core, `/federated/services/hello/` has `service`,
|
||||
`docker-compose.yml.in`, `env.in`, `install`, `uninstall`, `icon.png`,
|
||||
`Dockerfile`, `www/`, `README.md`, with no `{{...}}` left
|
||||
(`grep -r '{{' hello` prints nothing). `coreapp new hello` again refuses.
|
||||
`~/.local/share/coreapp-dev/app-addresses` has `hello 192.168.200.x`.
|
||||
2. `cd hello && coreapp deploy`: builds, copies the image, installs,
|
||||
prints `Deployed: https://hello.<domain>/`. On the Core,
|
||||
`/federated/apps/hello/.env` is root's, mode 600, with `IMAGE_VERSION`
|
||||
equal to `VERSION` and a random `APP_SECRET`.
|
||||
`coreapp.toml` and `.coreapp` (`needs=`); `/federated/apps/hello/.env`
|
||||
is root's, mode 600, with `IMAGE_VERSION` equal to `version` and a
|
||||
random `APP_SECRET`. Superpanel's catalog
|
||||
(`/federated/apps/superpanel/data/catalog.json`) lists `hello`.
|
||||
3. `coreapp check`: `OK: HTTP 200, valid certificate.` (the first
|
||||
certificate can take a minute).
|
||||
4. Change `www/index.html`, `coreapp deploy`: says "Updating it...", the
|
||||
container is recreated, the page shows the change, `APP_SECRET` is
|
||||
4. Change `www/index.html`, `coreapp deploy`: "Updating hello to 0.1.0",
|
||||
the container is recreated, the page shows the change, `.env` is
|
||||
unchanged. `coreapp deploy` again: "The Core already has this image."
|
||||
5. `coreapp status`, `coreapp logs`, `coreapp shell` (exit with `exit`).
|
||||
6. `coreapp remove`, answering y: on the Core, `/federated/apps/hello`,
|
||||
`/federated/services/hello`, the container and the `coreapp/hello`
|
||||
image are gone. Nothing from `uninstallapp`'s trace is printed; it's in
|
||||
`~/.local/share/coreapp-dev/logs/hello-remove.log` (mode 600).
|
||||
7. Collisions: an app named like one of Federated's (`coreapp new nextcloud`,
|
||||
deploy) is refused; so is an `INTERNAL_IP` another container uses.
|
||||
5. Raise `version` to 0.2.0, `coreapp deploy`: "Updated"; the container
|
||||
runs `:0.2.0`; `docker image ls localhost/coreapp/hello` on the Core lists
|
||||
only 0.2.0.
|
||||
6. `coreapp status` (address and port), `coreapp logs`, `coreapp shell`
|
||||
(exit with `exit`), `coreapp list` (all apps installed by coreapps).
|
||||
7. `coreapp remove`, answering y: on the Core, `/federated/apps/hello`,
|
||||
`/federated/services/hello`, the container and the image are gone, and
|
||||
the catalog no longer lists `hello`.
|
||||
8. Refused, with nothing changed on the Core:
|
||||
- `name = "nextcloud"` (one of Federated's apps) or `name = "mail"`
|
||||
- `image = "localhost/coreapp/nope"` with no such image on the Core
|
||||
(change `image`, and skip coreapp's build by running
|
||||
`coreapp-vm ssh /opt/coreapps/coreapps install <dir>` on a copy)
|
||||
- with the app installed with `needs = ["postgres"]`, deploying with
|
||||
`needs = []` ("drops needs postgres")
|
||||
9. On a Core whose tier isn't enterprise, deploying a new app asks before
|
||||
it's recorded as an add-on; answering no deploys nothing.
|
||||
|
||||
### With a database
|
||||
|
||||
1. `coreapp new --postgres guest-book`: has `app.py`, no `www/`;
|
||||
`service` has `DEPENDS="postgresql"`; `env.in` has `DB_NAME=coreapp_guest_book`
|
||||
and a random `DB_PASSWORD`; the README has a Database section.
|
||||
`coreapp.toml` has `needs = ["postgres"]` and `health = "/health"`; the
|
||||
README has a Database section.
|
||||
2. `coreapp deploy`, `coreapp check`. Loading the page several times
|
||||
(`curl -s https://guest-book.<domain>/ | grep visits`) counts up. On the
|
||||
Core, `docker exec postgresql psql -U postgres -l` lists `coreapp_guest_book`,
|
||||
owned by `coreapp_guest_book`.
|
||||
owned by `coreapp_guest_book`; `.env` has `DB_*`.
|
||||
3. Change `app.py`, `coreapp deploy`: the change shows, the count continues.
|
||||
4. `virsh -c qemu:///system reboot coreserver`: once the Core is up, the
|
||||
app answers and the count continues (its log may show "Waiting for the
|
||||
database" first).
|
||||
5. `coreapp remove`: the `coreapp_guest_book` database and user are gone too.
|
||||
|
||||
Adding a need later: install `coreapp new notes` (no needs), then set
|
||||
`needs = ["postgres"]` and deploy: "Updating", `.env` gains `DB_*` (the
|
||||
other values unchanged), the database `coreapp_notes` exists, the container
|
||||
has the `DB_*` variables, `.coreapp` says `needs=postgres`.
|
||||
|
||||
### With sign-in
|
||||
|
||||
1. `coreapp new --sso sso-demo`: has `app.py`, no `www/`; `service` has
|
||||
`DEPENDS="authelia"`; `docker-compose.yml.in` has `extra_hosts` with
|
||||
`@TRAEFIK_IP@`; `env.in` has `OIDC_*`; `app.py` and `oidc.py`; the README
|
||||
has a Sign-in section.
|
||||
1. `coreapp new --sso sso-demo`: has `app.py` and `oidc.py`, no `www/`;
|
||||
`needs = ["sso"]`; the README has a Sign-in section.
|
||||
2. `coreapp deploy`, `coreapp check`. On the Core, `idproviders.yml` has one
|
||||
`### coreapp-sso-demo begin` block; Authelia is healthy;
|
||||
`docker exec authelia authelia validate-config` is OK; no `*.bak` is
|
||||
left; the rendered compose file maps `authelia.<domain>` to traefik's
|
||||
address.
|
||||
left; `/federated/apps/sso-demo/docker-compose.yml` maps
|
||||
`authelia.<domain>` to traefik's address (`extra_hosts`).
|
||||
3. `https://sso-demo.<domain>/login` redirects to
|
||||
`https://authelia.<domain>/api/oidc/authorization?...client_id=coreapp-sso-demo...code_challenge_method=S256`.
|
||||
4. In a browser, sign in with a Core account: the page says "Signed in as
|
||||
..." with the account's email and groups. "Sign out" goes back to the
|
||||
sign-in link.
|
||||
5. Redeploy: still one client block. `coreapp remove`: none, Authelia
|
||||
healthy, other clients (Nextcloud) still work. Deploy again: one block.
|
||||
5. Redeploy: still one client block, and Authelia isn't restarted
|
||||
(`docker inspect -f '{{.State.StartedAt}}' authelia` unchanged).
|
||||
`coreapp remove`: no block, Authelia healthy, other clients (Nextcloud)
|
||||
still work. Deploy again: one block.
|
||||
|
||||
### With both
|
||||
|
||||
1. `coreapp new --postgres --sso team-visits`: `service` has
|
||||
`DEPENDS="postgresql authelia"`; `env.in` has `DB_*` and `OIDC_*`;
|
||||
`install` creates the database and registers the client; `uninstall`
|
||||
undoes both; `app.py` imports `oidc` and `psycopg`.
|
||||
2. `coreapp deploy`, `coreapp check`. In a browser, sign in: the page shows
|
||||
your name and "Your visits", which counts up on reload. Another account
|
||||
gets its own count; "people who have visited" counts both.
|
||||
1. `coreapp new --postgres --sso team-visits`: `needs = ["postgres",
|
||||
"sso"]`; `app.py` imports `oidc` and `psycopg`.
|
||||
2. `coreapp deploy`, `coreapp check`. On the Core, `service` has
|
||||
`DEPENDS="postgresql authelia"`, `.env` has `DB_*` and `OIDC_*`. In a
|
||||
browser, sign in: the page shows your name and "Your visits", which
|
||||
counts up on reload. Another account gets its own count; "people who have
|
||||
visited" counts both.
|
||||
3. `coreapp remove`: the database, user and Authelia client are gone.
|
||||
|
||||
### Apps deployed before coreapp.toml
|
||||
|
||||
An app deployed by an older coreapp (its own `service`, `install`, ... and
|
||||
an empty `.coreapp` marker on the Core) moves over by replacing those files
|
||||
with a `coreapp.toml` with the same name, image and needs. `coreapp deploy`
|
||||
then updates it: same address, `.env` and data unchanged, no needs set up
|
||||
again (they're read from its `DEPENDS`), Authelia not restarted; `.coreapp`
|
||||
then says which needs it has.
|
||||
|
||||
Reference in New Issue
Block a user