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
+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,
change nothing). Not "nothing until an admin grants access".
- 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
@@ -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
CSRF token) is submitted as a person pressing it would; with several such
forms, pick one with `--form <action>`. Don't add routes to the app just
CSRF token) is submitted as a person pressing it would. Forms with fields
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.
- 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