docker: a stable tag that follows the desktop app's Stable channel

jorbenzhu on Discord (#feedback, 10-31): "建议 docker镜像 也提供 stable 类tag,
与桌面版保持同步的稳定版发布". The desktop app's Stable channel is chosen in
site/worker.js (stableOf: once a week the newest release out three days,
or an urgent one at once) and served at /api/latest?channel=stable. The
image had latest, a version's tags, 0.1, 0 and edge, nothing for Stable.

New .github/workflows/docker-stable.yml reads that feed, hourly and after
each Docker run, and points ghcr.io/yetone/magpie:stable at the image
docker.yml already built for that version (buildx imagetools create, no
build). It decides nothing itself, so the tag can't drift from the
desktop's pick. latest, edge and the version tags aren't touched. A feed
it can't read (or one naming no version) leaves the tag where it was,
with a warning; no image for the Stable version is a red run. Images are
compared by their platform manifests, so a run with nothing to do pushes
nothing. Docker docs (en, zh, ja) list the tag; worker.js's Stable
comment points to the workflow.

Run:
- actionlint on the workflow: ok.
- The step's script locally against the real feed and ghcr (create
  swapped for an echo): feed says 0.1.1327, :stable missing -> would
  create stable from 0.1.1327; feed 404 -> warning, exit 0; stable
  already the same manifests -> "already", exit 0; no image for the
  version -> exit 4 (red).
