Pin a release's image by digest, and refuse downgrades without --downgrade
After pulling a release, coreapps records its registry digest and runs image:version@sha256:..., so a re-pushed tag can't change an installed app; installing that release again with another digest is refused. An older release than the installed one needs --downgrade (coreapps install/plan, coreapp install), since it may not understand the newer one's data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -305,10 +305,21 @@ Steps:
|
|||||||
on the Core
|
on the Core
|
||||||
- [ ] Tokens per host+owner, if a Core needs several accounts on one host
|
- [ ] Tokens per host+owner, if a Core needs several accounts on one host
|
||||||
- [ ] Superpanel would manage these tokens
|
- [ ] Superpanel would manage these tokens
|
||||||
- [ ] Downgrades: installing an older tag is allowed (`@v1.0.0`); an app's
|
- Done 2026-12-03: downgrades and digests. Installing an older release
|
||||||
data may not survive that. Refuse, or warn?
|
than the installed one is refused unless `--downgrade` (coreapps
|
||||||
- [ ] Pin the image digest at install (from the registry at that moment)
|
install/plan, coreapp install; the plan says what it goes back from);
|
||||||
so a re-pushed tag can't change what's installed
|
a failed start still rolls back. After pulling a release, coreapps
|
||||||
|
records its registry digest in the marker and `.env`
|
||||||
|
(`IMAGE_DIGEST=@sha256:...`, written by coreapps, not `templatize`,
|
||||||
|
which reads any `@...@` on a line as a variable), and the compose
|
||||||
|
file runs `image:${IMAGE_VERSION}${IMAGE_DIGEST:-}`, so a re-pushed
|
||||||
|
tag can't change an installed app, even on a recreate; installing the
|
||||||
|
same release again with another digest is refused and the tag is put
|
||||||
|
back on the installed image. Folder deploys have it empty. Tested on
|
||||||
|
dev.fedcom.net with a registry on the Core and a `file://` repository
|
||||||
|
(install, refusal, `--downgrade`, upgrade, re-pushed tag refused,
|
||||||
|
recreate), with pub-test from gitea.federated.computer (pinned), and
|
||||||
|
hello (empty)
|
||||||
4. Email (2026-12-03): `needs = ["email"]` (`coreapp new --email`) gives
|
4. Email (2026-12-03): `needs = ["email"]` (`coreapp new --email`) gives
|
||||||
the app its own mail account for sending: an LDAP entry
|
the app its own mail account for sending: an LDAP entry
|
||||||
`uid=coreapp-<name>,ou=people` with `objectClass: account`,
|
`uid=coreapp-<name>,ou=people` with `objectClass: account`,
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ each new app explains the files and the settings it gets.
|
|||||||
| `coreapp signin [path]` | Sign in to it as a browser would, with the Core's test account (`coreapp.test@<domain>`, made on the VM's Core when first needed), starting at `path` (default `/login`), and show each step; `--cookies <file>` keeps the app's cookies, `--code` gets a code for apps that start sign-in in the browser, `--remove-account` removes the account |
|
| `coreapp signin [path]` | Sign in to it as a browser would, with the Core's test account (`coreapp.test@<domain>`, made on the VM's Core when first needed), starting at `path` (default `/login`), and show each step; `--cookies <file>` keeps the app's cookies, `--code` gets a code for apps that start sign-in in the browser, `--remove-account` removes the account |
|
||||||
| `coreapp status` / `logs [-f]` / `shell [command]` | Its container, its log, a shell in it (or one command, without a terminal) |
|
| `coreapp status` / `logs [-f]` / `shell [command]` | Its container, its log, a shell in it (or one command, without a terminal) |
|
||||||
| `coreapp list` | The apps on the Core installed this way |
|
| `coreapp list` | The apps on the Core installed this way |
|
||||||
| `coreapp install <https://host/owner/repo>[@tag]` | Install a published app from its repository on the Core, as its owner would: shows what it is and needs, asks, then installs (default: the newest release tag) |
|
| `coreapp install [--downgrade] <https://host/owner/repo>[@tag]` | Install a published app from its repository on the Core, as its owner would: shows what it is and needs, asks, then installs (default: the newest release tag; an older release than the installed one only with `--downgrade`) |
|
||||||
| `coreapp update <name>` | Update an app installed from a repository to its newest release |
|
| `coreapp update <name>` | Update an app installed from a repository to its newest release |
|
||||||
| `coreapp login <host>` / `logout <host>` / `logins` | Give the Core a token for private apps from a host (asks for the user and token), forget it, list them |
|
| `coreapp login <host>` / `logout <host>` / `logins` | Give the Core a token for private apps from a host (asks for the user and token), forget it, list them |
|
||||||
| `coreapp publish [--platform <list>]` | Build the release image, push it to the registry in `coreapp.toml` (`image:version`, never replacing a published version) and tag the commit `v<version>` |
|
| `coreapp publish [--platform <list>]` | Build the release image, push it to the registry in `coreapp.toml` (`image:version`, never replacing a published version) and tag the commit `v<version>` |
|
||||||
@@ -114,8 +114,13 @@ image can be private: `coreapp login gitea.example.com` gives the Core a
|
|||||||
token for that host (for Gitea, one with read access to repositories and
|
token for that host (for Gitea, one with read access to repositories and
|
||||||
packages), which the installer uses for the repository and the image. It
|
packages), which the installer uses for the repository and the image. It
|
||||||
keeps tokens in `/etc/coreapps/credentials` on the Core (root only); docker
|
keeps tokens in `/etc/coreapps/credentials` on the Core (root only); docker
|
||||||
gets the token only for each pull, so the Core keeps no docker login. This
|
gets the token only for each pull, so the Core keeps no docker login.
|
||||||
is what Superpanel's Coreapps screen would do.
|
The Core runs the image it pulled at install, by its digest
|
||||||
|
(`image:version@sha256:...`), so pushing the tag again can't change an
|
||||||
|
installed app; installing that release again then is refused. Installing an
|
||||||
|
older release than the installed one is refused too (it may not understand
|
||||||
|
the newer one's data) unless you add `--downgrade`. This is what
|
||||||
|
Superpanel's Coreapps screen would do.
|
||||||
|
|
||||||
Installing and removing go through the Core's own `installapp` and
|
Installing and removing go through the Core's own `installapp` and
|
||||||
`uninstallapp`, so the app shows up in Superpanel. The installer gives apps
|
`uninstallapp`, so the app shows up in Superpanel. The installer gives apps
|
||||||
|
|||||||
@@ -433,7 +433,23 @@ has a `coreapp.toml` with a published, public `image` (e.g. after
|
|||||||
`/federated/services/<name>/.coreapp` has `source`, `tag`, `commit`.
|
`/federated/services/<name>/.coreapp` has `source`, `tag`, `commit`.
|
||||||
2. Publish a newer version, then `coreapp update <name>`: "Updated", the
|
2. Publish a newer version, then `coreapp update <name>`: "Updated", the
|
||||||
old image is gone from the Core. Again: "at the newest release".
|
old image is gone from the Core. Again: "at the newest release".
|
||||||
3. `coreapp install <url>@v<old version>`: installs that tag.
|
3. `coreapp install <url>@v<old version>` with a newer one installed:
|
||||||
|
"is older, and may not understand the data ... add --downgrade", nothing
|
||||||
|
changed. `coreapp install --downgrade <url>@v<old version>`: the plan
|
||||||
|
says "Goes back from the installed v<new>", then installs that tag; the
|
||||||
|
newer image is gone from the Core.
|
||||||
|
3a. Digest: after installing, "Image: <image>:<version>@sha256:..."; the
|
||||||
|
marker has `digest=`, the `.env` `IMAGE_DIGEST=@sha256:...`, `docker
|
||||||
|
compose config --images` and the container's image are
|
||||||
|
`<image>:<version>@sha256:...`. Push another image to the same tag, then
|
||||||
|
install that release again: "isn't the image installed here ... the
|
||||||
|
release was changed after it was published", the app keeps running,
|
||||||
|
`<image>:<version>` on the Core is the installed image again, and
|
||||||
|
`docker compose up --force-recreate` runs it. An app deployed from a
|
||||||
|
folder has `IMAGE_DIGEST=` (empty) and runs `<image>:<version>`.
|
||||||
|
(Tested with a registry on the Core, `docker run -p 127.0.0.1:5000:5000
|
||||||
|
registry:2`, `image = "localhost:5000/<name>"`, and a `file://`
|
||||||
|
repository as below.)
|
||||||
4. Refused with a message, nothing changed:
|
4. Refused with a message, nothing changed:
|
||||||
- a URL with a password (`https://u:p@host/o/r`), `http://`, `ssh://`,
|
- a URL with a password (`https://u:p@host/o/r`), `http://`, `ssh://`,
|
||||||
or one level only (`https://host/repo`)
|
or one level only (`https://host/repo`)
|
||||||
@@ -459,8 +475,9 @@ has a `coreapp.toml` with a published, public `image` (e.g. after
|
|||||||
|
|
||||||
Without a public repository, the fetch can be tested on a local bare
|
Without a public repository, the fetch can be tested on a local bare
|
||||||
repository (`git config uploadpack.allowFilter true`) by loading
|
repository (`git config uploadpack.allowFilter true`) by loading
|
||||||
`core/coreapps` as a module and replacing `REPO_URL`, `normalize_url` and
|
`core/coreapps` as a module and replacing `REPO_URL`, `normalize_url`,
|
||||||
`GIT_ENV["GIT_ALLOW_PROTOCOL"]` for `file://` (only in the test).
|
`resolve` and `GIT_ENV["GIT_ALLOW_PROTOCOL"]` for `file://` (only in the
|
||||||
|
test).
|
||||||
|
|
||||||
## Publishing (coreapp publish)
|
## Publishing (coreapp publish)
|
||||||
|
|
||||||
|
|||||||
+14
-7
@@ -24,9 +24,11 @@
|
|||||||
# remove the test account from the Core
|
# remove the test account from the Core
|
||||||
# coreapp remove uninstall it from the Core (asks first)
|
# coreapp remove uninstall it from the Core (asks first)
|
||||||
# coreapp list the apps on the Core installed this way
|
# coreapp list the apps on the Core installed this way
|
||||||
# coreapp install <https://host/owner/repo>[@tag]
|
# coreapp install [--downgrade] <https://host/owner/repo>[@tag]
|
||||||
# install a published app from its repository, as
|
# install a published app from its repository, as
|
||||||
# a Core's owner would (shows what it needs first)
|
# a Core's owner would (shows what it needs first;
|
||||||
|
# --downgrade: allow an older release than the
|
||||||
|
# installed one)
|
||||||
# coreapp update <name> update an app installed from a repository to its
|
# coreapp update <name> update an app installed from a repository to its
|
||||||
# newest release
|
# newest release
|
||||||
# coreapp login <host> give the Core a token for private apps from host
|
# coreapp login <host> give the Core a token for private apps from host
|
||||||
@@ -410,14 +412,16 @@ cmd_list() {
|
|||||||
# --- install, update (published apps) -----------------------------------
|
# --- install, update (published apps) -----------------------------------
|
||||||
|
|
||||||
cmd_install() {
|
cmd_install() {
|
||||||
local source="${1:-}" plan key value answer addon=""
|
local source plan key value answer addon="" downgrade=""
|
||||||
local -A info=()
|
local -A info=()
|
||||||
|
if [[ "${1:-}" == --downgrade ]]; then downgrade=--downgrade; shift; fi
|
||||||
|
source="${1:-}"
|
||||||
[[ $# -eq 1 && "$source" == https://* ]] \
|
[[ $# -eq 1 && "$source" == https://* ]] \
|
||||||
|| die "Usage: coreapp install <https://host/owner/repo>[@tag] (default: its newest release)"
|
|| die "Usage: coreapp install [--downgrade] <https://host/owner/repo>[@tag] (default: its newest release)"
|
||||||
init_core
|
init_core
|
||||||
sync_installer
|
sync_installer
|
||||||
echo "Reading $source..."
|
echo "Reading $source..."
|
||||||
plan="$(core "$REMOTE_INSTALLER/coreapps plan $(printf '%q' "$source")")" || exit 1
|
plan="$(core "$REMOTE_INSTALLER/coreapps plan $downgrade $(printf '%q' "$source")")" || exit 1
|
||||||
while IFS='=' read -r key value; do info[$key]="$value"; done <<< "$plan"
|
while IFS='=' read -r key value; do info[$key]="$value"; done <<< "$plan"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@@ -425,7 +429,10 @@ cmd_install() {
|
|||||||
echo " From: ${info[source]} (${info[tag]}, commit ${info[commit]:0:12})"
|
echo " From: ${info[source]} (${info[tag]}, commit ${info[commit]:0:12})"
|
||||||
echo " Image: ${info[image]}:${info[version]}"
|
echo " Image: ${info[image]}:${info[version]}"
|
||||||
echo " Needs: ${info[needs]:-nothing from the Core}"
|
echo " Needs: ${info[needs]:-nothing from the Core}"
|
||||||
if [[ "${info[state]}" == update ]]; then
|
if [[ -n "${info[downgrade_from]:-}" ]]; then
|
||||||
|
echo " Goes back from the installed ${info[downgrade_from]}, keeping its settings and data,"
|
||||||
|
echo " which the older version may not understand."
|
||||||
|
elif [[ "${info[state]}" == update ]]; then
|
||||||
echo " Updates the installed ${info[name]}, keeping its settings and data."
|
echo " Updates the installed ${info[name]}, keeping its settings and data."
|
||||||
else
|
else
|
||||||
echo " Installs it at ${info[url]}"
|
echo " Installs it at ${info[url]}"
|
||||||
@@ -438,7 +445,7 @@ cmd_install() {
|
|||||||
fi
|
fi
|
||||||
read -r -p "Install it? [y/N] " answer
|
read -r -p "Install it? [y/N] " answer
|
||||||
[[ "$answer" =~ ^[Yy] ]] || die "Not installed."
|
[[ "$answer" =~ ^[Yy] ]] || die "Not installed."
|
||||||
core "$REMOTE_INSTALLER/coreapps install $addon $(printf '%q' "$source")"
|
core "$REMOTE_INSTALLER/coreapps install $addon $downgrade $(printf '%q' "$source")"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_update() {
|
cmd_update() {
|
||||||
|
|||||||
+80
-10
@@ -9,11 +9,12 @@ own templates, so what an app can do on the Core is decided here, not by
|
|||||||
whoever wrote the app.
|
whoever wrote the app.
|
||||||
|
|
||||||
coreapps manifest <dir> check <dir>/coreapp.toml, print its values
|
coreapps manifest <dir> check <dir>/coreapp.toml, print its values
|
||||||
coreapps plan <source> what install would do on this Core
|
coreapps plan [--downgrade] <source> what install would do on this Core
|
||||||
coreapps install [--addon-ok] [--recreate] <source>
|
coreapps install [--addon-ok] [--recreate] [--downgrade] <source>
|
||||||
install the app, or update it
|
install the app, or update it
|
||||||
(--recreate: a new container even if
|
(--recreate: a new container even if
|
||||||
nothing changed)
|
nothing changed; --downgrade: allow an
|
||||||
|
older release than the installed one)
|
||||||
coreapps update [--addon-ok] <name> update an app installed from a
|
coreapps update [--addon-ok] <name> update an app installed from a
|
||||||
repository to its newest release
|
repository to its newest release
|
||||||
coreapps remove <name> uninstall an app installed by coreapps
|
coreapps remove <name> uninstall an app installed by coreapps
|
||||||
@@ -413,6 +414,10 @@ def normalize_url(url):
|
|||||||
return f"{scheme}://{host.lower()}/{path}"
|
return f"{scheme}://{host.lower()}/{path}"
|
||||||
|
|
||||||
|
|
||||||
|
def is_release(tag):
|
||||||
|
return bool(re.fullmatch(r"v[0-9]+(?:\.[0-9]+)*", tag or ""))
|
||||||
|
|
||||||
|
|
||||||
def version_key(tag):
|
def version_key(tag):
|
||||||
return [int(part) for part in tag[1:].split(".")]
|
return [int(part) for part in tag[1:].split(".")]
|
||||||
|
|
||||||
@@ -528,7 +533,7 @@ def marker_value(name, key):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def plan(m, origin=None):
|
def plan(m, origin=None, downgrade=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()
|
||||||
@@ -565,6 +570,18 @@ def plan(m, origin=None):
|
|||||||
if origin and installed_from and installed_from != origin["source"]:
|
if origin and installed_from and installed_from != origin["source"]:
|
||||||
raise Refused(f"'{name}' on this Core was installed from {installed_from}, "
|
raise Refused(f"'{name}' on this Core was installed from {installed_from}, "
|
||||||
f"not {origin['source']}. Remove it first to install this one.")
|
f"not {origin['source']}. Remove it first to install this one.")
|
||||||
|
# An older release may not understand what the newer one left in
|
||||||
|
# its database and /data
|
||||||
|
installed_tag = marker_value(name, "tag")
|
||||||
|
if origin and is_release(installed_tag) and is_release(origin["tag"]) \
|
||||||
|
and version_key(origin["tag"]) < version_key(installed_tag):
|
||||||
|
if not downgrade:
|
||||||
|
raise Refused(
|
||||||
|
f"'{name}' has {installed_tag} installed; {origin['tag']} is older, and may "
|
||||||
|
"not understand the data the newer version left (its database and /data). "
|
||||||
|
"To install it anyway, add --downgrade (if it fails to start, the update "
|
||||||
|
"rolls back).")
|
||||||
|
p["downgrade_from"] = installed_tag
|
||||||
else:
|
else:
|
||||||
p["new_needs"] = list(m["needs"])
|
p["new_needs"] = list(m["needs"])
|
||||||
for key in ("source", "tag", "commit"):
|
for key in ("source", "tag", "commit"):
|
||||||
@@ -669,8 +686,8 @@ def make_service_folder(m, p, source, origin):
|
|||||||
write(os.path.join(new, MARKER),
|
write(os.path.join(new, MARKER),
|
||||||
"# Installed by coreapps; delete with coreapps remove\n"
|
"# Installed by coreapps; delete with coreapps remove\n"
|
||||||
f"needs={' '.join(m['needs'])}\n"
|
f"needs={' '.join(m['needs'])}\n"
|
||||||
+ "".join(f"{key}={origin[key]}\n" for key in ("source", "tag", "commit")
|
+ "".join(f"{key}={origin[key]}\n" for key in ("source", "tag", "commit", "digest")
|
||||||
if origin))
|
if origin and origin.get(key)))
|
||||||
shutil.rmtree(final, ignore_errors=True)
|
shutil.rmtree(final, ignore_errors=True)
|
||||||
os.rename(new, final)
|
os.rename(new, final)
|
||||||
|
|
||||||
@@ -726,6 +743,32 @@ def ensure_image(m, pull=False):
|
|||||||
+ (hint or " Is it published?"))
|
+ (hint or " Is it published?"))
|
||||||
|
|
||||||
|
|
||||||
|
def image_digest(m):
|
||||||
|
"""The registry's digest of the pulled image:version (sha256:...), or ""."""
|
||||||
|
out = run(["docker", "image", "inspect", "--format", "{{json .RepoDigests}}",
|
||||||
|
f"{m['image']}:{m['version']}"])
|
||||||
|
|
||||||
|
def short(repo):
|
||||||
|
return repo.removeprefix("docker.io/").removeprefix("library/")
|
||||||
|
try:
|
||||||
|
digests = json.loads(out.stdout) if out.returncode == 0 else []
|
||||||
|
except ValueError:
|
||||||
|
digests = []
|
||||||
|
for d in digests or []:
|
||||||
|
repo, _, digest = d.partition("@")
|
||||||
|
if short(repo) == short(m["image"]) and re.fullmatch(r"sha256:[0-9a-f]{64}", digest):
|
||||||
|
return digest
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def set_env(name, key, value):
|
||||||
|
"""key=value in the app's .env, replacing it or added at the end."""
|
||||||
|
path = f"{APPS}/{name}/.env"
|
||||||
|
with open(path) as f:
|
||||||
|
lines = [line for line in f.read().splitlines() if not line.startswith(key + "=")]
|
||||||
|
write(path, "\n".join(lines + [f"{key}={value}"]) + "\n", 0o600)
|
||||||
|
|
||||||
|
|
||||||
def image_user(ref):
|
def image_user(ref):
|
||||||
"""The uid:gid the image runs as, or None for root (or unknown)."""
|
"""The uid:gid the image runs as, or None for root (or unknown)."""
|
||||||
user = run(["docker", "image", "inspect", "-f", "{{.Config.User}}", ref]).stdout.strip()
|
user = run(["docker", "image", "inspect", "-f", "{{.Config.User}}", ref]).stdout.strip()
|
||||||
@@ -756,6 +799,9 @@ def prepare_data(m):
|
|||||||
def compose_up(m, log, recreate=False):
|
def compose_up(m, log, recreate=False):
|
||||||
name = m["name"]
|
name = m["name"]
|
||||||
prepare_data(m)
|
prepare_data(m)
|
||||||
|
# A release runs the image it was installed with (image:version@digest),
|
||||||
|
# even if the tag is pushed again; a folder's image by its tag
|
||||||
|
set_env(name, "IMAGE_DIGEST", "@" + m["digest"] if m.get("digest") else "")
|
||||||
run_logged(["docker", "compose", "-f", f"{APPS}/{name}/docker-compose.yml",
|
run_logged(["docker", "compose", "-f", f"{APPS}/{name}/docker-compose.yml",
|
||||||
"-p", name, "up", "-d", "--remove-orphans",
|
"-p", name, "up", "-d", "--remove-orphans",
|
||||||
*(["--force-recreate"] if recreate else [])], log,
|
*(["--force-recreate"] if recreate else [])], log,
|
||||||
@@ -793,12 +839,12 @@ done
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def install(arg, addon_ok, recreate=False):
|
def install(arg, addon_ok, recreate=False, downgrade=False):
|
||||||
with tempfile.TemporaryDirectory(prefix="coreapps-") as staging:
|
with tempfile.TemporaryDirectory(prefix="coreapps-") as staging:
|
||||||
folder, origin = resolve(arg, staging)
|
folder, origin = resolve(arg, staging)
|
||||||
m = read_manifest(folder)
|
m = read_manifest(folder)
|
||||||
check_release(m, origin)
|
check_release(m, origin)
|
||||||
p = plan(m, origin)
|
p = plan(m, origin, downgrade)
|
||||||
return install_app(m, p, folder, origin, addon_ok, recreate)
|
return install_app(m, p, folder, origin, addon_ok, recreate)
|
||||||
|
|
||||||
|
|
||||||
@@ -813,6 +859,8 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
|
|||||||
say(f"{m['title']} {m['version']} from {origin['source']} ({origin['tag']}, "
|
say(f"{m['title']} {m['version']} from {origin['source']} ({origin['tag']}, "
|
||||||
f"commit {origin['commit'][:12]})")
|
f"commit {origin['commit'][:12]})")
|
||||||
ensure_image(m, pull=bool(origin))
|
ensure_image(m, pull=bool(origin))
|
||||||
|
if origin:
|
||||||
|
pin_release(m, p, origin)
|
||||||
state, note = icon_check(folder)
|
state, note = icon_check(folder)
|
||||||
if state != "ok":
|
if state != "ok":
|
||||||
say(f"Note: {note}")
|
say(f"Note: {note}")
|
||||||
@@ -858,6 +906,26 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def pin_release(m, p, origin):
|
||||||
|
"""Record the pulled release's digest (m and the marker), or refuse if
|
||||||
|
the release installed here has changed in its registry since."""
|
||||||
|
name, ref = m["name"], f"{m['image']}:{m['version']}"
|
||||||
|
digest = image_digest(m)
|
||||||
|
if not digest:
|
||||||
|
raise Refused(f"Can't read the registry's digest of {ref}.")
|
||||||
|
before = marker_value(name, "digest") if p["state"] == "update" else ""
|
||||||
|
if before and before != digest and marker_value(name, "tag") == origin["tag"]:
|
||||||
|
# Put the tag back on the installed image, and drop the changed one
|
||||||
|
run(["docker", "tag", f"{m['image']}@{before}", ref])
|
||||||
|
run(["docker", "image", "rm", f"{m['image']}@{digest}"])
|
||||||
|
raise Refused(f"{ref} in its registry isn't the image installed here (installed "
|
||||||
|
f"{before[:19]}..., now {digest[:19]}...): the release was changed after "
|
||||||
|
f"it was published. {name} keeps running the installed one. A new "
|
||||||
|
"version should have a new tag.")
|
||||||
|
m["digest"] = origin["digest"] = digest
|
||||||
|
say(f"Image: {ref}@{digest}")
|
||||||
|
|
||||||
|
|
||||||
# Kept during an update, to put back if it fails
|
# Kept during an update, to put back if it fails
|
||||||
ROLLBACK_FILES = [".env", "docker-compose.yml"]
|
ROLLBACK_FILES = [".env", "docker-compose.yml"]
|
||||||
|
|
||||||
@@ -1261,12 +1329,14 @@ def main(args):
|
|||||||
return 0
|
return 0
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
raise Refused("Run coreapps as root on the Core.")
|
raise Refused("Run coreapps as root on the Core.")
|
||||||
|
downgrade = "--downgrade" in rest
|
||||||
|
rest = [a for a in rest if a != "--downgrade"]
|
||||||
if cmd == "plan" and len(rest) == 1:
|
if cmd == "plan" and len(rest) == 1:
|
||||||
with tempfile.TemporaryDirectory(prefix="coreapps-") as staging:
|
with tempfile.TemporaryDirectory(prefix="coreapps-") as staging:
|
||||||
folder, origin = resolve(rest[0], staging)
|
folder, origin = resolve(rest[0], staging)
|
||||||
m = read_manifest(folder)
|
m = read_manifest(folder)
|
||||||
check_release(m, origin)
|
check_release(m, origin)
|
||||||
p = plan(m, origin)
|
p = plan(m, origin, downgrade)
|
||||||
for key in ("name", "title", "description", "version", "image"):
|
for key in ("name", "title", "description", "version", "image"):
|
||||||
print(f"{key}={m[key]}")
|
print(f"{key}={m[key]}")
|
||||||
print(f"needs={' '.join(m['needs'])}")
|
print(f"needs={' '.join(m['needs'])}")
|
||||||
@@ -1278,7 +1348,7 @@ def main(args):
|
|||||||
recreate = "--recreate" in rest
|
recreate = "--recreate" in rest
|
||||||
folders = [a for a in rest if a not in ("--addon-ok", "--recreate")]
|
folders = [a for a in rest if a not in ("--addon-ok", "--recreate")]
|
||||||
if len(folders) == 1:
|
if len(folders) == 1:
|
||||||
return install(folders[0], addon_ok, recreate)
|
return install(folders[0], addon_ok, recreate, downgrade)
|
||||||
if cmd == "update" and rest:
|
if cmd == "update" and rest:
|
||||||
names = [a for a in rest if a != "--addon-ok"]
|
names = [a for a in rest if a != "--addon-ok"]
|
||||||
if len(names) == 1:
|
if len(names) == 1:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
{{NAME}}:
|
{{NAME}}:
|
||||||
image: @CONTAINER@:${IMAGE_VERSION}
|
image: @CONTAINER@:${IMAGE_VERSION}${IMAGE_DIGEST:-}
|
||||||
container_name: {{NAME}}
|
container_name: {{NAME}}
|
||||||
hostname: {{NAME}}.@DOMAIN@
|
hostname: {{NAME}}.@DOMAIN@
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
@@ -458,7 +458,11 @@ and image, the Core needs a token for the host first, `coreapp login
|
|||||||
only reads `coreapp.toml` and `icon.png` from the repository; `version` has
|
only reads `coreapp.toml` and `icon.png` from the repository; `version` has
|
||||||
to match the tag. On the same Core, `coreapp deploy` from the folder and
|
to match the tag. On the same Core, `coreapp deploy` from the folder and
|
||||||
`coreapp install` from the repository update the same app (same name, data
|
`coreapp install` from the repository update the same app (same name, data
|
||||||
and database).
|
and database). A Core keeps running the image it installed, by digest: a
|
||||||
|
release can't be fixed by pushing its tag again (installing it again is
|
||||||
|
refused), so publish a new version. Going back to an older release needs
|
||||||
|
`coreapp install --downgrade <url>@v<old>`; the user decides that, since
|
||||||
|
the older version may not understand the newer one's data.
|
||||||
|
|
||||||
## Reporting back
|
## Reporting back
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user