update: a container's hint names the found version's own image, not :latest (fishmagic80 on X)

In Docker, Settings › About on the Daily channel said "0.1.4479 is out
… docker pull ghcr.io/yetone/magpie:latest". :latest is the newest
release (docker.yml), daily and stable the Daily and Stable channels'
(docker-daily.yml, docker-stable.yml), so :latest held 0.1.4504, not the
0.1.4479 announced; on Stable it is weeks apart. docker.yml writes every
release's own tag (ghcr.io/yetone/magpie:0.1.4479; checked on ghcr: 4479,
4395, latest, daily, stable, 0.1 all resolve, daily = 4479's digest).

update.Image(version) is that tag, and every place that printed the
command names it now, with "recreate the container from it" (a compose
file on :latest would otherwise run the old tag again):
- the GUI's Version row and Update pill (/api/update's new `image`,
  stuck "container"; app.js updateStuck);
- `magpie update` in a container (internal/cli);
- a Remote magpie row's tip for a container: UpdateRemotes now keeps the
  version it asked for on an "unsupported" answer too, so the tip names
  that version's image;
- i18n zh, zh-TW, ja, de for both strings;
- docs/docker (en, zh, ja): Updates says Settings › About names the
  version's own image and that latest may be ahead of the channel;
  llms-full and search indexes rebuilt (site/docs-index.mjs).

Run at this tree (mica, through mica-run):
- red on origin/main 14b6b9555 with the new tests copied in:
  TestUpdateInContainerSaysPullTheImage (cli: ":latest" in the error),
  TestRemoteMagpieAskedToFollow (gateway: Version v0.1.100, not the asked
  v0.1.200), update-stuck.test.cjs container cases and
  remote-update.test.cjs, both engines;