- node --test site/*.test.mjs on mote: 49 pass.

Not tried:
- the workflow on GitHub itself: it first runs on its schedule or after
  the next Docker run; I didn't dispatch it by hand. Its first run
  creates :stable.
- whether buildx imagetools create with one source keeps the index's
  digest (the compare is by platform manifests, so either way is fine).
This commit is contained in:
yetone
2026-10-31 11:51:01 +08:00
parent 79b4be4668
commit deabe0903e
5 changed files with 74 additions and 4 deletions
+69
View File
@@ -0,0 +1,69 @@
name: Docker stable
# ghcr.io/yetone/magpie:stable is the image of the desktop app's Stable
# release (Settings › Update channel › Stable; jorbenzhu on Discord). Which
# release that is, is decided in one place only, site/worker.js's stableOf
# (a weekly pick out three days, or an urgent release at once), and served
# at /api/latest?channel=stable. This only reads that answer and points
# :stable at the image already built for that version (docker.yml); it
# never builds, and never touches latest, edge or a version's tags. While
# the feed can't be read the tag stays where it was.
on:
schedule:
- cron: '23 * * * *'
# a release's image is pushed: an urgent one is Stable at once
workflow_run:
workflows: [Docker]
types: [completed]
workflow_dispatch:
concurrency:
group: docker-stable
cancel-in-progress: false
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/magpie
FEED: https://usemagpie.ai/api/latest?channel=stable
jobs:
stable:
if: github.repository == 'yetone/magpie' && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Point stable at the Stable release's image
run: |
set -euo pipefail
if ! BODY=$(curl -fsS --retry 3 --max-time 30 "$FEED"); then
echo "::warning::the Stable feed couldn't be read; $IMAGE:stable stays where it was"
exit 0
fi
V=$(jq -r '.version // empty' <<<"$BODY")
if [[ ! "$V" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::warning::the Stable feed named no release ($V); $IMAGE:stable stays where it was"
exit 0
fi
# an image is the platforms' manifests in it, however its index
# is written
digest() { docker buildx imagetools inspect "$1" --format '{{json .}}' | jq -er '[.manifest.manifests[]?.digest] | sort | join(",") | select(. != "")'; }
WANT=$(digest "$IMAGE:$V") # no image for the Stable release is a red run
HAVE=$(digest "$IMAGE:stable" 2>/dev/null || true)
if [[ "$HAVE" == "$WANT" ]]; then
echo "$IMAGE:stable is $V already ($WANT)"
exit 0
fi
docker buildx imagetools create -t "$IMAGE:stable" "$IMAGE:$V"
GOT=$(digest "$IMAGE:stable")
echo "$IMAGE:stable is now $V ($GOT, was ${HAVE:-none})"
test "$GOT" == "$WANT"
+1 -1
View File
@@ -90,7 +90,7 @@
<div class="table-wrap"><table>
<tr><td><b>Image</b></td><td><code>ghcr.io/yetone/magpie</code>, for <code>linux/amd64</code> and <code>linux/arm64</code></td></tr>
<tr><td><b>Tags</b></td><td><code>latest</code> (the newest release), <code>0.1.1150</code> (one release), <code>0.1</code>, <code>edge</code> (every change on <code>main</code>)</td></tr>
<tr><td><b>Tags</b></td><td><code>latest</code> (the newest release), <code>stable</code> (the desktop app's Stable channel: a release a week, out three days first, or an urgent one at once), <code>0.1.1150</code> (one release), <code>0.1</code>, <code>edge</code> (every change on <code>main</code>)</td></tr>
<tr><td><b>Ports</b></td><td><code>3425</code> the gateway agents call; <code>3430</code> the browser UI, when the container runs <code>magpie web</code>; it answers the gateway’s <code>/v1</code> routes too, so a reverse proxy needs only this port</td></tr>
<tr><td><b>Volume</b></td><td><code>/config</code>: providers, keys, sign-ins, plugins and usage</td></tr>
<tr><td><b>User</b></td><td>nonroot (uid 65532)</td></tr>
+1 -1
View File
@@ -90,7 +90,7 @@
<div class="table-wrap"><table>
<tr><td><b>イメージ</b></td><td><code>ghcr.io/yetone/magpie</code>(<code>linux/amd64</code> と <code>linux/arm64</code>)</td></tr>
<tr><td><b>タグ</b></td><td><code>latest</code>(最新リリース)、<code>0.1.1150</code>(特定のリリース)、<code>0.1</code>、<code>edge</code>(<code>main</code> の変更ごと)</td></tr>
<tr><td><b>タグ</b></td><td><code>latest</code>(最新リリース)、<code>stable</code>(デスクトップ版の Stable チャンネルと同じ:公開から 3 日たったリリースが週に 1 つ、緊急リリースはすぐ)、<code>0.1.1150</code>(特定のリリース)、<code>0.1</code>、<code>edge</code>(<code>main</code> の変更ごと)</td></tr>
<tr><td><b>ポート</b></td><td><code>3425</code> はエージェントが呼ぶゲートウェイ、<code>3430</code> はコンテナが <code>magpie web</code> を動かすときのブラウザ UI。ゲートウェイの <code>/v1</code> ルートにも応えるので、リバースプロキシはこのポートだけで足ります</td></tr>
<tr><td><b>ボリューム</b></td><td><code>/config</code>:プロバイダ、キー、サインイン、プラグイン、使用量</td></tr>
<tr><td><b>ユーザー</b></td><td>nonroot(uid 65532)</td></tr>
+1 -1
View File
@@ -90,7 +90,7 @@
<div class="table-wrap"><table>
<tr><td><b>镜像</b></td><td><code>ghcr.io/yetone/magpie</code>,支持 <code>linux/amd64</code> 和 <code>linux/arm64</code></td></tr>
<tr><td><b>标签</b></td><td><code>latest</code>(最新正式版)、<code>0.1.1150</code>(某个版本)、<code>0.1</code>、<code>edge</code>(<code>main</code> 上的每次改动)</td></tr>
<tr><td><b>标签</b></td><td><code>latest</code>(最新正式版)、<code>stable</code>(与桌面版的稳定版通道一致:每周一个已发布满三天的版本,紧急修复版立即跟上)、<code>0.1.1150</code>(某个版本)、<code>0.1</code>、<code>edge</code>(<code>main</code> 上的每次改动)</td></tr>
<tr><td><b>端口</b></td><td><code>3425</code> 是 Agent 调用的网关;<code>3430</code> 是容器运行 <code>magpie web</code> 时的 Web 界面;它也响应网关的 <code>/v1</code> 路由,所以反向代理只需转发这一个端口</td></tr>
<tr><td><b>数据卷</b></td><td><code>/config</code>:供应商、密钥、登录、插件和用量</td></tr>
<tr><td><b>用户</b></td><td>nonroot(uid 65532)</td></tr>
+2 -1
View File
@@ -558,7 +558,8 @@ async function releases(ctx, env) {
// first) and "notes:<UTC day>" each day's notes by version, which
// /api/notes reads for a range older than the hundred newest. Without the
// ledger, or one that doesn't reach back to the week's cut, Stable isn't
// known and the feed says so (503) rather than guess.
// known and the feed says so (503) rather than guess. The Docker image's
// stable tag follows this feed (.github/workflows/docker-stable.yml).
const DAY = 86400e3;
const SOAK = 3 * DAY;
const LEDGER_DAYS = 45;