Fixes from the listmonk rehearsal; porting checklist in its own file

A rehearsal porting listmonk (postgres, sso, email) deployed it, signed
in, and read its opt-in mail with coreapp inbox. The name refusal said the
Core "already has" listmonk when it's Federated's uninstalled app; it now
says so, and coreapp core lists the names apps can't use. The porting
checklist moves to references/porting.md, adding settings kept in the
app's database, upstream entrypoints that assume root, and min_version
from the app's documented minimum. sign-in.md: the admin rule in an
upstream image, and when --form isn't needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 21:05:11 -07:00
co-authored by Claude Opus 5.5
parent f0468c43f2
commit 5d90c246a1
7 changed files with 177 additions and 91 deletions
+20
View File
@@ -503,6 +503,26 @@ Steps:
in one command in one command
- [ ] David: Miniflux runs without an admin until the Core's - [ ] David: Miniflux runs without an admin until the Core's
groups work (then map `admins`) groups work (then map `admins`)
- Rehearsed 2026-12-03 with listmonk (upstream image; postgres, sso,
email; a new agent with only the skill): deployed as
`listmonk-app` at `https://listmonk-app.dev.fedcom.net/`, signed in
(the test account a read-only Viewer), the admin rule kept by a
trigger, a double opt-in confirmation read with `coreapp inbox`
and confirmed, data kept by `--recreate`. Used `min_version`
(12). Fixed from it: the name refusal said "already has an app
called 'listmonk'" for Federated's uninstalled listmonk; it now
says it's Federated's app's name, and `coreapp core` lists the
names apps can't use. The porting checklist moved to
`references/porting.md` (SKILL.md 500 -> ~430 lines), with:
settings an app keeps in its database (write the Core's at every
start), upstream entrypoints that assume root (`PUID`/`PGID`), and
`min_version` from the app's documented minimum. sign-in.md: the
admin rule in an upstream image (a setting, else CLI/API at
startup, else a trigger on the admin's row only), and `--form`
isn't needed beside a password form
- [ ] 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
- 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
+1 -1
View File
@@ -180,6 +180,6 @@ stay installed.
| `templates/app/` | What `coreapp new` starts from | | `templates/app/` | What `coreapp new` starts from |
| `templates/postgres/`, `templates/sso/` | Example apps laid over it by `--postgres` / `--sso`: their files replace the base's; `*.append` files are added to the base file, `.remove` lists base files to drop, `.needs` goes into `needs` | | `templates/postgres/`, `templates/sso/` | Example apps laid over it by `--postgres` / `--sso`: their files replace the base's; `*.append` files are added to the base file, `.remove` lists base files to drop, `.needs` goes into `needs` |
| `templates/postgres-sso/` | The example app when both are used | | `templates/postgres-sso/` | The example app when both are used |
| `skills/coreapp/` | A Claude Code skill for making apps (`SKILL.md`, with `references/sign-in.md` and `references/publishing.md` read when needed); `update.sh` links it into `~/.claude/skills/` | | `skills/coreapp/` | A Claude Code skill for making apps (`SKILL.md`, with `references/porting.md`, `references/sign-in.md` and `references/publishing.md` read when needed); `update.sh` links it into `~/.claude/skills/` |
| `uninstall.sh` | Removes what coreapp-dev set up | | `uninstall.sh` | Removes what coreapp-dev set up |
| [PLAN.md](PLAN.md), [TEST.md](TEST.md) | What's next, and how to test it | | [PLAN.md](PLAN.md), [TEST.md](TEST.md) | What's next, and how to test it |
+7
View File
@@ -222,6 +222,13 @@ The Core's own scripts trace secrets, so their output goes to
disk (btrfs) and what's not offered. As an app's database user, disk (btrfs) and what's not offered. As an app's database user,
`CREATE EXTENSION pg_trgm` works and `CREATE EXTENSION vector` is `CREATE EXTENSION pg_trgm` works and `CREATE EXTENSION vector` is
refused ("Must be superuser"). refused ("Must be superuser").
5e. Names: `coreapp core` lists "Names apps can't use" (Federated's apps
from `/federated/services` and `/federated/lib`, installed or not, and
the Core's host names; not coreapps' own apps). Deploying `listmonk`:
"'listmonk' is the name of one of Federated's apps on this Core (not
installed, but the Core can install it) ..."; `nextcloud`: "...
(installed)"; `carpal` (only a script in `/federated/lib`): refused too.
An app coreapps installed (`listmonk-app`) deploys as before.
5c. `[postgres] extensions`: a `coreapp new --postgres` app with 5c. `[postgres] extensions`: a `coreapp new --postgres` app with
`[postgres]` `extensions = ["vector"]` deploys with "Enabling PostgreSQL `[postgres]` `extensions = ["vector"]` deploys with "Enabling PostgreSQL
extension(s) vector"; on the Core, its database has vector (owned by extension(s) vector"; on the Core, its database has vector (owned by
+22 -6
View File
@@ -618,18 +618,32 @@ def marker_value(name, key):
return "" return ""
def federated_names():
"""Names of the Core's own apps and services, installed or not: their
folders in /federated/services and their scripts in /federated/lib."""
names = set()
if os.path.isdir(SERVICES):
names |= {n for n in os.listdir(SERVICES)
if os.path.isdir(os.path.join(SERVICES, n)) and not is_ours(n)
and re.fullmatch(FIELDS["name"], n)}
lib = os.path.join(FEDERATED, "lib")
if os.path.isdir(lib):
names |= {n[:-3] for n in os.listdir(lib)
if n.endswith(".sh") and re.fullmatch(FIELDS["name"], n[:-3])}
return names
def plan(m, origin=None, downgrade=False, drop_database=False): def plan(m, origin=None, downgrade=False, drop_database=False):
"""What installing m would do here, or Refused.""" """What installing m would do here, or Refused."""
name = m["name"] name = m["name"]
domain, tier = federated_settings() domain, tier = federated_settings()
if not domain: if not domain:
raise Refused("This Core isn't provisioned yet (no DOMAIN in /etc/federated).") raise Refused("This Core isn't provisioned yet (no DOMAIN in /etc/federated).")
if os.path.exists(os.path.join(SERVICES, name)) and not is_ours(name): if name in federated_names():
raise Refused(f"This Core already has an app called '{name}' " state = ("installed" if os.path.isdir(os.path.join(APPS, name))
f"({service_value(os.path.join(SERVICES, name, 'service'), 'CONTAINER') or 'Federated'}). " else "not installed, but the Core can install it")
"Pick another name.") raise Refused(f"'{name}' is the name of one of Federated's apps on this Core ({state}). "
if os.path.exists(os.path.join(FEDERATED, "lib", name + ".sh")): "Pick another name (coreapp core lists the names that are taken).")
raise Refused(f"'{name}' is the name of one of Federated's apps. Pick another name.")
installed = os.path.isdir(os.path.join(APPS, name)) installed = os.path.isdir(os.path.join(APPS, name))
if installed and not is_ours(name): if installed and not is_ours(name):
raise Refused(f"/federated/apps/{name} exists but wasn't installed by coreapps.") raise Refused(f"/federated/apps/{name} exists but wasn't installed by coreapps.")
@@ -1543,6 +1557,8 @@ def core_info():
f"{os.cpu_count()} CPUs, {mem:.1f} GB memory")) f"{os.cpu_count()} CPUs, {mem:.1f} GB memory"))
rows.append(("Apps' disk", f"{disk.free / 1e9:.0f} GB free of {disk.total / 1e9:.0f} GB, " rows.append(("Apps' disk", f"{disk.free / 1e9:.0f} GB free of {disk.total / 1e9:.0f} GB, "
f"{fstype or '?'} (/data)")) f"{fstype or '?'} (/data)"))
rows.append(("Names apps can't use", ", ".join(sorted(federated_names() | RESERVED))
+ " (Federated's apps, installed or not, and the Core's host names)"))
rows.append(("Not offered", "Redis or other services, a second container, extra host names, " rows.append(("Not offered", "Redis or other services, a second container, extra host names, "
"public ports other than HTTPS, the Core's AI model")) "public ports other than HTTPS, the Core's AI model"))
for label, value in rows: for label, value in rows:
+11 -82
View File
@@ -84,7 +84,10 @@ that are read by shell and YAML:
- `name`: 2-31 lowercase letters, digits and `-`, starting with a letter, - `name`: 2-31 lowercase letters, digits and `-`, starting with a letter,
not ending with `-`. Names of Federated's own apps (nextcloud, gitea, not ending with `-`. Names of Federated's own apps (nextcloud, gitea,
...) and the Core's hostnames (www, mail, ...) are refused. listmonk, ..., including ones not installed) and the Core's hostnames
(www, mail, ...) are refused: check `coreapp core`'s "Names apps can't
use" before choosing one. For an app Federated also offers, use another
name (e.g. `listmonk-app`) and keep its usual `title`.
- `title`: up to 40 letters, digits, spaces and `. , ! ? ( ) & + _ -`. - `title`: up to 40 letters, digits, spaces and `. , ! ? ( ) & + _ -`.
- `description`: up to 200 characters, no `"`, `$`, backtick, `\`, `@` or - `description`: up to 200 characters, no `"`, `$`, backtick, `\`, `@` or
line breaks. line breaks.
@@ -323,87 +326,13 @@ Replace the example with the real app.
### 2b. An existing app (porting) ### 2b. An existing app (porting)
Work in the app's repository. Add `coreapp.toml` (copy the example above), Read [references/porting.md](references/porting.md) first: the checklist
and make the Dockerfile fit the Core: for making the app's Dockerfile fit the Core. In short: plain HTTP on `0.0.0.0:port`; its public
address from `APP_URL`, trusting `CORE_PROXY`; state in `/data`; the Core's
- **Listen on `0.0.0.0` and on `port`**, plain HTTP. No TLS in the app. variables mapped onto the app's settings, outright in an entrypoint that
- **Know its public address**: `APP_URL` (many apps need a "base URL" or ends by running the upstream one (and written at every start, for settings
"trusted host" setting). It's behind traefik, which sends the app keeps in its database); waiting for the database and Authelia at
`X-Forwarded-Proto: https` and `X-Forwarded-For`: set the app's "trusted startup; a non-root user; its own `icon.png`; one container.
proxies" to `CORE_PROXY` (so it logs and rate-limits by the real client
address), and turn on its "behind HTTPS" or secure-cookie setting if it
has one, since it sees plain HTTP itself.
- **Keep state in `/data`**: point upload folders, SQLite files and
generated keys there. If the app needs a directory structure under `/data`,
create it at startup (it starts empty).
- **Send mail with `needs = ["email"]`**, if the app sends any (password
resets, notifications): map `SMTP_*` onto its mail settings.
- **If the app also runs elsewhere** (a desktop or another server edition
sharing the Dockerfile), keep those working: choose the Core's behaviour
in the app when `CORE_DOMAIN` is set (the Core's variables become
defaults; the app's own explicit settings still win), not by changing
the Dockerfile's `ENV` or `ENTRYPOINT` for everyone. The Core builds the
`Dockerfile` at the repository's root. Where the app's settings have
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 '<app> ...'`) get
them too, not only the server started by the entrypoint.
- **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
an upstream image, set the app's variables outright rather than "only if
unset": the image's own `ENV` defaults (a SQLite path, a port) would win
otherwise, and on a Core nobody else sets them. (In the app's own code,
as above, the Core's values are defaults that the app's explicit
settings override: that's for its other editions, not upstream `ENV`.)
Before writing the entrypoint, look at how the upstream image starts
(`docker inspect -f '{{json .Config.Entrypoint}} {{json .Config.Cmd}}'
<image>`): end yours by running what it ran (`exec` its entrypoint with
`"$@"`, or `exec "$@"` when it only has a `CMD`).
- **Wait for what it needs at startup** if it only checks once: the
database may come up after the app on a reboot, and Authelia restarts
when the app's sign-in client is registered (on the first deploy, and
when `[sso]` changes). An app that fetches Authelia's discovery only at
startup then has no sign-in until restarted, so wait in the entrypoint,
with a time limit, e.g.
`until wget -qO /dev/null "$OIDC_ISSUER/.well-known/openid-configuration"; do sleep 2; done`
(and `nc -z "$DB_HOST" "$DB_PORT"` for the database).
- **Images without a shell** (built `FROM scratch` or distroless) can't run
an entrypoint script, and `coreapp shell` can't open one. Copy a static
busybox in and run the script with it:
```dockerfile
FROM busybox:1.37-musl AS busybox
FROM upstream/image:1.2.3
COPY --from=busybox /bin/busybox /bin/busybox
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/busybox", "sh", "/entrypoint.sh"]
```
(end it with `exec` and the upstream entrypoint; call tools as
`/bin/busybox mkdir ...`). Prefer this to a program of your own.
- **Run as a non-root user** if the image allows. `/data` is given to
whatever user the image runs as, so this is enough:
```dockerfile
RUN useradd --system --uid 1000 --home-dir /data app # Debian-based images
USER app
```
(`adduser -S -u 1000 -h /data app` on Alpine.) Many upstream images
already have a user; use it.
- **Give it its own `icon.png`**: the project's logo, square, as a PNG
(convert an SVG or ICO; 256x256 is good). The template's is a
placeholder. `coreapp deploy` and `publish` say if it's unusable, not
square or under 80 pixels; `publish` refuses one the Core can't use.
- **Answer on `health`** once ready (a dedicated health endpoint, or `/` if
it returns 2xx-4xx without signing in).
- **One container.** If the upstream project ships a compose file with
several services, keep only the app, use `needs = ["postgres"]` (or
`["mysql"]` for MySQL/MariaDB) for its database, and stop if it needs other services (see "Not available yet").
Keep the app's other files as they are; add `.dockerignore` entries for
`coreapp.toml`, `icon.png` and `.git` so they don't bust the build cache.
### 3. Deploy and test ### 3. Deploy and test
+104
View File
@@ -0,0 +1,104 @@
# Porting an existing app: the checklist
Read this when making an existing app (its own repository, or an upstream
image) into a Coreapp. SKILL.md has the workflow around it.
Work in the app's repository. Add `coreapp.toml` (copy the example in
SKILL.md), and make the Dockerfile fit the Core:
- **Listen on `0.0.0.0` and on `port`**, plain HTTP. No TLS in the app.
- **Know its public address**: `APP_URL` (many apps need a "base URL" or
"trusted host" setting). It's behind traefik, which sends
`X-Forwarded-Proto: https` and `X-Forwarded-For`: set the app's "trusted
proxies" to `CORE_PROXY` (so it logs and rate-limits by the real client
address), and turn on its "behind HTTPS" or secure-cookie setting if it
has one, since it sees plain HTTP itself.
- **Keep state in `/data`**: point upload folders, SQLite files and
generated keys there. If the app needs a directory structure under `/data`,
create it at startup (it starts empty).
- **Send mail with `needs = ["email"]`**, if the app sends any (password
resets, notifications): map `SMTP_*` onto its mail settings.
- **If the app also runs elsewhere** (a desktop or another server edition
sharing the Dockerfile), keep those working: choose the Core's behaviour
in the app when `CORE_DOMAIN` is set (the Core's variables become
defaults; the app's own explicit settings still win), not by changing
the Dockerfile's `ENV` or `ENTRYPOINT` for everyone. The Core builds the
`Dockerfile` at the repository's root. Where the app's settings have
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 '<app> ...'`) get
them too, not only the server started by the entrypoint.
- **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
an upstream image, set the app's variables outright rather than "only if
unset": the image's own `ENV` defaults (a SQLite path, a port) would win
otherwise, and on a Core nobody else sets them. (In the app's own code,
as above, the Core's values are defaults that the app's explicit
settings override: that's for its other editions, not upstream `ENV`.)
Before writing the entrypoint, look at how the upstream image starts
(`docker inspect -f '{{json .Config.Entrypoint}} {{json .Config.Cmd}}'
<image>`): end yours by running what it ran (`exec` its entrypoint with
`"$@"`, or `exec "$@"` when it only has a `CMD`).
- **Settings the app keeps in its database** (many apps store the base
URL, SMTP server or OIDC client in a settings table, edited in their
admin pages, and that table wins over environment variables): write the
ones the Core owns (its address, `SMTP_*`, `OIDC_*`, paths under
`/data`) at every start, after the app's migrations, with its own CLI or
API if it has one, else SQL as the app's database user (`psql` with the
`DB_*` variables). Change only those rows or fields, leave the rest to
the app's admins, and say in your report that edits to them in the app
are put back at the next start.
- **Wait for what it needs at startup** if it only checks once: the
database may come up after the app on a reboot, and Authelia restarts
when the app's sign-in client is registered (on the first deploy, and
when `[sso]` changes). An app that fetches Authelia's discovery only at
startup then has no sign-in until restarted, so wait in the entrypoint,
with a time limit, e.g.
`until wget -qO /dev/null "$OIDC_ISSUER/.well-known/openid-configuration" 2>/dev/null; do sleep 2; done`
(and `nc -z "$DB_HOST" "$DB_PORT"` for the database).
- **Images without a shell** (built `FROM scratch` or distroless) can't run
an entrypoint script, and `coreapp shell` can't open one. Copy a static
busybox in and run the script with it:
```dockerfile
FROM busybox:1.37-musl AS busybox
FROM upstream/image:1.2.3
COPY --from=busybox /bin/busybox /bin/busybox
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/busybox", "sh", "/entrypoint.sh"]
```
(end it with `exec` and the upstream entrypoint; call tools as
`/bin/busybox mkdir ...`). Prefer this to a program of your own.
- **Run as a non-root user** if the image allows. `/data` is given to
whatever user the image runs as, so this is enough:
```dockerfile
RUN useradd --system --uid 1000 --home-dir /data app # Debian-based images
USER app
```
(`adduser -S -u 1000 -h /data app` on Alpine.) Many upstream images
already have a user; use it. Upstream entrypoints often assume they start as
root (they `chown` folders and drop to a user from `PUID`/`PGID` with
`su-exec` or `gosu`): under `USER` set those variables to your user's
ids so it doesn't try to switch, and a harmless chown warning is fine.
If the image really can't run as another user, leave it as root and
say so.
- **Give it its own `icon.png`**: the project's logo, square, as a PNG
(convert an SVG or ICO; 256x256 is good). The template's is a
placeholder. `coreapp deploy` and `publish` say if it's unusable, not
square or under 80 pixels; `publish` refuses one the Core can't use.
- **Answer on `health`** once ready (a dedicated health endpoint, or `/` if
it returns 2xx-4xx without signing in).
- **One container.** If the upstream project ships a compose file with
several services, keep only the app, use `needs = ["postgres"]` (or
`["mysql"]` for MySQL/MariaDB) for its database, and stop if it needs other services (see "Not available yet").
Keep the app's other files as they are; add `.dockerignore` entries for
`coreapp.toml`, `icon.png` and `.git` so they don't bust the build cache.
If the app documents a minimum database version, set `[postgres]` or
`[mysql]` `min_version` to it, even when today's Core is far newer: it
keeps the app from installing on an older Core later.
+12 -2
View File
@@ -92,6 +92,14 @@ else gets the lowest role that can look around. How:
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".
- 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
order: a setting that names admins by email; its CLI or API at startup
(making `CORE_ADMIN_EMAIL` an admin before anyone signs in); and if the
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.
## Testing sign-in: coreapp signin ## Testing sign-in: coreapp signin
@@ -112,8 +120,10 @@ jar=$(mktemp) && coreapp signin --cookies "$jar" /login && curl -b "$jar" https:
``` ```
- A page with a sign-in button (a form with only hidden fields, such as a - A page with a sign-in button (a form with only hidden fields, such as a
CSRF token) is submitted as a person pressing it would; with several such CSRF token) is submitted as a person pressing it would. Forms with fields
forms, pick one with `--form <action>`. Don't add routes to the app just to fill (a password form beside the button) are ignored, so a page with
one button and a password form needs nothing more; only with several
buttons, pick one with `--form <action>`. Don't add routes to the app just
for the test. for the test.
- With `--cookies`, check what the test account may do: it should land as - With `--cookies`, check what the test account may do: it should land as
a read-only member. Keep the jar's path in one command, as above a read-only member. Keep the jar's path in one command, as above