Snipe-IT rehearsal: slow starts, image volumes, HTML-as-text mail
Deploy waits up to 5 minutes for an app to answer, printing its last log line every 30 s, and stops early when the container exits or restarts three times. It notes VOLUMEs the image declares outside /data, and uninstall removes anonymous volumes (down -v). coreapp inbox renders HTML sent in a text/plain part. Skill: no first-come setup wizard even without sso (admin at startup, password by reset), no new sign-in code for apps without OIDC, upstream scripts that read shell variables, a step between upstream steps, the image's VOLUMEs, a slow first install, three-part min_version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -554,7 +554,28 @@ Steps:
|
||||
claims, testing a new account's first sign-in
|
||||
- [ ] David: sign in to leantime as admin@dev.fedcom.net (owner;
|
||||
a project, a task, an upload); remove it when done
|
||||
- [ ] A MySQL-only app, to rehearse `mysql`
|
||||
- Rehearsed 2026-12-04 with Snipe-IT (upstream Laravel image;
|
||||
mysql, email): deployed at `https://snipe-it.dev.fedcom.net/`,
|
||||
CORE_ADMIN_EMAIL made admin at startup (username `admin`, no known
|
||||
password; set by password reset), its setup wizard skipped, a reset
|
||||
mail read with `coreapp inbox`, the test account `coreapp.test`
|
||||
made there. No `sso`: Snipe-IT has no OpenID Connect sign-in (only
|
||||
passwords, LDAP and SAML), and writing one is out of scope. Fixed
|
||||
from it: deploy waited only 60 s for a first start that runs
|
||||
hundreds of migrations; it now waits 5 minutes, prints the app's
|
||||
last log line every 30 s, and stops early on a crash loop. Deploy
|
||||
notes an image's `VOLUME`s outside `/data` (Snipe-IT's storage),
|
||||
uninstall removes anonymous volumes (`down -v`), and `coreapp
|
||||
inbox` renders HTML sent as text/plain. Skill: no first-come
|
||||
setup wizard even without `sso` (admin at startup, password by
|
||||
reset), apps without OIDC aren't given sign-in code, upstream
|
||||
scripts that read shell variables, a step between upstream steps
|
||||
(run its migrations yourself, then `exec` it), the image's
|
||||
`VOLUME`s, a slow first install, `min_version` with three parts
|
||||
- [x] David: set admin's password by reset and signed in
|
||||
(2026-12-04)
|
||||
- [ ] David: in snipe-it, an asset and an upload; remove it when
|
||||
done
|
||||
- [ ] 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
|
||||
|
||||
@@ -258,6 +258,16 @@ The Core's own scripts trace secrets, so their output goes to
|
||||
deploys; breaking it again in an update gives the same message with
|
||||
the wget error, rolls back, and right after "Rolled back" the public
|
||||
address answers 200 (the rollback waits for traefik).
|
||||
5g. A slow start (`coreapp new slowtest`, with `CMD` sleeping 40 s,
|
||||
logging "migrating", before the server): deploy prints "still starting
|
||||
(31 s); its log: migrating", then "Installed". A container that exits
|
||||
or restarts three times stops the wait at once with its state and log;
|
||||
one that never answers stops after 5 minutes ("doesn't answer at ...
|
||||
after 300 s").
|
||||
5h. An image declaring `VOLUME /var/www/storage` (outside `/data`): deploy
|
||||
prints "Note: the image declares VOLUME /var/www/storage ..." and
|
||||
installs. `coreapp remove` removes its anonymous volume too (`docker
|
||||
volume ls -q` shows none left; uninstall runs `down -v`).
|
||||
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
|
||||
@@ -520,7 +530,8 @@ has the `DB_*` variables, `.coreapp` says `needs=postgres`.
|
||||
<supermarket@<domain>>", its subject and text with the `/reset/...`
|
||||
link. An HTML-only message shows as text, `Confirm
|
||||
<https://...>` for a link, without its `<style>`; an encoded subject
|
||||
(`=?utf-8?q?...`) is decoded. `--clear` says how many it removed, then
|
||||
(`=?utf-8?q?...`) is decoded, and so is a text/plain part that is
|
||||
really HTML (Snipe-IT's reset mail). `--clear` says how many it removed, then
|
||||
"inbox is empty". The test account's LDAP entry has
|
||||
`PostfixBookMailAccount`, `extensibleObject`, `mailEnabled: TRUE` and
|
||||
`homeDirectory: /home/coreapp.test` and no `uidNumber`; an entry made
|
||||
|
||||
+40
-4
@@ -778,6 +778,17 @@ def write(path, text, mode=0o644):
|
||||
ICON_LIMIT = 1024 * 1024
|
||||
|
||||
|
||||
def image_volumes(m):
|
||||
"""Paths outside /data that the app's image declares as VOLUMEs."""
|
||||
out = run(["docker", "image", "inspect", "-f", "{{json .Config.Volumes}}",
|
||||
f"{m['image']}:{m['version']}"]).stdout
|
||||
try:
|
||||
paths = sorted(json.loads(out) or {})
|
||||
except ValueError:
|
||||
return []
|
||||
return [p for p in paths if p.rstrip("/") != "/data" and not p.startswith("/data/")]
|
||||
|
||||
|
||||
def icon_check(folder):
|
||||
"""The app's icon.png: ("ok", "missing" or "bad", a note for the
|
||||
developer or "")."""
|
||||
@@ -1028,6 +1039,10 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
|
||||
state, note = icon_check(folder)
|
||||
if state != "ok":
|
||||
say(f"Note: {note}")
|
||||
for path in image_volumes(m):
|
||||
say(f"Note: the image declares VOLUME {path}. Docker gives that its own anonymous "
|
||||
"volume, which isn't the app's /data: it isn't backed up with the app or kept "
|
||||
"for a rollback. Point the app's files there at /data instead.")
|
||||
|
||||
if p["new_extensions"]:
|
||||
say(f"Enabling PostgreSQL extension(s) {', '.join(p['new_extensions'])} in "
|
||||
@@ -1425,6 +1440,10 @@ def remove_old_images(m):
|
||||
remove_images(m["image"], keep=m["version"])
|
||||
|
||||
|
||||
# How long deploy waits for an app to answer after starting it
|
||||
ANSWER_WAIT = 300
|
||||
|
||||
|
||||
def wait_until_answering(m, p):
|
||||
name = m["name"]
|
||||
url = f"http://{p['address']}:{m['port']}{m['health']}"
|
||||
@@ -1433,10 +1452,24 @@ def wait_until_answering(m, p):
|
||||
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()
|
||||
# A first start can take minutes (an app's database migrations), so
|
||||
# wait while the container runs, saying what it's doing now and then
|
||||
started = time.monotonic()
|
||||
shown = started
|
||||
while time.monotonic() - started < ANSWER_WAIT:
|
||||
state, _, restarts = run(["docker", "inspect", "-f", "{{.State.Status}} {{.RestartCount}}",
|
||||
name]).stdout.strip().partition(" ")
|
||||
if state not in ("running", "created", "restarting"):
|
||||
break
|
||||
if restarts.isdigit() and int(restarts) >= 3:
|
||||
state = f"{state}, restarted {restarts} times"
|
||||
break
|
||||
if time.monotonic() - shown >= 30:
|
||||
shown = time.monotonic()
|
||||
tail = run(["docker", "logs", "--tail", "1", name])
|
||||
line = " ".join((tail.stdout + tail.stderr).split())[:150]
|
||||
say(f" still starting ({time.monotonic() - started:.0f} s)"
|
||||
+ (f"; its log: {line}" if line else ""))
|
||||
try:
|
||||
with urllib.request.urlopen(urllib.request.Request(url, headers=headers),
|
||||
timeout=2) as r:
|
||||
@@ -1450,7 +1483,8 @@ def wait_until_answering(m, p):
|
||||
time.sleep(2)
|
||||
logs = run(["docker", "logs", "--tail", "20", name])
|
||||
sys.stderr.write(logs.stdout + logs.stderr)
|
||||
raise Refused(f"{name} doesn't answer at {url} (state: {state or 'missing'}; "
|
||||
raise Refused(f"{name} doesn't answer at {url} after "
|
||||
f"{time.monotonic() - started:.0f} s (state: {state or 'missing'}; "
|
||||
"its log is above).")
|
||||
|
||||
|
||||
@@ -1823,7 +1857,9 @@ def mail_text(message):
|
||||
content = part.get_content()
|
||||
except (LookupError, UnicodeError):
|
||||
content = part.get_payload(decode=True).decode("utf-8", "replace")
|
||||
if part.get_content_subtype() == "html":
|
||||
# Some apps put HTML in the part they label plain text (Snipe-IT)
|
||||
looks_html = re.match(r"\s*(<!doctype html|<html)", content, re.I)
|
||||
if part.get_content_subtype() == "html" or looks_html:
|
||||
parser = TextOfHTML()
|
||||
parser.feed(content)
|
||||
content = parser.text()
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Made by coreapps from the app's coreapp.toml. Sourced by the Core's
|
||||
# uninstallapp (so no `exit` here): stop the app, undo what it needed from
|
||||
# the Core, delete its settings and data.
|
||||
docker compose -f /federated/apps/{{NAME}}/docker-compose.yml -p {{NAME}} down
|
||||
# uninstallapp (so no `exit` here): stop the app (removing the anonymous
|
||||
# volumes its image declares), undo what it needed from the Core, delete its
|
||||
# settings and data.
|
||||
docker compose -f /federated/apps/{{NAME}}/docker-compose.yml -p {{NAME}} down -v
|
||||
for teardown in /federated/services/{{NAME}}/needs/*/teardown; do
|
||||
if [ -e "$teardown" ]; then . "$teardown"; fi
|
||||
done
|
||||
|
||||
@@ -100,8 +100,9 @@ that are read by shell and YAML:
|
||||
listens on; for a new app, 8080. It's only reachable inside the Core.
|
||||
- `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
|
||||
`X-Forwarded-Proto: https`, as traefik sends), and waits (up to 5
|
||||
minutes, showing the app's last log line every 30 seconds) 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.
|
||||
@@ -122,7 +123,7 @@ install it (with both versions in the message) instead of breaking later:
|
||||
|
||||
```toml
|
||||
[postgres]
|
||||
min_version = "16" # or [mysql] min_version = "11.4" (MariaDB's numbering)
|
||||
min_version = "16" # up to three parts; or [mysql] min_version = "10.6.2" (MariaDB's numbering)
|
||||
```
|
||||
|
||||
Use what the app's docs or code require, not just today's version.
|
||||
@@ -299,7 +300,11 @@ If the app can't work without one of these, say so plainly in your report
|
||||
rather than working around it; the gap is useful to know. The same goes for
|
||||
a need that doesn't fit the app (e.g. a sign-in `[sso]` can't describe):
|
||||
report it rather than writing a proxy, bridge or second service into the
|
||||
app's container. If it's optional
|
||||
app's container. That includes an app with no OpenID Connect sign-in
|
||||
(only passwords, LDAP, SAML or a fixed provider such as Google): writing
|
||||
new sign-in code into it is out of scope, so leave `sso` off and report
|
||||
it. A generic OAuth2 or OIDC provider setting the app already has is fine
|
||||
to point at Authelia. If it's optional
|
||||
(e.g. email notifications), leave it off and note it.
|
||||
|
||||
## Workflow
|
||||
|
||||
@@ -43,7 +43,18 @@ SKILL.md), and make the Dockerfile fit the Core:
|
||||
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`).
|
||||
`"$@"`, or `exec "$@"` when it only has a `CMD`). Read the upstream
|
||||
script: it may read settings from its own shell (`$SESSION_DRIVER`),
|
||||
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
|
||||
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}}'
|
||||
<image>`): Docker gives each its own anonymous volume, which isn't
|
||||
`/data` (not kept for a rollback, gone with the container). Point what
|
||||
the app keeps there at `/data`; deploy warns about any it finds.
|
||||
- **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
|
||||
@@ -112,6 +123,18 @@ SKILL.md), and make the Dockerfile fit the Core:
|
||||
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.
|
||||
|
||||
**First-run setup without `sso`.** The "no first-come owner" rule holds
|
||||
for every app: if the app has a setup wizard where whoever arrives first
|
||||
becomes the admin, skip it on a Core. Make `CORE_ADMIN_EMAIL` the admin at
|
||||
startup with a password nobody knows, and give the app `email` so that
|
||||
account sets its own password with the app's password reset; say so in
|
||||
your report.
|
||||
|
||||
**A slow first start.** Deploy waits up to 5 minutes for the app to
|
||||
answer. If its first install takes longer (hundreds of migrations), deploy
|
||||
says it's installed but not working; check `coreapp logs`, and once it's
|
||||
done, deploy again (it's an update then, and waits again).
|
||||
|
||||
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.
|
||||
|
||||
@@ -60,7 +60,7 @@ standard-library Python example of the whole flow (`oidc.py`).
|
||||
has none of them, so an app that reads the person only from the ID token
|
||||
gets no email or name: turn on its "use userinfo" setting. Requesting
|
||||
fewer scopes doesn't help (without `openid`, userinfo answers 403). If
|
||||
the app has no such setting, a small patch to its OIDC code that fills
|
||||
the app has no such setting, a small patch to its existing OIDC code that fills
|
||||
missing claims from userinfo (when its `sub` matches the ID token's) is
|
||||
fine: keep it as a patch file applied in the Dockerfile, say why in a
|
||||
comment, and name it in your report, since it's the app's own code. (The
|
||||
|
||||
Reference in New Issue
Block a user