Fixes from the second Supermarket run: database versions, health host
The rerun found Supermarket needs PostgreSQL 18 while the Core runs 17.6, which nothing had shown. The skill now gives the version and says to check the app's; coreapp status shows the Core's PostgreSQL/MariaDB version. Deploy's health check sends the app's Host, as traefik does; a same-version deploy says so. The skill covers making the owner at startup, building settings in the app's config loader, and checking mail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -425,6 +425,29 @@ Steps:
|
||||
to it
|
||||
- [ ] David: sign in to a `coreapp new --sso` app as admin in a
|
||||
browser ("the app's admin")
|
||||
- Run again 2026-12-03 with the updated skill, from a fresh clone (run
|
||||
1's Supermarket removed from the Core; commit a7777e6 in the new
|
||||
clone). It followed the new guidance unprompted: `CORE_DOMAIN` for
|
||||
Core behaviour, `CORE_ADMIN_EMAIL` made owner at startup and on each
|
||||
Core sign-in, `coreapp signin /signin` pressing the button. It found
|
||||
what run 1 missed: Supermarket needs PostgreSQL 18 (`LIKE` with its
|
||||
case-insensitive ICU collation) and the Core's is 17.6, so run 1's
|
||||
app would have failed on its first search; run 2 used the app's
|
||||
SQLite in `/data`. Fixed: the skill gives PostgreSQL's version and
|
||||
says to check the app's before choosing, with a newer server under
|
||||
"Not available yet" (SQLite in `/data` where the app has it);
|
||||
`coreapp status` shows the Core's PostgreSQL/MariaDB version;
|
||||
deploy's health check sends the app's `Host` (an app refusing
|
||||
unknown hosts passed on a 421 before); a same-version deploy says
|
||||
"(0.1.0 again, in a new container)"; the skill covers making the
|
||||
owner at startup, building differently shaped settings in the
|
||||
app's config loader, and checking mail (no inbox: logs, and the
|
||||
user)
|
||||
- [ ] David: what ordinary Core accounts get in an app (run 2 let
|
||||
any Core account join as a member who can view every module)
|
||||
- [ ] PostgreSQL 18 on the Core (Federated's), or a minimum version
|
||||
in coreapp.toml that the installer checks, so an app refuses to
|
||||
install on an older Core instead of failing later
|
||||
- [ ] David: the agent's changes, for Supermarket's own repository
|
||||
(and a login CSRF it noticed in the app's sign-in: its OIDC state
|
||||
isn't tied to a browser cookie)
|
||||
|
||||
@@ -203,10 +203,14 @@ The Core's own scripts trace secrets, so their output goes to
|
||||
the container is recreated, the page shows the change, `.env` is
|
||||
unchanged. `coreapp deploy` again: "The Core already has this image.",
|
||||
and the container is the same (`docker inspect -f '{{.Created}}'`);
|
||||
`coreapp deploy --recreate`: a new container, same data.
|
||||
`coreapp deploy --recreate`: "Updating hello (0.1.0 again, in a new
|
||||
container)...", a new container, same data.
|
||||
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.
|
||||
5a. An app that answers 421 to an unknown `Host` (Supermarket): deploy's
|
||||
wait passes because it sends `Host: <name>.<domain>`; on the Core, curl
|
||||
of its health URL gives 421 bare, 200 with that `Host`.
|
||||
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
|
||||
@@ -272,7 +276,9 @@ The Core's own scripts trace secrets, so their output goes to
|
||||
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`; `.env` has `DB_*`.
|
||||
owned by `coreapp_guest_book`; `.env` has `DB_*`. `coreapp status`:
|
||||
"The Core's PostgreSQL: 17.6" (`mysql` apps: "The Core's MariaDB:
|
||||
12.1.2").
|
||||
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
|
||||
|
||||
@@ -319,6 +319,14 @@ cmd_status() {
|
||||
address="$(core "sed -n 's/^INTERNAL_IP=//p' /federated/services/$NAME/service 2> /dev/null || true")"
|
||||
[[ -z "$address" ]] || echo "Address on the Core: $address, port $PORT"
|
||||
echo "Needs: ${NEEDS:-nothing}"
|
||||
# The Core's database servers (shared by its apps), for apps that need a
|
||||
# given version
|
||||
if [[ " $NEEDS " == *" postgres "* ]]; then
|
||||
echo "The Core's PostgreSQL: $(core "docker exec postgresql postgres --version 2> /dev/null | sed -n 's/^postgres (PostgreSQL) \([^ ]*\).*/\1/p'")"
|
||||
fi
|
||||
if [[ " $NEEDS " == *" mysql "* ]]; then
|
||||
echo "The Core's MariaDB: $(core "docker exec pdnsmysql mariadb --version 2> /dev/null | sed -n 's/.* \([0-9][0-9.]*\)-MariaDB.*/\1/p'")"
|
||||
fi
|
||||
echo "URL: https://$NAME.$domain/"
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -873,6 +873,10 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
|
||||
# installapp's start step only knows Federated's own apps
|
||||
compose_up(m, log)
|
||||
wait_until_answering(m, p)
|
||||
else:
|
||||
before = service_value(f"{APPS}/{name}/.env", "IMAGE_VERSION")
|
||||
if before == m["version"]:
|
||||
say(f"Updating {name} ({m['version']} again{', in a new container' if recreate else ''})...")
|
||||
else:
|
||||
say(f"Updating {name} to {m['version']}...")
|
||||
log = log_path(name, "update")
|
||||
@@ -1144,13 +1148,18 @@ def remove_old_images(m):
|
||||
def wait_until_answering(m, p):
|
||||
name = m["name"]
|
||||
url = f"http://{p['address']}:{m['port']}{m['health']}"
|
||||
# As traefik sends it, so apps that check the host name answer as they
|
||||
# will to people
|
||||
headers = {"Host": f"{name}.{p['domain']}", "X-Forwarded-Proto": "https",
|
||||
"X-Forwarded-Host": f"{name}.{p['domain']}"}
|
||||
say(f"Waiting for it to answer at {url}...")
|
||||
for _ in range(30):
|
||||
state = run(["docker", "inspect", "-f", "{{.State.Status}}", name]).stdout.strip()
|
||||
if state not in ("running", "created", "restarting"):
|
||||
break
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=2) as r:
|
||||
with urllib.request.urlopen(urllib.request.Request(url, headers=headers),
|
||||
timeout=2) as r:
|
||||
if 200 <= r.status < 400:
|
||||
return
|
||||
except urllib.error.HTTPError as e:
|
||||
|
||||
+28
-9
@@ -94,8 +94,10 @@ that are read by shell and YAML:
|
||||
- `version`: letters, digits, `.`, `_`, `-`.
|
||||
- `port`: a number, not a string. Use whatever port the app already
|
||||
listens on; for a new app, 8080. It's only reachable inside the Core.
|
||||
- `health`: a path starting with `/`. Deploy waits until it answers with
|
||||
any status below 500 (so `/` is fine for an app without a health
|
||||
- `health`: a path starting with `/`. Deploy asks for it on the app's
|
||||
address with the app's host name (`Host: <name>.<domain>`,
|
||||
`X-Forwarded-Proto: https`, as traefik sends), and waits until it answers
|
||||
with any status below 500 (so `/` is fine for an app without a health
|
||||
endpoint, even if it redirects to a sign-in page); `coreapp check` wants a
|
||||
2xx there, so prefer a path that returns 200 without signing in.
|
||||
- Unknown settings are refused, so a typo doesn't go unnoticed.
|
||||
@@ -115,8 +117,13 @@ The Core makes a PostgreSQL user and database just for this app, and adds:
|
||||
| `DB_NAME`, `DB_USER` | `coreapp_<name>` with `-` as `_` (e.g. `coreapp_my_app`) |
|
||||
| `DB_PASSWORD` | random |
|
||||
|
||||
The server is PostgreSQL shared with the Core's other apps; the app owns its
|
||||
database and nothing else. There's no superuser access, so the app creates
|
||||
The server is PostgreSQL 17 (17.6 today; `coreapp status` shows the Core's
|
||||
version), shared with the Core's other apps; the app owns its database and
|
||||
nothing else. Check what version the app needs before choosing this (its
|
||||
docs, its own compose file's `postgres:` image, its migrations): features
|
||||
of a newer PostgreSQL fail only when the code that uses them runs, so a
|
||||
deploy, `coreapp check` and a sign-in can all pass on the wrong version.
|
||||
If it needs a newer one, see "Not available yet". There's no superuser access, so the app creates
|
||||
its own tables (migrations at startup are the usual way). At boot the
|
||||
database may come up after the app: retry the connection instead of
|
||||
exiting. Many apps want a URL; build it from these variables in the
|
||||
@@ -201,7 +208,10 @@ may log; it should retry).
|
||||
the app, its next Core sign-in gives it back.
|
||||
|
||||
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. The example 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 one),
|
||||
make `CORE_ADMIN_EMAIL` the owner at startup, without a password; it
|
||||
signs in with the Core. The example app
|
||||
(`coreapp new --sso`) shows the check in `oidc.py`. `coreapp signin`
|
||||
signs in as the test account, not the admin, so ask the user to sign in
|
||||
once as `admin@<domain>` in a browser and check it gets the admin pages.
|
||||
@@ -238,11 +248,16 @@ Most apps have SMTP settings; map these onto them. Mail to `SMTP_FROM`
|
||||
isn't delivered anywhere (the account has no mailbox), so set a reply-to
|
||||
if people should be able to answer. The account can't sign in to anything
|
||||
else on the Core. `coreapp new --email` adds the need (there's no example
|
||||
app for it).
|
||||
app for it). There's no inbox to check that a test message arrived: send
|
||||
one the app's usual way (e.g. a password reset for `coreapp.test@<domain>`)
|
||||
and check `coreapp logs` for mail errors; ask the user to confirm delivery
|
||||
to a real address.
|
||||
|
||||
### Not available yet
|
||||
|
||||
The Core's AI features (offering
|
||||
A newer database server than the Core's (an app that needs PostgreSQL 18:
|
||||
if the app also supports SQLite, that in `/data` is a fine choice, and say
|
||||
so in your report), the Core's AI features (offering
|
||||
tools to its AI agent, or using its model), extra services such as Redis or
|
||||
a second container, extra hostnames, and public ports other than HTTPS.
|
||||
If the app can't work without one of these, say so plainly in your report
|
||||
@@ -296,7 +311,11 @@ and make the Dockerfile fit the Core:
|
||||
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.
|
||||
`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=...`). Set the app's own
|
||||
@@ -399,7 +418,7 @@ pages, and that the admin gets the admin role).
|
||||
|
||||
| Command | Shows |
|
||||
|---|---|
|
||||
| `coreapp status` | Its container, address, port, needs, URL |
|
||||
| `coreapp status` | Its container, address, port, needs, the Core's database version, URL |
|
||||
| `coreapp logs` / `coreapp logs -f` | The app's own log |
|
||||
| `coreapp signin [path]` | Signs in with the Core's test account and shows each step |
|
||||
| `coreapp shell '<command>'` | Run one command in its container, e.g. `coreapp shell 'id; env; ls -l /data'` (without a command it opens an interactive shell, which needs a terminal) |
|
||||
|
||||
Reference in New Issue
Block a user