diff --git a/Dockerfile b/Dockerfile index 1daa2a719..9199eac4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,31 +12,25 @@ RUN CGO_ENABLED=0 go build -tags nogui -trimpath \ -ldflags "-s -w -X main.version=${VERSION}" -o /out/magpie . \ && mkdir -p /config/home /config/cache /config/data /config/state -# A shell for the container's terminal: NAS panels (Synology, 1Panel, -# Portainer) open /bin/bash or /bin/sh, and distroless has neither, so a -# terminal there failed with "stat /bin/bash: no such file or directory". -# Debian 12's bash (with the libtinfo it links), which runs on the glibc of -# distroless's own Debian 12, and busybox for ls, cat and the like. -FROM debian:12-slim AS shell -RUN mkdir -p /out/bin /out/lib \ - && cp /bin/bash /out/bin/bash \ - && cp -L "$(ldd /bin/bash | awk '/libtinfo/ {print $3}')" /out/lib/ +# Debian, not distroless: a subscription's CLI is installed with its +# vendor's `curl … | bash` (Cursor, Devin, Grok Build), and the CLI it +# installs is a glibc binary that needs a full system's loader and +# libraries. distroless with a copied curl ran the installer, but Cursor's +# cursor-agent then failed with "cannot execute: required file not found". +# Debian 12 has the glibc, libgcc and libstdc++ the plugins' Bun needs too, +# and bash for a NAS panel's terminal. nonroot keeps distroless's uid 65532, +# so a volume made by an older image stays writable. +FROM debian:12-slim -FROM busybox:1.37-uclibc AS busybox - -# cc, not static: plugins run on Bun, which magpie downloads on first use -# and which needs glibc (static has no libc at all, and Bun's musl build -# would need musl). cc is static plus glibc, libgcc and libstdc++. -FROM gcr.io/distroless/cc-debian12:nonroot +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates curl \ + && rm -rf /var/lib/apt/lists/* \ + && groupadd -g 65532 nonroot \ + && useradd -u 65532 -g nonroot -d /config/home -s /bin/bash nonroot COPY --from=build /out/magpie /magpie -COPY --from=busybox /bin/busybox /bin/busybox -COPY --from=shell /out/bin/bash /bin/bash -COPY --from=shell /out/lib/ /usr/lib/ -# busybox's commands, and magpie on PATH, so `magpie accounts add …` works -# in that terminal -USER root -RUN ["/bin/busybox", "sh", "-c", "/bin/busybox --install -s /bin && mkdir -p /usr/local/bin && ln -s /magpie /usr/local/bin/magpie"] +# magpie on PATH, so `magpie accounts add …` works in that terminal +RUN ln -s /magpie /usr/local/bin/magpie USER nonroot COPY --from=build --chown=65532:65532 /config /config diff --git a/docs/reference.md b/docs/reference.md index bfd30b4f3..e1106c862 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -2230,9 +2230,10 @@ uses the service's gateway. ### Docker -`docker build` makes a server image: the terminal-only binary on -distroless (`cc`, for the glibc the plugins' Bun needs) with bash and -busybox for a terminal in the container (`docker exec -it magpie bash`, or a +`docker build` makes a server image: the terminal-only binary on Debian 12 +slim, with bash and curl, so a vendor's `curl … | bash` installer runs and +the CLI it installs (Cursor's, Devin's, Grok Build) finds the glibc it links, +as the plugins' Bun does, and a terminal opens in the container (`docker exec -it magpie bash`, or a NAS panel's terminal; `magpie` is on its PATH), run as nonroot, with everything it keeps in a volume at `/config`: magpie's own files (`/config/magpie`), the sign-ins kept where their agent keeps them (HOME is diff --git a/internal/provider/install.go b/internal/provider/install.go index 0bdfad9cb..ed0a351f5 100644 --- a/internal/provider/install.go +++ b/internal/provider/install.go @@ -22,7 +22,7 @@ import ( // agentCLI is a CLI a subscription runs through: how to find it, and the // vendor's install one-liners for a POSIX shell and for PowerShell. native, // when there is one, does what the shell one does without a shell, for a -// magpie with none (its Docker image has no bash, curl or wget). setup: the +// magpie with none (its Docker image had no bash, curl or wget until #2834). setup: the // installer ends by running the CLI's own setup, which asks how to sign in; // magpie signs in itself once the CLI is there. type agentCLI struct { @@ -148,8 +148,10 @@ func runUntilInstalled(ctx context.Context, cmd *exec.Cmd, c agentCLI) ([]byte, // bash, and curl, which every one-liner (and the scripts behind them) // downloads with. magpie's Docker image had none of them, and the install // failed there with "exec: bash: not found". Since 7bfe3137 it has bash and -// busybox's wget but still no curl, and the one-liner failed there too. A -// var so tests can say there is none. +// busybox's wget but still no curl, and the one-liner failed there too. +// Since #2834 it is Debian with bash and curl, and the CLIs the one-liners +// install find the loader and libraries they link. A var so tests can say +// there is none. var shellInstallerRuns = func() bool { for _, p := range []string{"bash", "curl"} { if _, err := exec.LookPath(p); err != nil { diff --git a/internal/provider/install_test.go b/internal/provider/install_test.go index d0460c5a6..7fb727692 100644 --- a/internal/provider/install_test.go +++ b/internal/provider/install_test.go @@ -98,7 +98,7 @@ func waitPast(t *testing.T, id, state string) SignInState { return SignInState{} } -// magpie's Docker image has bash and busybox's wget but no curl, which every +// magpie's Docker image had bash and busybox's wget but no curl, which every // vendor's one-liner downloads with: there the native installer is used func TestShellInstallerNeedsCurl(t *testing.T) { if runtime.GOOS == "windows" { diff --git a/site/public/docs/docker.html b/site/public/docs/docker.html index 9269ebdea..defe1d07a 100644 --- a/site/public/docs/docker.html +++ b/site/public/docs/docker.html @@ -93,7 +93,7 @@ Volume/config: providers, keys, sign-ins, plugins and usage Usernonroot (uid 65532) -