- green here: go test ./internal/update ./internal/cli, internal/gateway
  and internal/provider -run TestRemote*, internal/gui except
  TestGatewayModeListsNoOwnSessions, which fails the same on
  14b6b9555 alone (#7064);
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build, gofmt -l (nothing);
- node --test site/docker-tags.test.mjs; GUI files in chromium and
  webkit: update-stuck, remote-update, update-channel,
  update-stable-newest, update-release-page, update-check, lan-docker,
  i18n-keys, gui-de, gui-zh-tw, i18n-en-no-cjk (216 pass, 0 fail);
  gui-ja's "ja has every zh string" is red on main for another string
  (#7144).

Not run before the push: the full `go test -tags nogui ./...` (mote and
mica each had another session's full suite running); it runs after.
Not tried: a real container pulling the new tag. Not checked at runtime:
whether the version's image is already on ghcr; docker.yml pushes it in
~6 minutes, before the release is published, and a missing one makes
docker pull fail with "manifest unknown", not pull another version.
This commit is contained in:
yetone
2026-11-19 10:26:23 +08:00
parent 14b6b95556
commit 598bc45346
22 changed files with 125 additions and 48 deletions
+1 -1
View File
@@ -278,7 +278,7 @@ func updateCmd(args []string) error {
// the Docker image's /magpie, run as nonroot: the image is what is
// updated, and a replace would only fail with "permission denied"
if exe, err := updateExecutable(); err == nil && !update.Writable(filepath.Dir(exe)) && !updateCanElevate() && updateInContainer() {
return fmt.Errorf("this magpie runs in a container and can't replace itself; pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container")
return fmt.Errorf("this magpie runs in a container and can't replace itself; pull the image of %s (docker pull %s) and recreate the container from it", rel.Version, update.Image(rel.Version))
}
// a package manager's binary (Homebrew's, pacman's magpie-bin from
// the AUR, a .deb's): replaced under it, the manager's database names
+5 -3
View File
@@ -14,8 +14,10 @@ import (
)
// `magpie update` in the Docker image (/magpie, run as nonroot) failed with
// the rename's "permission denied"; it now says to pull the new image.
// Outside a container it goes on to the download as before.
// the rename's "permission denied"; it now says to pull the new image:
// the found release's own tag, not :latest, which on the Daily or Stable
// channel holds another release (fishmagic80 on X). Outside a container
// it goes on to the download as before.
func TestUpdateInContainerSaysPullTheImage(t *testing.T) {
if runtime.GOOS == "windows" || os.Geteuid() == 0 {
t.Skip("needs a folder this user may not write to")
@@ -44,7 +46,7 @@ func TestUpdateInContainerSaysPullTheImage(t *testing.T) {
updateInContainer = func() bool { return true }
err := updateCmd([]string{"update"})
if err == nil || !strings.Contains(err.Error(), "docker pull ghcr.io/yetone/magpie:latest") {
if err == nil || !strings.Contains(err.Error(), "the image of 0.1.11 (docker pull ghcr.io/yetone/magpie:0.1.11)") {
t.Fatalf("in a container: %v", err)
}
+4 -2
View File
@@ -212,13 +212,15 @@ func TestRemoteMagpieAskedToFollow(t *testing.T) {
t.Fatalf("the row: %+v %v", u, ok)
}
// it can't update itself: the row says why
// it can't update itself: the row says why, and keeps the version it
// was asked to go to, whose image a container's hint names
// (fishmagic80 on X)
a.mu.Lock()
a.out = provider.RemoteUpdate{State: "unsupported", Why: "container"}
a.mu.Unlock()
provider.ForgetRemoteUpdatesForTest()
provider.UpdateRemotes(ctx, "v0.1.200")
if u, ok := provider.RemoteUpdateOf("home", time.Now()); !ok || u.State != "unsupported" || u.Why != "container" {
if u, ok := provider.RemoteUpdateOf("home", time.Now()); !ok || u.State != "unsupported" || u.Why != "container" || u.Version != "v0.1.200" {
t.Fatalf("a container: %+v %v", u, ok)
}
+2 -1
View File
@@ -4610,7 +4610,8 @@ function servedAnew(u) {
function updateStuck(u) {
const p = u.packaged;
if (p) return p.command ? t("{manager} installed magpie ({pkg}), so {manager} updates it, not magpie: {cmd}", { manager: p.manager, pkg: p.package, cmd: p.command }) : t("{manager} installed magpie, so {manager} updates it, not magpie.", { manager: p.manager });
if (u.stuck === "container") return t("magpie runs in a container, so it can't update itself; pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.");
// the version's own image: latest, daily and stable may hold another (fishmagic80 on X)
if (u.stuck === "container") return t("magpie runs in a container, so it can't update itself; pull the image of {v} (docker pull {image}) and recreate the container from it.", { v: u.latest, image: u.image });
if (u.stuck === "not-writable") return t("magpie can't write to the folder it runs from ({dir}), so it can't update itself; move it to a folder you can write to and open it from there.", { dir: u.stuckDir || "" });
return u.stuck === "translocated"
? t("macOS is running magpie from a temporary copy, so it can't update itself; move magpie to Applications and open it from there.")
+8 -8
View File
@@ -2052,7 +2052,7 @@ const I18N = {
"update it there": "请在那台电脑上更新",
"That magpie is too old to be updated from here: update it on that computer once.": "那台 magpie 版本太旧,无法从这里更新:请在那台电脑上手动更新一次。",
"Updating it from here takes a gateway key with full access there; this provider's key is read-only or held.": "从这里更新它需要它那边一个拥有完全权限的网关密钥;此提供商的密钥是只读的或受限的。",
"It runs in a container: pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "它运行在容器中:请拉取新镜像(docker pull ghcr.io/yetone/magpie:latest)并重新创建容器。",
"It runs in a container: pull the image of {v} (docker pull {image}) and recreate the container from it.": "它运行在容器中:请拉取 {v} 的镜像(docker pull {image}),并用它重新创建容器。",
"{manager} installed it there: update it with {manager}.": "它是由 {manager} 安装的:请用 {manager} 更新。",
"{manager} installed it there: update it with {cmd}": "它是由 {manager} 安装的:请运行 {cmd} 更新",
"It was built from source: update it the way it was built.": "它是从源码构建的:请按构建方式更新。",
@@ -4313,7 +4313,7 @@ const I18N = {
"magpie can't write to the folder it runs from ({dir}), so it can't update itself; move it to a folder you can write to and open it from there.": "magpie 无法写入它所在的文件夹({dir}),所以无法自动更新;请把它移到你有写入权限的文件夹,再从那里打开。",
"{manager} installed magpie ({pkg}), so {manager} updates it, not magpie: {cmd}": "{manager} 安装了 magpie({pkg}),所以由 {manager} 更新它,而不是 magpie 自己:{cmd}",
"{manager} installed magpie, so {manager} updates it, not magpie.": "由 {manager} 安装的 magpie 由 {manager} 更新,而不是 magpie 自己。",
"magpie runs in a container, so it can't update itself; pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "magpie 运行在容器里,无法自动更新;请拉取新镜像(docker pull ghcr.io/yetone/magpie:latest)并重新创建容器。",
"magpie runs in a container, so it can't update itself; pull the image of {v} (docker pull {image}) and recreate the container from it.": "magpie 运行在容器里,无法自动更新;请拉取 {v} 的镜像(docker pull {image}),并用它重新创建容器。",
"Config folder": "配置目录",
"Log": "日志",
"What magpie has logged, to send with a bug report": "magpie 记下的日志,报告问题时可附上",
@@ -7544,7 +7544,7 @@ const I18N = {
"update it there": "請在那台電腦上更新",
"That magpie is too old to be updated from here: update it on that computer once.": "那台 magpie 版本太舊,無法從這裡更新:請在那台電腦上手動更新一次。",
"Updating it from here takes a gateway key with full access there; this provider's key is read-only or held.": "從這裡更新它需要它那邊一個擁有完整權限的閘道金鑰;此供應商的金鑰是唯讀的或受限的。",
"It runs in a container: pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "它執行在容器中:請拉取新映像(docker pull ghcr.io/yetone/magpie:latest)並重新建立容器。",
"It runs in a container: pull the image of {v} (docker pull {image}) and recreate the container from it.": "它執行在容器中:請拉取 {v} 的映像(docker pull {image}),並用它重新建立容器。",
"{manager} installed it there: update it with {manager}.": "它是由 {manager} 安裝的:請用 {manager} 更新。",
"{manager} installed it there: update it with {cmd}": "它是由 {manager} 安裝的:請執行 {cmd} 更新",
"It was built from source: update it the way it was built.": "它是從原始碼建置的:請依建置方式更新。",
@@ -9785,7 +9785,7 @@ const I18N = {
"magpie can't write to the folder it runs from ({dir}), so it can't update itself; move it to a folder you can write to and open it from there.": "magpie 無法寫入它所在的資料夾({dir}),所以無法自動更新;請把它移到你有寫入權限的資料夾,再從那裡開啟。",
"{manager} installed magpie ({pkg}), so {manager} updates it, not magpie: {cmd}": "{manager} 安裝了 magpie({pkg}),所以由 {manager} 更新它,而不是 magpie 自己:{cmd}",
"{manager} installed magpie, so {manager} updates it, not magpie.": "由 {manager} 安裝的 magpie 由 {manager} 更新,而不是 magpie 自己。",
"magpie runs in a container, so it can't update itself; pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "magpie 在容器中執行,無法自動更新;請拉取新映像(docker pull ghcr.io/yetone/magpie:latest)並重新建立容器。",
"magpie runs in a container, so it can't update itself; pull the image of {v} (docker pull {image}) and recreate the container from it.": "magpie 在容器中執行,無法自動更新;請拉取 {v} 的映像(docker pull {image}),並用它重新建立容器。",
"Config folder": "設定目錄",
"Log": "日誌",
"What magpie has logged, to send with a bug report": "magpie 記下的日誌,回報問題時可附上",
@@ -13003,7 +13003,7 @@ const I18N = {
"update it there": "あちらで更新してください",
"That magpie is too old to be updated from here: update it on that computer once.": "あちらの magpie は古いため、ここからは更新できません。一度あちらのコンピューターで更新してください。",
"Updating it from here takes a gateway key with full access there; this provider's key is read-only or held.": "ここから更新するには、あちらでフルアクセスのゲートウェイキーが必要です。このプロバイダーのキーは読み取り専用か制限付きです。",
"It runs in a container: pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "コンテナで動作しています。新しいイメージを取得し(docker pull ghcr.io/yetone/magpie:latest)、コンテナを作り直してください。",
"It runs in a container: pull the image of {v} (docker pull {image}) and recreate the container from it.": "コンテナで動作しています。{v} のイメージを取得し(docker pull {image})、そのイメージでコンテナを作り直してください。",
"{manager} installed it there: update it with {manager}.": "{manager} でインストールされています。{manager} で更新してください。",
"{manager} installed it there: update it with {cmd}": "{manager} でインストールされています。{cmd} で更新してください",
"It was built from source: update it the way it was built.": "ソースからビルドされています。ビルドした方法で更新してください。",
@@ -15266,7 +15266,7 @@ const I18N = {
"magpie can't write to the folder it runs from ({dir}), so it can't update itself; move it to a folder you can write to and open it from there.": "magpie は実行中のフォルダ({dir})に書き込めないため、自動アップデートできません。書き込み可能なフォルダに移動し、そこから開いてください。",
"{manager} installed magpie ({pkg}), so {manager} updates it, not magpie: {cmd}": "magpie は {manager} でインストールされている({pkg})ため、magpie ではなく {manager} がアップデートします:{cmd}",
"{manager} installed magpie, so {manager} updates it, not magpie.": "magpie は {manager} でインストールされているため、magpie ではなく {manager} がアップデートします。",
"magpie runs in a container, so it can't update itself; pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "magpie はコンテナで実行されているため、自動アップデートできません。新しいイメージを取得し(docker pull ghcr.io/yetone/magpie:latest)、コンテナを作り直してください。",
"magpie runs in a container, so it can't update itself; pull the image of {v} (docker pull {image}) and recreate the container from it.": "magpie はコンテナで実行されているため、自動アップデートできません。{v} のイメージを取得し(docker pull {image})、そのイメージでコンテナを作り直してください。",
"Config folder": "設定フォルダ",
"Log": "ログ",
"What magpie has logged, to send with a bug report": "magpie が記録したログ。不具合の報告に添えてください",
@@ -18505,7 +18505,7 @@ const I18N = {
"update it there": "dort aktualisieren",
"That magpie is too old to be updated from here: update it on that computer once.": "Jenes magpie ist zu alt, um von hier aktualisiert zu werden: Aktualisiere es einmal auf jenem Computer.",
"Updating it from here takes a gateway key with full access there; this provider's key is read-only or held.": "Um es von hier zu aktualisieren, braucht es dort einen Gateway-Schlüssel mit vollem Zugriff; der Schlüssel dieses Anbieters ist schreibgeschützt oder eingeschränkt.",
"It runs in a container: pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "Es läuft in einem Container: Lade das neue Image (docker pull ghcr.io/yetone/magpie:latest) und erstelle den Container neu.",
"It runs in a container: pull the image of {v} (docker pull {image}) and recreate the container from it.": "Es läuft in einem Container: Lade das Image von {v} (docker pull {image}) und erstelle den Container damit neu.",
"{manager} installed it there: update it with {manager}.": "{manager} hat es dort installiert: Aktualisiere es mit {manager}.",
"{manager} installed it there: update it with {cmd}": "{manager} hat es dort installiert: Aktualisiere es mit {cmd}",
"It was built from source: update it the way it was built.": "Es wurde aus dem Quellcode gebaut: Aktualisiere es so, wie es gebaut wurde.",
@@ -20768,7 +20768,7 @@ const I18N = {
"magpie can't write to the folder it runs from ({dir}), so it can't update itself; move it to a folder you can write to and open it from there.": "magpie kann nicht in den Ordner schreiben, aus dem es läuft ({dir}), und kann sich daher nicht selbst aktualisieren; verschieben Sie es in einen Ordner mit Schreibrechten und öffnen Sie es von dort.",
"{manager} installed magpie ({pkg}), so {manager} updates it, not magpie: {cmd}": "{manager} hat magpie installiert ({pkg}), daher aktualisiert {manager} es, nicht magpie: {cmd}",
"{manager} installed magpie, so {manager} updates it, not magpie.": "{manager} hat magpie installiert, daher aktualisiert {manager} es, nicht magpie.",
"magpie runs in a container, so it can't update itself; pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.": "magpie läuft in einem Container und kann sich daher nicht selbst aktualisieren; laden Sie das neue Image (docker pull ghcr.io/yetone/magpie:latest) und erstellen Sie den Container neu.",
"magpie runs in a container, so it can't update itself; pull the image of {v} (docker pull {image}) and recreate the container from it.": "magpie läuft in einem Container und kann sich daher nicht selbst aktualisieren; laden Sie das Image von {v} (docker pull {image}) und erstellen Sie den Container damit neu.",
"Config folder": "Konfigurationsordner",
"Log": "Protokoll",
"What magpie has logged, to send with a bug report": "Was magpie protokolliert hat, zum Mitschicken bei einem Fehlerbericht",
+3 -3
View File
@@ -51,7 +51,7 @@ const strings = [
"update it there",
"That magpie is too old to be updated from here: update it on that computer once.",
"Updating it from here takes a gateway key with full access there; this provider's key is read-only or held.",
"It runs in a container: pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.",
"It runs in a container: pull the image of {v} (docker pull {image}) and recreate the container from it.",
"{manager} installed it there: update it with {manager}.",
"{manager} installed it there: update it with {cmd}",
"It was built from source: update it the way it was built.",
@@ -60,7 +60,7 @@ const strings = [
const rows = [
remote("home", "Home", { remoteUpdate: { say: "updating to {v}", tip: strings[2], v: "v0.1.200" } }),
remote("nas", "NAS", { remoteUpdate: { say: "can't update itself", tip: strings[8] } }),
remote("nas", "NAS", { remoteUpdate: { say: "can't update itself", tip: strings[8], v: "v0.1.200", image: "ghcr.io/yetone/magpie:0.1.200" } }),
remote("arch", "Arch", { remoteUpdate: { say: "can't update itself", tip: strings[10], manager: "pacman", cmd: "yay -S magpie-bin" } }),
remote("lab", "Lab", { remoteUpdate: { say: "automatic updates off", tip: strings[4] } }),
remote("old", "Old", { remoteUpdate: { say: "update it there", tip: strings[6] } }),
@@ -89,7 +89,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const tip = await rup(name).getAttribute("title");
assert.ok(tip.length > 20, `${name}'s tip says why: ${tip}`);
}
assert.match(await rup("NAS").getAttribute("title"), /docker pull ghcr\.io\/yetone\/magpie:latest/);
assert.match(await rup("NAS").getAttribute("title"), /docker pull ghcr\.io\/yetone\/magpie:0\.1\.200[))]/);
assert.match(await rup("Arch").getAttribute("title"), /yay -S magpie-bin/);
assert.match(await rup("Arch").getAttribute("title"), /pacman/);
assert.match(await rup("Home").getAttribute("title"), /v0\.1\.200/);
+11 -8
View File
@@ -4,8 +4,9 @@
// version was out, and its Download opened the release page with nothing
// saying why. Both now say the folder magpie may not write to, in English,
// Chinese, Japanese and German, at a narrow window too. In a container (the
// Docker image's /magpie, run as nonroot) they say to pull the new image
// rather than to move magpie to another folder. No backend, the API is
// Docker image's /magpie, run as nonroot) they say to pull the new
// version's image, by its own tag, rather than to move magpie to another
// folder. No backend, the API is
// faked here.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -24,13 +25,15 @@ const words = {
};
const folder = { state: "available", current: "0.1.400", latest: "0.1.401", url: "https://github.com/yetone/magpie-releases/releases/tag/v0.1.401", stuck: "not-writable", stuckDir: DIR };
const container = { state: "available", current: "0.1.400", latest: "0.1.401", url: "https://github.com/yetone/magpie-releases/releases/tag/v0.1.401", stuck: "container" };
// on the Daily channel :latest held another release than the one out
// (fishmagic80 on X): the hint names the version's own image
const container = { state: "available", current: "0.1.400", latest: "0.1.401", channel: "daily", url: "https://github.com/yetone/magpie-releases/releases/tag/v0.1.401", stuck: "container", image: "ghcr.io/yetone/magpie:0.1.401" };
const pull = {
en: "magpie runs in a container, so it can't update itself; pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container.",
zh: "magpie 运行在容器里,无法自动更新;请拉取新镜像(docker pull ghcr.io/yetone/magpie:latest)并重新创建容器。",
"zh-TW": "magpie 在容器中執行,無法自動更新;請拉取新映像(docker pull ghcr.io/yetone/magpie:latest)並重新建立容器。",
ja: "magpie はコンテナで実行されているため、自動アップデートできません。新しいイメージを取得し(docker pull ghcr.io/yetone/magpie:latest)、コンテナを作り直してください。",
de: "magpie läuft in einem Container und kann sich daher nicht selbst aktualisieren; laden Sie das neue Image (docker pull ghcr.io/yetone/magpie:latest) und erstellen Sie den Container neu.",
en: "magpie runs in a container, so it can't update itself; pull the image of 0.1.401 (docker pull ghcr.io/yetone/magpie:0.1.401) and recreate the container from it.",
zh: "magpie 运行在容器里,无法自动更新;请拉取 0.1.401 的镜像(docker pull ghcr.io/yetone/magpie:0.1.401),并用它重新创建容器。",
"zh-TW": "magpie 在容器中執行,無法自動更新;請拉取 0.1.401 的映像(docker pull ghcr.io/yetone/magpie:0.1.401),並用它重新建立容器。",
ja: "magpie はコンテナで実行されているため、自動アップデートできません。0.1.401 のイメージを取得し(docker pull ghcr.io/yetone/magpie:0.1.401)、そのイメージでコンテナを作り直してください。",
de: "magpie läuft in einem Container und kann sich daher nicht selbst aktualisieren; laden Sie das Image von 0.1.401 (docker pull ghcr.io/yetone/magpie:0.1.401) und erstellen Sie den Container damit neu.",
};
const cases = [
{ name: "a magpie that can't write to its folder says why it can't update", update: folder, langs: ["en", "zh", "ja", "de"], why: (lang) => words[lang].why },
+7 -1
View File
@@ -138,7 +138,10 @@ type updateJSON struct {
// magpie and updates it (pacman's magpie-bin from the AUR, say), and
// the command that does
Packaged *packagedJSON `json:"packaged,omitempty"`
Retry bool `json:"retry,omitempty"` // error: a click downloads it again
// available, stuck "container": the image of the version out, its
// own tag (update.Image)
Image string `json:"image,omitempty"`
Retry bool `json:"retry,omitempty"` // error: a click downloads it again
// error: the download failed through this mirror (Settings' UpdateMirror),
// and GitHub itself may do (#893)
Mirror string `json:"mirror,omitempty"`
@@ -831,6 +834,9 @@ func (u *updater) jsonIn(lang string) updateJSON {
if u.stuck == "not-writable" {
j.StuckDir = u.exeDir
}
if u.stuck == "container" && u.latest != nil {
j.Image = update.Image(u.latest.Version)
}
if u.stuck == "package" && u.packaged != nil {
j.Packaged = &packagedJSON{Manager: u.packaged.Name(), Package: u.packaged.Package, Command: u.packaged.Command()}
}
+9 -5
View File
@@ -5,12 +5,16 @@ import (
"path/filepath"
"runtime"
"testing"
"github.com/yetone/magpie/internal/update"
)
// The Docker image runs /magpie as nonroot, in a folder it may not write
// to and with no password prompt, so the page said "move it to a folder you
// can write to" (/), which a container can't act on. In a container it says
// to pull the new image; outside one the folder is still named (#1277).
// to pull the new image, by the version's own tag: on the Daily channel
// :latest held another release than the one out (fishmagic80 on X).
// Outside one the folder is still named (#1277).
func TestUpdateInContainerSaysPullTheImage(t *testing.T) {
if runtime.GOOS == "windows" || os.Geteuid() == 0 {
t.Skip("needs a folder this user may not write to")
@@ -29,16 +33,16 @@ func TestUpdateInContainerSaysPullTheImage(t *testing.T) {
canElevate = func() bool { return false }
inContainer = func() bool { return true }
u := &updater{state: "available"}
u := &updater{state: "available", latest: &update.Release{Version: "0.1.4479"}, channel: "daily"}
u.placeExe(exe)
if j := u.json(); u.exe != "" || j.Stuck != "container" || j.StuckDir != "" {
if j := u.json(); u.exe != "" || j.Stuck != "container" || j.StuckDir != "" || j.Image != "ghcr.io/yetone/magpie:0.1.4479" {
t.Fatalf("in a container: exe %q, %+v", u.exe, j)
}
inContainer = func() bool { return false }
u = &updater{state: "available"}
u = &updater{state: "available", latest: &update.Release{Version: "0.1.4479"}}
u.placeExe(exe)
if j := u.json(); j.Stuck != "not-writable" || j.StuckDir != dir {
if j := u.json(); j.Stuck != "not-writable" || j.StuckDir != dir || j.Image != "" {
t.Fatalf("outside one: %+v", j)
}
+3 -1
View File
@@ -53,6 +53,7 @@ type remoteUpdateJSON struct {
V string `json:"v,omitempty"`
Manager string `json:"manager,omitempty"`
Cmd string `json:"cmd,omitempty"`
Image string `json:"image,omitempty"`
}
// remoteUpdateNote is what the Remote magpie id's row says of its last
@@ -75,7 +76,8 @@ func remoteUpdateNote(id string, now time.Time) *remoteUpdateJSON {
default:
switch u.Why {
case "container":
j.Tip = "It runs in a container: pull the new image (docker pull ghcr.io/yetone/magpie:latest) and recreate the container."
j.Tip = "It runs in a container: pull the image of {v} (docker pull {image}) and recreate the container from it."
j.Image = update.Image(u.Version)
case "package":
j.Tip = "{manager} installed it there: update it with {manager}."
if u.Command != "" {
+8 -1
View File
@@ -112,7 +112,7 @@ func TestRemoteUpdateNote(t *testing.T) {
say, tip string
}{
{provider.RemoteUpdate{State: "updating", Version: "v0.1.200"}, "updating to {v}", "{v}"},
{provider.RemoteUpdate{State: "unsupported", Why: "container"}, "can't update itself", "docker pull ghcr.io/yetone/magpie:latest"},
{provider.RemoteUpdate{State: "unsupported", Why: "container", Version: "0.1.4479"}, "can't update itself", "docker pull {image}"},
{provider.RemoteUpdate{State: "unsupported", Why: "package", Manager: "Homebrew", Command: "brew upgrade magpie"}, "can't update itself", "{cmd}"},
{provider.RemoteUpdate{State: "unsupported", Why: "not-writable"}, "can't update itself", "update it there"},
{provider.RemoteUpdate{State: "off"}, "automatic updates off", "turned off"},
@@ -126,6 +126,13 @@ func TestRemoteUpdateNote(t *testing.T) {
t.Errorf("%+v: %+v", c.out, j)
}
}
// a container is pointed at the image of the version it was asked to
// update to, by its own tag: :latest may hold another release
// (fishmagic80 on X)
provider.SetRemoteUpdateForTest("office", provider.RemoteUpdate{State: "unsupported", Why: "container", Version: "0.1.4479"})
if j := remoteUpdateNote("office", now); j == nil || j.V != "0.1.4479" || j.Image != "ghcr.io/yetone/magpie:0.1.4479" || strings.Contains(j.Tip, "latest") {
t.Errorf("container: %+v", j)
}
provider.SetRemoteUpdateForTest("office", provider.RemoteUpdate{State: "current"})
if j := remoteUpdateNote("office", now); j != nil {
t.Fatalf("current: %+v", j)
+4 -4
View File
@@ -37,8 +37,8 @@ type RemoteUpdate struct {
// old: a magpie from before RemoteUpdatePath; refused: the key isn't
// one of full access there
State string `json:"state"`
// Version is what the remote runs (as answered), or is updating to
// (kept here)
// Version is what the remote runs (as answered), or is updating to,
// or can't update itself to (kept here)
Version string `json:"version,omitempty"`
// Why it can't: container, package, not-writable, source
Why string `json:"why,omitempty"`
@@ -179,8 +179,8 @@ func UpdateRemotes(ctx context.Context, version string) {
return
}
out := AskRemoteUpdate(ctx, p, version)
if out.State == "updating" {
out.Version = version
if out.State == "updating" || out.State == "unsupported" {
out.Version = version // what it is updating to, or would: a container's hint names its image
}
log.Printf("remote magpie %s on %s, asked to update to %s: %s %s", remoteName(p), have, version, out.State, out.Why)
noteRemoteUpdate(p.ID, version, out, time.Now())
+17
View File
@@ -0,0 +1,17 @@
package update
import "strings"
// ImageRepo is magpie's Docker image (.github/workflows/docker.yml).
const ImageRepo = "ghcr.io/yetone/magpie"
// Image is the Docker image of release version: its own tag, which
// docker.yml writes for every release ("0.1.4479", no "v"). A magpie in a
// container names it when the update it found is out, since the floating
// tags hold other releases: latest is the newest release, daily and
// stable the Daily and Stable channels' (docker-daily.yml,
// docker-stable.yml), so `docker pull …:latest` on the Daily channel
// fetched a version other than the one announced (fishmagic80 on X).
func Image(version string) string {
return ImageRepo + ":" + strings.TrimPrefix(version, "v")
}
+33
View File
@@ -0,0 +1,33 @@
package update
import (
"os"
"regexp"
"testing"
)
// The image a magpie in a container names for a release is that
// release's own tag, the one docker.yml writes, never a floating tag
// (latest, daily, stable) that may hold another release (fishmagic80 on
// X: Daily found 0.1.4479 and the hint said :latest).
func TestImageIsTheReleasesOwnTag(t *testing.T) {
for in, want := range map[string]string{
"0.1.4479": "ghcr.io/yetone/magpie:0.1.4479",
"v0.1.4479": "ghcr.io/yetone/magpie:0.1.4479",
} {
if got := Image(in); got != want {
t.Errorf("Image(%q) = %q, want %q", in, got, want)
}
}
// docker.yml tags a release's image with its version, "v" taken off
y, err := os.ReadFile("../../.github/workflows/docker.yml")
if err != nil {
t.Fatal(err)
}
if !regexp.MustCompile(`V="\$\{GITHUB_REF_NAME#v\}"`).Match(y) || !regexp.MustCompile(`TAGS=\(-t "\$IMAGE:\$V"\)`).Match(y) {
t.Error("docker.yml no longer tags each release's image with its version; Image names a tag that isn't written")
}
if !regexp.MustCompile(`IMAGE: ghcr\.io/\$\{\{ github\.repository_owner \}\}/magpie`).Match(y) || ImageRepo != "ghcr.io/yetone/magpie" {
t.Error("the image docker.yml pushes isn't ImageRepo")
}
}
+3 -3
View File
@@ -29,7 +29,7 @@ e8f03915aaf12c386bd6254ccfacbe6dc7ae1544e0080bde67ce31b048a50ee0 docs/copilot.h
c2795244d9df800736d5be9042a45bca9358800b27521723e9a4f0604e7a8c43 docs/crush.html
d042047b8d4e480702a6986c52135154ded05388ff82e63f215d652ea55f0c6e docs/cursor-private-inference.html
cf2645267d38d072f0467a02f6888b3a8848b27c3b14fa2461cda904ab07b793 docs/deepseek.html
9a134818c5bc12a199f480a798d1b4e442ceca2f514462e4d9c03ca8154bff59 docs/docker.html
2c0344b89bcc3c7a33004261e53e96802618357f8f5b309405ba9f3fb67a1bca docs/docker.html
0df2e589a2a8d2f0a91344d79ba15eff4a63dbd4d26e9a24601fec9c61a1d90e docs/droid.html
4ea324a67bf788a62585120a5685a66c977f1fccd7bf2ca39a4f5f6dae63fa04 docs/ds-bot.html
1e11349a9456e75797816776f8f420de351683df7d2aaf09c18688aaf5d781b5 docs/empryo.html
@@ -80,7 +80,7 @@ f3b062404993ee53684e2282e28c21af93f13003e7d09a13e0a06efcf36d1634 docs/ja/craft-
07f679f11a97fa7e75130c5defef055b1abc142dbd15510b6ae9b67845817944 docs/ja/crush.html
478cf1f70d9a9d9730931c785aee1f72e38bc27b62b3c429fed5ef6e97b8b406 docs/ja/cursor-private-inference.html
1dce97081a8170168bc329f4f6c5cf555a207a8a90d375cb19de4c7ec9aba488 docs/ja/deepseek.html
0c98a501fdc62e144a412f01112777a5fb58a811c68cf936b8aa6868b20ae94e docs/ja/docker.html
88f23a4f1639412d41314e18dba803992e004a662cbca01613dbf4729a0d45c5 docs/ja/docker.html
e1b20bd4d38845588252a3b083f13517309bea5fbc4c1961f1a9a0291a870a44 docs/ja/droid.html
82360502ec915c659a80d388eeb3fe359e68d65a86b5e4dcb46fbbdeefc488c7 docs/ja/ds-bot.html
aa1c027a828a9f7cae0297aeb86e8d91759bf2cacb10875e56c1fe49f162a40c docs/ja/empryo.html
@@ -279,7 +279,7 @@ abf1ef4b505f95b1b1cb32c79ae311f236c8c67c3474e00fe779359a650238d4 docs/zh/copilo
a5b7151d7c21e4bb3f601c0c399d0e5a8de051ec7e342c552fd3883f589b66f4 docs/zh/crush.html
939171a143b339969019c6fa2cba7f983cb83220b21e08fcb2e49f958fcb7fd3 docs/zh/cursor-private-inference.html
69752603509b92a8c0dcda461b71b1e02e669de2f790f6e1ad50922090971dd2 docs/zh/deepseek.html
d14dbb01485d0fb44e16d794ce51afc1d2d3ca2ecdd3c4ee7f5e1268977d7acd docs/zh/docker.html
8e8ada5cbfa1e6062bb267432afa39fe4b14d7b2bfe6b34a48c23bd1200f45c5 docs/zh/docker.html
d282d59587baab9e6cdd4c1d36b69b9ceea9e2cd0b49d1537642fd529c7816a8 docs/zh/droid.html
e8bc868847eede8bcdf157f13e2508f91c790baee914cb3c8f2b1801bf2c5fc1 docs/zh/ds-bot.html
2665b5de3bc00d5a7f34ed318dcecc76cd136479ecd239f2623f76134f826850 docs/zh/empryo.html
+1 -1
View File
@@ -277,7 +277,7 @@ docker logs magpie</pre>
<ul>
<li><b>Health.</b> The image has a <code>HEALTHCHECK</code>: <code>magpie healthcheck</code> exits 0 while the gateway answers, under <code>serve</code> and <code>web</code> alike, so <code>docker ps</code> shows the container as healthy and Compose can wait for it with <code>depends_on: condition: service_healthy</code>.</li>
<li><b>Terminal.</b> <code>docker exec -it magpie bash</code>, or a NAS panel’s terminal, opens a shell with <code>magpie</code> on its PATH: <code>magpie providers</code>, <code>magpie models</code>, <code>magpie usage</code>, <code>magpie quota</code> and the rest of the <a href="https://github.com/yetone/magpie/blob/main/docs/reference.md">CLI</a>.</li>
<li><b>Updates.</b> Pull the new image and recreate the container on the same volume: <code>docker pull ghcr.io/yetone/magpie:latest</code>, then <code>docker rm -f magpie</code> and the same <code>docker run</code>, or <code>docker compose pull &amp;&amp; docker compose up -d</code>. magpie releases several times a day; for one update a day with Renovate or Watchtower, follow <code>daily</code> (with Renovate, pin its digest), or <code>stable</code> for one a week.</li>
<li><b>Updates.</b> Pull the new image and recreate the container on the same volume: <code>docker pull ghcr.io/yetone/magpie:latest</code>, then <code>docker rm -f magpie</code> and the same <code>docker run</code>, or <code>docker compose pull &amp;&amp; docker compose up -d</code>. magpie releases several times a day; for one update a day with Renovate or Watchtower, follow <code>daily</code> (with Renovate, pin its digest), or <code>stable</code> for one a week. When magpie finds an update, Settings › About names that version's own image (<code>docker pull ghcr.io/yetone/magpie:0.1.1150</code>): <code>latest</code> may hold a newer release than your update channel's; run the container from the tag you pulled.</li>
<li><b>Build it yourself.</b> <code>docker build -t magpie .</code> in a checkout of <a href="https://github.com/yetone/magpie">the repository</a> makes the same image.</li>
</ul>
+1 -1
View File
@@ -277,7 +277,7 @@ docker logs magpie</pre>
<ul>
<li><b>ヘルスチェック。</b>イメージには <code>HEALTHCHECK</code> があります。ゲートウェイが応答している間 <code>magpie healthcheck</code> は 0 で終わり、<code>serve</code> でも <code>web</code> でも同じです。<code>docker ps</code> は healthy と表示し、Compose は <code>depends_on: condition: service_healthy</code> で待てます。</li>
<li><b>ターミナル。</b><code>docker exec -it magpie bash</code> や NAS の管理画面のターミナルで、<code>magpie</code> が PATH にあるシェルが開きます:<code>magpie providers</code>、<code>magpie models</code>、<code>magpie usage</code>、<code>magpie quota</code> など、<a href="https://github.com/yetone/magpie/blob/main/docs/reference.md">CLI</a> のすべてが使えます。</li>
<li><b>更新。</b>新しいイメージを取得し、同じボリュームでコンテナを作り直します:<code>docker pull ghcr.io/yetone/magpie:latest</code> のあと <code>docker rm -f magpie</code> と同じ <code>docker run</code>、または <code>docker compose pull &amp;&amp; docker compose up -d</code>。magpie は 1 日に何度もリリースされます。Renovate や Watchtower で 1 日 1 回だけ更新するなら <code>daily</code> を(Renovate ではダイジェストを固定して)、週 1 回なら <code>stable</code> を使います。</li>
<li><b>更新。</b>新しいイメージを取得し、同じボリュームでコンテナを作り直します:<code>docker pull ghcr.io/yetone/magpie:latest</code> のあと <code>docker rm -f magpie</code> と同じ <code>docker run</code>、または <code>docker compose pull &amp;&amp; docker compose up -d</code>。magpie は 1 日に何度もリリースされます。Renovate や Watchtower で 1 日 1 回だけ更新するなら <code>daily</code> を(Renovate ではダイジェストを固定して)、週 1 回なら <code>stable</code> を使います。magpie が更新を見つけると、設定 › 情報にはそのバージョン自身のイメージが表示されます(<code>docker pull ghcr.io/yetone/magpie:0.1.1150</code>)。<code>latest</code> はアップデートチャンネルのものより新しいリリースのことがあるので、取得したタグでコンテナを起動してください。</li>
<li><b>自分でビルドする。</b><a href="https://github.com/yetone/magpie">リポジトリ</a>のチェックアウトで <code>docker build -t magpie .</code> を実行すると同じイメージができます。</li>
</ul>
+1 -1
View File
@@ -277,7 +277,7 @@ docker logs magpie</pre>
<ul>
<li><b>健康检查。</b>镜像带 <code>HEALTHCHECK</code>:网关能应答时 <code>magpie healthcheck</code> 返回 0,<code>serve</code> 和 <code>web</code> 都一样,所以 <code>docker ps</code> 会显示 healthy,Compose 可以用 <code>depends_on: condition: service_healthy</code> 等它。</li>
<li><b>终端。</b><code>docker exec -it magpie bash</code> 或 NAS 面板里的终端会打开一个 shell,<code>magpie</code> 在 PATH 里:<code>magpie providers</code>、<code>magpie models</code>、<code>magpie usage</code>、<code>magpie quota</code> 以及其他 <a href="https://github.com/yetone/magpie/blob/main/docs/reference.md">CLI 命令</a>。</li>
<li><b>更新。</b>拉取新镜像,在同一个数据卷上重新创建容器:<code>docker pull ghcr.io/yetone/magpie:latest</code>,然后 <code>docker rm -f magpie</code> 再执行同样的 <code>docker run</code>;或 <code>docker compose pull &amp;&amp; docker compose up -d</code>。magpie 一天会发好几个版本;用 Renovate 或 Watchtower 想一天只更新一次,就跟 <code>daily</code>(Renovate 请固定它的 digest),想一周一次就跟 <code>stable</code>。</li>
<li><b>更新。</b>拉取新镜像,在同一个数据卷上重新创建容器:<code>docker pull ghcr.io/yetone/magpie:latest</code>,然后 <code>docker rm -f magpie</code> 再执行同样的 <code>docker run</code>;或 <code>docker compose pull &amp;&amp; docker compose up -d</code>。magpie 一天会发好几个版本;用 Renovate 或 Watchtower 想一天只更新一次,就跟 <code>daily</code>(Renovate 请固定它的 digest),想一周一次就跟 <code>stable</code>。magpie 发现更新时,设置 › 关于里写的是那个版本自己的镜像(<code>docker pull ghcr.io/yetone/magpie:0.1.1150</code>):<code>latest</code> 可能比你的更新通道的版本更新;请用你拉取的那个标签运行容器。</li>
<li><b>自己构建。</b>在<a href="https://github.com/yetone/magpie">仓库</a>的检出目录里 <code>docker build -t magpie .</code> 得到同样的镜像。</li>
</ul>
+1 -1
View File
@@ -10920,7 +10920,7 @@ Then: `sudo chown -R 65532:65532 ./config`, `docker compose up -d`, open `http:/
- **Health..** The image has a `HEALTHCHECK`: `magpie healthcheck` exits 0 while the gateway answers, under `serve` and `web` alike, so `docker ps` shows the container as healthy and Compose can wait for it with `depends_on: condition: service_healthy`.
- **Terminal..** `docker exec -it magpie bash`, or a NAS panel’s terminal, opens a shell with `magpie` on its PATH: `magpie providers`, `magpie models`, `magpie usage`, `magpie quota` and the rest of the [CLI](https://github.com/yetone/magpie/blob/main/docs/reference.md).
- **Updates..** Pull the new image and recreate the container on the same volume: `docker pull ghcr.io/yetone/magpie:latest`, then `docker rm -f magpie` and the same `docker run`, or `docker compose pull && docker compose up -d`. magpie releases several times a day; for one update a day with Renovate or Watchtower, follow `daily` (with Renovate, pin its digest), or `stable` for one a week.
- **Updates..** Pull the new image and recreate the container on the same volume: `docker pull ghcr.io/yetone/magpie:latest`, then `docker rm -f magpie` and the same `docker run`, or `docker compose pull && docker compose up -d`. magpie releases several times a day; for one update a day with Renovate or Watchtower, follow `daily` (with Renovate, pin its digest), or `stable` for one a week. When magpie finds an update, Settings › About names that version's own image (`docker pull ghcr.io/yetone/magpie:0.1.1150`): `latest` may hold a newer release than your update channel's; run the container from the tag you pulled.
- **Build it yourself..** `docker build -t magpie .` in a checkout of [the repository](https://github.com/yetone/magpie) makes the same image.
Questions or a setup worth sharing? Ask on [Discord](https://discord.gg/vGSnD3ZKQF). The [reference](https://github.com/yetone/magpie/blob/main/docs/reference.md#docker) has the details.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long