From deabe0903eb7d87af47a52121d2b8832b596a8f1 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 31 Oct 2026 11:51:01 +0800 Subject: [PATCH] docker: a stable tag that follows the desktop app's Stable channel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- .github/workflows/docker-stable.yml | 69 +++++++++++++++++++++++++++++ site/public/docs/docker.html | 2 +- site/public/docs/ja/docker.html | 2 +- site/public/docs/zh/docker.html | 2 +- site/worker.js | 3 +- 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/docker-stable.yml diff --git a/.github/workflows/docker-stable.yml b/.github/workflows/docker-stable.yml new file mode 100644 index 000000000..b835385c5 --- /dev/null +++ b/.github/workflows/docker-stable.yml @@ -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" diff --git a/site/public/docs/docker.html b/site/public/docs/docker.html index 484e46045..fe123d377 100644 --- a/site/public/docs/docker.html +++ b/site/public/docs/docker.html @@ -90,7 +90,7 @@
- + diff --git a/site/public/docs/ja/docker.html b/site/public/docs/ja/docker.html index 6d1b08f26..f68156848 100644 --- a/site/public/docs/ja/docker.html +++ b/site/public/docs/ja/docker.html @@ -90,7 +90,7 @@
Imageghcr.io/yetone/magpie, for linux/amd64 and linux/arm64
Tagslatest (the newest release), 0.1.1150 (one release), 0.1, edge (every change on main)
Tagslatest (the newest release), stable (the desktop app's Stable channel: a release a week, out three days first, or an urgent one at once), 0.1.1150 (one release), 0.1, edge (every change on main)
Ports3425 the gateway agents call; 3430 the browser UI, when the container runs magpie web; it answers the gateway’s /v1 routes too, so a reverse proxy needs only this port
Volume/config: providers, keys, sign-ins, plugins and usage
Usernonroot (uid 65532)
- + diff --git a/site/public/docs/zh/docker.html b/site/public/docs/zh/docker.html index d65665e9e..089613ac6 100644 --- a/site/public/docs/zh/docker.html +++ b/site/public/docs/zh/docker.html @@ -90,7 +90,7 @@
イメージghcr.io/yetone/magpie(linux/amd64 と linux/arm64)
タグlatest(最新リリース)、0.1.1150(特定のリリース)、0.1、edge(main の変更ごと)
タグlatest(最新リリース)、stable(デスクトップ版の Stable チャンネルと同じ:公開から 3 日たったリリースが週に 1 つ、緊急リリースはすぐ)、0.1.1150(特定のリリース)、0.1、edge(main の変更ごと)
ポート3425 はエージェントが呼ぶゲートウェイ、3430 はコンテナが magpie web を動かすときのブラウザ UI。ゲートウェイの /v1 ルートにも応えるので、リバースプロキシはこのポートだけで足ります
ボリューム/config:プロバイダ、キー、サインイン、プラグイン、使用量
ユーザーnonroot(uid 65532)
- + diff --git a/site/worker.js b/site/worker.js index 2101bfebc..5dd7c293c 100644 --- a/site/worker.js +++ b/site/worker.js @@ -558,7 +558,8 @@ async function releases(ctx, env) { // first) and "notes:" 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;
镜像ghcr.io/yetone/magpie,支持 linux/amd64 和 linux/arm64
标签latest(最新正式版)、0.1.1150(某个版本)、0.1、edge(main 上的每次改动)
标签latest(最新正式版)、stable(与桌面版的稳定版通道一致:每周一个已发布满三天的版本,紧急修复版立即跟上)、0.1.1150(某个版本)、0.1、edge(main 上的每次改动)
端口3425 是 Agent 调用的网关;3430 是容器运行 magpie web 时的 Web 界面;它也响应网关的 /v1 路由,所以反向代理只需转发这一个端口
数据卷/config:供应商、密钥、登录、插件和用量
用户nonroot(uid 65532)