Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(update): 一键更新区分旧 compose 与固定版本号,更新后显示新运行版本

longmeidaoe98a66dd751e
diff --git a/docs/DOCKER.md b/docs/DOCKER.md
index b0921fa5b..15d1f3fb5 100644
--- a/docs/DOCKER.md
+++ b/docs/DOCKER.md
@@ -177,11 +177,11 @@ Watchtower 挂着宿主机的 Docker socket,能创建、停止任何容器,
3. 启动:`docker compose --profile watchtower up -d`。之后的 `docker compose` 命令都带上 `--profile watchtower`,或在 `.env` 写 `COMPOSE_PROFILES=watchtower`。
4. 在配置页「应用与维护 → 一键更新」填写地址 `http://watchtower:8080` 与令牌文件的内容,保存配置。令牌只保存在 `/data/secrets`,页面不再显示。
-检查更新发现新镜像后,「一键更新」替代两步命令。点击并确认后,Peach 会断开一会儿;新版本启动后页面提示刷新。15 分钟内没有看到新版本时,用 `docker compose logs watchtower` 和 `docker compose logs peach` 查看原因。
+检查更新发现新镜像后,「一键更新」替代两步命令。点击并确认后,Peach 会断开一会儿;新版本启动后页面提示刷新。15 分钟内没有看到新版本时,用 `docker compose logs watchtower` 和 `docker compose logs peach` 查看原因。已经在宿主机上 `docker compose pull` 过新镜像、还没 `up -d` 时,旧容器的镜像可能已失去标签,Watchtower 日志显示 `Failed to retrieve image info` 并跳过;这时直接运行 `docker compose up -d`。
Watchtower 不在新容器起不来时自动回退。换上新镜像后它删除被替下的旧镜像,免得每次更新在 NAS 上多留一份;指向同一镜像的其他本地标签也一起删除。Docker Hub 保留每个版本号标签,回滚时重新拉取。回滚到旧版本前,先停下 Peach,用升级时生成的 `ledger.pre-migrate-<时间>.db` 替换 `ledger.db`,再把 `.env` 的 `PEACH_VERSION` 设为旧版本号并 `docker compose up -d`;旧版本不会写入它不认识的数据库结构。方案取舍见 [ADR-0140](adr/0140-docker-one-click-update-via-watchtower.md)。
-2026-11-04 在 Windows 的 Docker Desktop(Engine 29.9.2)上,把本地 registry 的 `edge` 换成版本号更高、多一个空表迁移的测试镜像,经配置页接口触发后通过验收:Watchtower 按 75 秒停止超时停下旧容器,9 秒内起了新容器;`/data` 里的标记文件保留,启动前生成 `ledger.pre-migrate-*.db` 并执行了新迁移,`/healthz?ready=1` 通过,旧镜像已清理。不带 profile、没有令牌文件时 `docker compose up -d` 照常启动。Docker Hub 的真实拉取、ARM NAS 与 Docker Desktop 以外的 Linux 宿主机未取得。
+2026-11-04 在 Windows 的 Docker Desktop(Engine 29.9.2,containerd 镜像库)上,运行中容器的镜像只有 `edge` 一个本机标签,把本地 registry 的 `edge` 换成版本号更高、多一个空表迁移的测试镜像,经配置页触发后通过验收:Watchtower 自己拉取新镜像,按 75 秒停止超时停下旧容器,11 秒内起了新容器;`/data` 里的标记文件保留,启动前生成 `ledger.pre-migrate-*.db` 并执行了新迁移,`/healthz?ready=1` 通过,旧镜像已清理。不带 profile、没有令牌文件时 `docker compose up -d` 照常启动。Docker Hub 的真实拉取、ARM NAS 与 Docker Desktop 以外的 Linux 宿主机未取得。
Linux 容器不读取用户电脑上的浏览历史,也不包含交互式浏览器;需要本机浏览器完成验证的来源在此环境不可用。CloudDrive2 的真实账号登录、网盘流量与 NAS 实机挂载需在目标机器验证。
diff --git a/docs/dockerhub/README.md b/docs/dockerhub/README.md
index 1c622109e..93a2984e5 100644
--- a/docs/dockerhub/README.md
+++ b/docs/dockerhub/README.md
@@ -47,6 +47,10 @@ services:
init: true
restart: unless-stopped
stop_grace_period: 75s
+ environment:
+ PEACH_IMAGE_TAG: ${PEACH_VERSION:-edge}
+ labels:
+ com.centurylinklabs.watchtower.enable: "true"
ports:
- "${PEACH_BIND:-127.0.0.1}:${PEACH_PORT:-8900}:8900"
volumes:
@@ -99,7 +103,9 @@ On NAS container UIs, run `peach token` in the Peach container's terminal to get
## Updating
-Run `docker compose pull` and `docker compose up -d` again. Keep the `peach-data` volume: deleting it removes your settings, database and watch history. Hardware transcoding, CloudDrive2 networking, path mapping and diagnostics are covered in the [Docker guide](https://github.com/peach-mitao/peach/blob/master/docs/DOCKER.md).
+Run `docker compose pull` and `docker compose up -d` again. Keep the `peach-data` volume: deleting it removes your settings, database and watch history.
+
+To update from the settings page instead, run the optional Watchtower container from the repository's [`compose.yaml`](https://github.com/peach-mitao/peach/blob/master/compose.yaml) (`watchtower` profile) and enter its token under Settings → Maintenance → One-click update. Watchtower mounts the Docker socket, which gives it root-level control of the host; read the [one-click update section](https://github.com/peach-mitao/peach/blob/master/docs/DOCKER.md#一键更新可选-watchtower) before enabling it. Hardware transcoding, CloudDrive2 networking, path mapping and diagnostics are covered in the [Docker guide](https://github.com/peach-mitao/peach/blob/master/docs/DOCKER.md).
## License
diff --git a/frontend/src/react/settings/docker-update.tsx b/frontend/src/react/settings/docker-update.tsx
index c599fad54..5c6873f8d 100644
--- a/frontend/src/react/settings/docker-update.tsx
+++ b/frontend/src/react/settings/docker-update.tsx
@@ -90,9 +90,9 @@ export function DockerUpdateSettings({ state, onSaved, receipt }: {
<Input id="docker-update-token" type="password" label="Watchtower 令牌" autoComplete="off" maxLength={512}
value={token} onChange={setToken}
hint={state.token_set ? '已保存,留空不改。' : '与宿主机 secrets/watchtower-token 文件的内容一致。'} />
- {!state.rolling
- ? <Help>当前镜像标签是 {state.image_tag || '未取得'},Watchtower 只会换同一标签的新镜像。把 .env 的 PEACH_VERSION 删掉或改成 edge 后才能一键更新。</Help>
- : null}
+ {state.rolling ? null : state.image_tag
+ ? <Help>当前镜像标签是 {state.image_tag},Watchtower 只会换同一标签的新镜像。把 .env 的 PEACH_VERSION 删掉或改成 edge 后才能一键更新。</Help>
+ : <Help>容器里没有镜像标签,compose.yaml 可能还是旧版。换成仓库当前的 compose.yaml 后重建容器,才能一键更新。</Help>}
{action.error ? <ErrorText>{action.error}</ErrorText> : null}
</Stack>
<Footer>
diff --git a/frontend/src/react/settings/release-updates.tsx b/frontend/src/react/settings/release-updates.tsx
index 24254afd4..a45ed7ed0 100644
--- a/frontend/src/react/settings/release-updates.tsx
+++ b/frontend/src/react/settings/release-updates.tsx
@@ -104,7 +104,7 @@ export function ReleaseUpdates({ initial, initialJob, docker }: {
<Section id="releaseUpdates" guide="updates" title="检查更新" aside={<StatusLabel tone={error || data.state === 'error' || job.state === 'error' || container.job.state === 'timeout' ? 'error' : running || rebuilding ? 'progress' : container.job.state === 'done' ? 'success' : data.state === 'available' ? 'warning' : data.state === 'unchecked' ? 'neutral' : 'success'}>
{error || data.state === 'error' || job.state === 'error' ? '检查未完成' : container.job.state === 'timeout' ? '更新未完成' : running ? '准备更新中' : rebuilding ? '正在更新' : container.job.state === 'done' ? '已更新' : job.state === 'ready' ? '可安装' : data.state === 'available' ? '有可用更新' : data.state === 'unchecked' ? '尚未检查' : '检查完成'}</StatusLabel>}>
<FactList>
- <Fact term="当前版本">{data.current_version}</Fact>
+ <Fact term="当前版本">{container.job.state === 'done' ? container.job.version : data.current_version}</Fact>
<Fact term="安装方式">{data.installation}</Fact>
<Fact term="更新通道">{data.channel}</Fact>
<Fact term="最新版本">{data.latest_version || '未取得'}</Fact>
diff --git a/src/peach/docker_update.py b/src/peach/docker_update.py
index 86fc080b8..2bc3e1aec 100644
--- a/src/peach/docker_update.py
+++ b/src/peach/docker_update.py
@@ -117,7 +117,9 @@ def trigger(root: Path, *, transport: httpx.BaseTransport | None = None) -> dict
saved = values(root)
if not saved.get("token"):
raise ValueError("请先保存 Watchtower 令牌")
- if not describe(root)["rolling"]:
+ if not image_tag():
+ raise ValueError("容器里没有镜像标签,compose.yaml 可能还是旧版;换成仓库当前的 compose.yaml 后重建容器")
+ if image_tag() != ROLLING_TAG:
raise ValueError("镜像标签不是 edge,Watchtower 换不到新版本;请按下方步骤在宿主机上更新")
url = saved.get("url") or DEFAULT_URL
try:
diff --git a/tests/test_release_updates.py b/tests/test_release_updates.py
index 0d7eaf533..c771b8627 100644
--- a/tests/test_release_updates.py
+++ b/tests/test_release_updates.py
@@ -262,8 +262,9 @@ class DockerUpdateTests(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "令牌"):
docker_update.trigger(self.root, transport=transport)
docker_update.save(self.root, {"url": "http://watchtower:8080", "token": "s3cret"})
- with patch.dict("os.environ", {docker_update.IMAGE_TAG_ENV: "0.53.0"}):
- self.assertFalse(docker_update.ready(self.root))
- with self.assertRaisesRegex(ValueError, "edge"):
- docker_update.trigger(self.root, transport=transport)
+ for tag, message in (("0.53.0", "edge"), ("", "compose.yaml")):
+ with self.subTest(tag=tag), patch.dict("os.environ", {docker_update.IMAGE_TAG_ENV: tag}):
+ self.assertFalse(docker_update.ready(self.root))
+ with self.assertRaisesRegex(ValueError, message, msg="旧 compose 没传标签时要指向 compose 文件,不是 .env"):
+ docker_update.trigger(self.root, transport=transport)
self.assertEqual(requests, [], "换不到新版本时不打扰 Watchtower")
diff --git a/web/dist/peach-app.configuration-page-Bp9xqw7P.js b/web/dist/peach-app.configuration-page-DrYVxvix.js
similarity index 99%
rename from web/dist/peach-app.configuration-page-Bp9xqw7P.js
rename to web/dist/peach-app.configuration-page-DrYVxvix.js
index a2fd2a6d7..92fd6d17c 100644
--- a/web/dist/peach-app.configuration-page-Bp9xqw7P.js
+++ b/web/dist/peach-app.configuration-page-DrYVxvix.js
@@ -1,7 +1,7 @@
(function() {
try {
var e = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, t = new e.Error().stack;
- t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "d12779d0-b70d-4476-8688-11ba2bc2cfe4", e._sentryDebugIdIdentifier = "sentry-dbid-d12779d0-b70d-4476-8688-11ba2bc2cfe4");
+ t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "7e29bc25-ab84-42e6-a136-b98eb873a38a", e._sentryDebugIdIdentifier = "sentry-dbid-7e29bc25-ab84-42e6-a136-b98eb873a38a");
} catch {}
})();
import { AnimatedItems as e, Cell as t, ChartBackground as n, ChartContainer as r, ChartLegend as i, ChartLegendContent as a, ChartTip as o, ChartTooltip as s, ChartTooltipContent as c, Curve as l, DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME as u, DATA_ITEM_INDEX_ATTRIBUTE_NAME as d, DefaultZIndexes as f, EvilBarChart as p, LabelList as m, LabelListFromLabelProp as h, Layer as g, LoadingIndicator as _, PolarChart as v, PolarLabelContextProvider as y, PolarLabelListContextProvider as b, RegisterGraphicalItemId as x, Sector as S, SetPolarGraphicalItem as C, SetPolarLegendPayload as w, SetTooltipEntrySettings as T, Shape as ee, TIP_SWATCH as te, Text as ne, ZIndexLayer as re, adaptEventsOfChild as ie, arrayTooltipSearcher as ae, createSelector as oe, defaultPolarChartProps as se, findAllByType as ce, get as le, getClassNameFromUnknown as ue, getColorsCount as de, getMaxRadius as fe, getPercentValue as pe, getTooltipNameProp as me, getValueByDataKey as he, interpolate as ge, isNumber as _e, matchAppend as ve, mathSign as ye, polarToCartesian as be, resolveDefaultProps as xe, selectActiveTooltipDataKey as Se, selectActiveTooltipGraphicalItemId as Ce, selectActiveTooltipIndex as we, selectChartDataAndAlwaysIgnoreIndexes as Te, selectChartOffsetInternal as Ee, selectUnfilteredPolarItems as De, svgPropertiesNoEvents as Oe, svgPropertiesNoEventsFromUnknown as ke, tone as Ae, useAnimationCallbacks as je, useAppSelector as Me, useMouseClickItemDispatch as Ne, useMouseEnterItemDispatch as Pe, useMouseLeaveItemDispatch as Fe, usePolarChartLayout as Ie } from "./peach-app.chart-tip-CRxYp6KT.js";
@@ -791,11 +791,11 @@ function Ir({ state: e, onSaved: t, receipt: n }) {
onChange: o,
hint: e.token_set ? "已保存,留空不改。" : "与宿主机 secrets/watchtower-token 文件的内容一致。"
}),
- e.rolling ? null : /* @__PURE__ */ (0, Q.jsxs)(N, { children: [
+ e.rolling ? null : e.image_tag ? /* @__PURE__ */ (0, Q.jsxs)(N, { children: [
"当前镜像标签是 ",
- e.image_tag || "未取得",
+ e.image_tag,
",Watchtower 只会换同一标签的新镜像。把 .env 的 PEACH_VERSION 删掉或改成 edge 后才能一键更新。"
- ] }),
+ ] }) : /* @__PURE__ */ (0, Q.jsx)(N, { children: "容器里没有镜像标签,compose.yaml 可能还是旧版。换成仓库当前的 compose.yaml 后重建容器,才能一键更新。" }),
s.error ? /* @__PURE__ */ (0, Q.jsx)(k, { children: s.error }) : null
] }), /* @__PURE__ */ (0, Q.jsx)(M, { children: /* @__PURE__ */ (0, Q.jsx)(E, {
type: "submit",
@@ -2539,7 +2539,7 @@ function za({ initial: e, initialJob: t, docker: n }) {
/* @__PURE__ */ (0, Q.jsxs)(ut, { children: [
/* @__PURE__ */ (0, Q.jsx)(j, {
term: "当前版本",
- children: r.current_version
+ children: p.job.state === "done" ? p.job.version : r.current_version
}),
/* @__PURE__ */ (0, Q.jsx)(j, {
term: "安装方式",
@@ -5943,4 +5943,4 @@ function Bs({ data: e, receipt: t, reopenTutorial: n, section: r, diagnostics: i
}
export { Ls as ConfigurationPage };
-//# debugId=d12779d0-b70d-4476-8688-11ba2bc2cfe4
\ No newline at end of file
+//# debugId=7e29bc25-ab84-42e6-a136-b98eb873a38a
\ No newline at end of file