diff --git a/PLAN.md b/PLAN.md index 32d2cbb..af0f46f 100644 --- a/PLAN.md +++ b/PLAN.md @@ -579,6 +579,25 @@ Steps: - [ ] David: sign in to listmonk-app as admin@dev.fedcom.net (Super Admin, Settings), and send a campaign from `listmonk-app@dev.fedcom.net`; remove it when done + - Rehearsed 2026-12-04 with Open WebUI (upstream Python image, the + slim variant; postgres with `vector`, sso): deployed at + `https://open-webui.dev.fedcom.net/`, its data and vector store + (pgvector) in the Core's database, Core SSO sign-in (a new + account's first sign-in, as a regular user: Open WebUI has no + viewer role), admin made at startup with `WEBUI_ADMIN_EMAIL` and + kept by a trigger, password sign-in off, data kept by + `--recreate`. No language model or embeddings on the Core, so + chatting and document processing wait for "AI needs". Fixed from + it: `coreapp shell` sources `/coreapp/env.sh` if the image has + one, so settings an upstream image's entrypoint builds (a + database URL) reach the app's tools there too. Skill: that file; + apps that migrate only inside the server (call its migration + function, with the app on the import path); a "pending" role + isn't read-only; a random never-shown password when an app + insists on one; keep the admin trigger if `sso` is dropped; + `$TMPDIR` differs for any command outside the sandbox + - [ ] David: sign in to open-webui as admin@dev.fedcom.net in a + browser (admin panel); remove it when done - Done 2026-12-03: `[postgres] extensions = ["vector"]` in coreapp.toml: the installer checks the Core has each one and makes it in the app's database as the superuser (`CASCADE`, so diff --git a/TEST.md b/TEST.md index ec48587..06fb46f 100644 --- a/TEST.md +++ b/TEST.md @@ -271,7 +271,10 @@ The Core's own scripts trace secrets, so their output goes to 6. `coreapp status` (address and port), `coreapp logs`, `coreapp shell` (exit with `exit`), `coreapp shell 'id; echo $APP_URL'` (prints both, no terminal needed, also when piped), `coreapp list` (all apps installed - by coreapps). + by coreapps). With `/coreapp/env.sh` in the container (`export + CA_TEST=works`), `coreapp shell 'echo $CA_TEST'` and `echo $CA_TEST` + in an interactive `coreapp shell` print `works`; without the file, + nothing changes. 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`. diff --git a/bin/coreapp b/bin/coreapp index 2ca3799..51f119a 100755 --- a/bin/coreapp +++ b/bin/coreapp @@ -371,12 +371,16 @@ cmd_shell() { load_app core "docker exec $NAME sh -c : > /dev/null 2>&1" \ || die "Can't run a shell in $NAME: it isn't running (coreapp status, coreapp logs), or its image has no sh (images built FROM scratch or distroless). coreapp logs shows its output." + # Settings an entrypoint builds from the Core's (a database URL) are in + # /coreapp/env.sh, if the image has it: the entrypoint sources it, and + # so does the shell, so the app's own tools get them here too + local env='[ -r /coreapp/env.sh ] && . /coreapp/env.sh; ' if [[ $# -gt 0 ]]; then # One command, without a terminal, so scripts and agents can use it: # coreapp shell 'ls -l /data' - core "docker exec $NAME sh -c $(printf '%q' "$*")" + core "docker exec $NAME sh -c $(printf '%q' "$env$*")" else - core_tty "docker exec -it $NAME sh -c 'command -v bash > /dev/null && exec bash || exec sh'" + core_tty "docker exec -it $NAME sh -c $(printf '%q' "${env}command -v bash > /dev/null && exec bash || exec sh")" fi } diff --git a/skills/coreapp/SKILL.md b/skills/coreapp/SKILL.md index a46e342..e99681c 100644 --- a/skills/coreapp/SKILL.md +++ b/skills/coreapp/SKILL.md @@ -418,9 +418,10 @@ Common causes: check and its result (often the app refusing 127.0.0.1, see the porting checklist). An update rolls back; a first install stays, so deploy again once it's fixed. -- `coreapp` runs outside the sandbox, where `$TMPDIR` is another folder: - keep a file you pass between your shell and `coreapp` (or `docker cp`) - in the app's folder, not in `$TMPDIR`. +- Commands run outside the sandbox (`coreapp`, `docker`, anything with + `dangerouslyDisableSandbox`) see another `$TMPDIR`: keep files they + write or read in the app's folder (or a folder beside it), not in + `$TMPDIR`. The installer's own log (the Core's install scripts) is on the Core in `/federated/logs/coreapps/`. It contains secrets, so don't print it in full; diff --git a/skills/coreapp/references/porting.md b/skills/coreapp/references/porting.md index 73e5052..782de2b 100644 --- a/skills/coreapp/references/porting.md +++ b/skills/coreapp/references/porting.md @@ -31,7 +31,10 @@ SKILL.md), and make the Dockerfile fit the Core: another shape (a mail URL instead of `SMTP_*`, a database URL, a hex key), build them from the Core's variables where the app loads its settings, so its command-line tools (`coreapp shell ' ...'`) get - them too, not only the server started by the entrypoint. + them too, not only the server started by the entrypoint. In an upstream + image you can't change, put those lines (`export DATABASE_URL=...`) in + `/coreapp/env.sh` and source it from the entrypoint: `coreapp shell` + sources that file too. - **Read settings from the environment**, mapping the Core's names to the app's in an entrypoint script or config file if they differ (`SECRET_KEY="$APP_SECRET"`, `DATABASE_URL=...`). In an entrypoint for @@ -48,7 +51,12 @@ SKILL.md), and make the Dockerfile fit the Core: not from the app's config, so export those in yours. If you need a step between its steps (after its migrations, before the server starts), run its migration command yourself in your entrypoint, then your step, then - `exec` it (migrations are safe to run twice); editing the upstream + `exec` it (migrations are safe to run twice). If the app has no + migration command (it migrates when the server starts), call the + function its server calls, from a short script in the app's language; + run it from the app's folder with the app on the import path + (`PYTHONPATH`), since a script in `/coreapp/` doesn't find the app's + modules on its own. Editing the upstream script with `sed` is the last resort, since it breaks silently when the image changes. - **The image's `VOLUME`s** (`docker inspect -f '{{json .Config.Volumes}}' diff --git a/skills/coreapp/references/sign-in.md b/skills/coreapp/references/sign-in.md index 83d3c75..71aaf4c 100644 --- a/skills/coreapp/references/sign-in.md +++ b/skills/coreapp/references/sign-in.md @@ -94,13 +94,18 @@ else gets the lowest role that can look around. How: - If the app has its own first-run setup (an owner to create, a setup link), skip it on a Core: the Core's admin is the owner. If the app can't run without an owner (its pages say "not set up" until there is - one), make `CORE_ADMIN_EMAIL` the owner at startup, without a password. + one), make `CORE_ADMIN_EMAIL` the owner at startup, without a password + (or, if the app insists on one, a random one that is never shown or + saved). - That account signs in only with the Core: turn off the app's password sign-in and password reset for it, or its forgot-password page could give it a local password. - Other Core accounts join on their first Core sign-in, without an invitation, as read-only members (a viewer: they see what members see, - change nothing). Not "nothing until an admin grants access". + change nothing). Not "nothing until an admin grants access": a + "pending" or "awaiting approval" role isn't read-only, it's locked out. + If the app has no viewer role, use its regular user role and say so in + your report. - The example app (`coreapp new --sso`) shows the admin check in `oidc.py`. - In an upstream image you can't change, use what it offers, in this order: a setting that names admins by email; its CLI or API at startup @@ -108,8 +113,9 @@ else gets the lowest role that can look around. How: rule has to hold on every sign-in and the app has no hook for it, a database trigger on its users table that touches only the `CORE_ADMIN_EMAIL` row (role, enabled, no password), made at startup by - the entrypoint and explained in a comment. Say in your report which you - used. + the entrypoint and explained in a comment. Keep it if `sso` is dropped + later: the admin rule holds without sign-in too. Say in your report + which you used. ## Testing sign-in: coreapp signin