Open WebUI rehearsal: coreapp shell sources /coreapp/env.sh

Settings an upstream image's entrypoint builds from the Core's (a
database URL) go in /coreapp/env.sh, which the entrypoint sources and
coreapp shell now sources too, for one command and interactively.

Skill: that file; apps that migrate only inside the server; a pending
role isn't read-only; a never-shown password when an app insists on one;
keep the admin trigger when sso is dropped; $TMPDIR differs for any
command outside the sandbox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 13:32:43 -07:00
co-authored by Claude Opus 5.5
parent 114b364cef
commit b855fd53f4
6 changed files with 53 additions and 12 deletions
+19
View File
@@ -579,6 +579,25 @@ Steps:
- [ ] David: sign in to listmonk-app as admin@dev.fedcom.net - [ ] David: sign in to listmonk-app as admin@dev.fedcom.net
(Super Admin, Settings), and send a campaign from (Super Admin, Settings), and send a campaign from
`listmonk-app@dev.fedcom.net`; remove it when done `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 - Done 2026-12-03: `[postgres] extensions = ["vector"]` in
coreapp.toml: the installer checks the Core has each one and coreapp.toml: the installer checks the Core has each one and
makes it in the app's database as the superuser (`CASCADE`, so makes it in the app's database as the superuser (`CASCADE`, so
+4 -1
View File
@@ -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` 6. `coreapp status` (address and port), `coreapp logs`, `coreapp shell`
(exit with `exit`), `coreapp shell 'id; echo $APP_URL'` (prints both, (exit with `exit`), `coreapp shell 'id; echo $APP_URL'` (prints both,
no terminal needed, also when piped), `coreapp list` (all apps installed 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`, 7. `coreapp remove`, answering y: on the Core, `/federated/apps/hello`,
`/federated/services/hello`, the container and the image are gone, and `/federated/services/hello`, the container and the image are gone, and
the catalog no longer lists `hello`. the catalog no longer lists `hello`.
+6 -2
View File
@@ -371,12 +371,16 @@ cmd_shell() {
load_app load_app
core "docker exec $NAME sh -c : > /dev/null 2>&1" \ 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." || 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 if [[ $# -gt 0 ]]; then
# One command, without a terminal, so scripts and agents can use it: # One command, without a terminal, so scripts and agents can use it:
# coreapp shell 'ls -l /data' # coreapp shell 'ls -l /data'
core "docker exec $NAME sh -c $(printf '%q' "$*")" core "docker exec $NAME sh -c $(printf '%q' "$env$*")"
else 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 fi
} }
+4 -3
View File
@@ -418,9 +418,10 @@ Common causes:
check and its result (often the app refusing 127.0.0.1, see the porting 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 checklist). An update rolls back; a first install stays, so deploy again
once it's fixed. once it's fixed.
- `coreapp` runs outside the sandbox, where `$TMPDIR` is another folder: - Commands run outside the sandbox (`coreapp`, `docker`, anything with
keep a file you pass between your shell and `coreapp` (or `docker cp`) `dangerouslyDisableSandbox`) see another `$TMPDIR`: keep files they
in the app's folder, not in `$TMPDIR`. 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 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; `/federated/logs/coreapps/`. It contains secrets, so don't print it in full;
+10 -2
View File
@@ -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 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 key), build them from the Core's variables where the app loads its
settings, so its command-line tools (`coreapp shell '<app> ...'`) get settings, so its command-line tools (`coreapp shell '<app> ...'`) 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 - **Read settings from the environment**, mapping the Core's names to the
app's in an entrypoint script or config file if they differ app's in an entrypoint script or config file if they differ
(`SECRET_KEY="$APP_SECRET"`, `DATABASE_URL=...`). In an entrypoint for (`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 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 between its steps (after its migrations, before the server starts), run
its migration command yourself in your entrypoint, then your step, then 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 script with `sed` is the last resort, since it breaks silently when the
image changes. image changes.
- **The image's `VOLUME`s** (`docker inspect -f '{{json .Config.Volumes}}' - **The image's `VOLUME`s** (`docker inspect -f '{{json .Config.Volumes}}'
+10 -4
View File
@@ -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 - 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 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 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 - 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 sign-in and password reset for it, or its forgot-password page could
give it a local password. give it a local password.
- Other Core accounts join on their first Core sign-in, without an - Other Core accounts join on their first Core sign-in, without an
invitation, as read-only members (a viewer: they see what members see, 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`. - 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 - 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 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 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 database trigger on its users table that touches only the
`CORE_ADMIN_EMAIL` row (role, enabled, no password), made at startup by `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 the entrypoint and explained in a comment. Keep it if `sso` is dropped
used. later: the admin rule holds without sign-in too. Say in your report
which you used.
## Testing sign-in: coreapp signin ## Testing sign-in: coreapp signin