The image holds magpie’s terminal-only build on distroless, with bash and busybox for a terminal in the container. It runs magpie serve (the gateway alone) unless given another command. The container finds no agents to wire, so magpie in it is a gateway: the agents that use it run elsewhere.

+

The image holds magpie’s terminal-only build on Debian 12 slim, with bash for a terminal in the container and curl for the installers of the CLIs some subscriptions sign in with (Cursor, Devin, Grok Build). It runs magpie serve (the gateway alone) unless given another command. The container finds no agents to wire, so magpie in it is a gateway: the agents that use it run elsewhere.

Run it

Run it with the browser UI, a key for that page you keep across restarts, and both ports on the host’s loopback only:

diff --git a/site/public/docs/ja/docker.html b/site/public/docs/ja/docker.html index 43302c61c..550632cb8 100644 --- a/site/public/docs/ja/docker.html +++ b/site/public/docs/ja/docker.html @@ -93,7 +93,7 @@ ボリューム/config:プロバイダ、キー、サインイン、プラグイン、使用量 ユーザーnonroot(uid 65532) -

イメージに入っているのはターミナル専用ビルドの magpie で、distroless をベースに、コンテナ内でターミナルを使うための bash と busybox を含みます。コマンドを指定しなければ magpie serve(ゲートウェイのみ)を実行します。コンテナ内には設定するエージェントがないので、ここでの magpie はゲートウェイです。それを使うエージェントはほかのマシンで動きます。

+

イメージに入っているのはターミナル専用ビルドの magpie で、Debian 12 slim をベースに、コンテナ内でターミナルを使うための bash と、一部のサブスクリプションのサインインに必要な CLI(Cursor、Devin、Grok Build)をインストールするための curl を含みます。コマンドを指定しなければ magpie serve(ゲートウェイのみ)を実行します。コンテナ内には設定するエージェントがないので、ここでの magpie はゲートウェイです。それを使うエージェントはほかのマシンで動きます。

起動する

ブラウザ UI 付きで、再起動しても変わらないページ用のキーを渡し、両方のポートをホストのループバックだけに公開して起動します。

diff --git a/site/public/docs/zh/docker.html b/site/public/docs/zh/docker.html index 5ac2be38f..9d12a9787 100644 --- a/site/public/docs/zh/docker.html +++ b/site/public/docs/zh/docker.html @@ -93,7 +93,7 @@ 数据卷/config:供应商、密钥、登录、插件和用量 用户nonroot(uid 65532) -

镜像里是 magpie 的纯终端版本,基于 distroless,并带了 bash 和 busybox,方便在容器里开终端。不指定命令时运行 magpie serve(只有网关)。容器里找不到需要配置的 Agent,所以这里的 magpie 是一个网关:用它的 Agent 运行在别的机器上。

+

镜像里是 magpie 的纯终端版本,基于 Debian 12 slim,带 bash,方便在容器里开终端,也带 curl,用来安装部分订阅登录时需要的 CLI(Cursor、Devin、Grok Build)。不指定命令时运行 magpie serve(只有网关)。容器里找不到需要配置的 Agent,所以这里的 magpie 是一个网关:用它的 Agent 运行在别的机器上。

运行

带 Web 界面运行,给页面一个重启后不变的 key,两个端口都只发布在宿主机的回环地址上: