Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(docker): build and publish the server image for linux/arm64 (#4263)

Aditya Umalef12a834e56ce
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 5bf3a44206..dfa2506adc 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -391,9 +391,37 @@ jobs:
print(f"{path}: {len(files)} files, each once; no build cache; {native[0]}")
PY
+ arm64-smoke:
+ name: arm64 image + boot smoke
+ # Raspberry Pi 4/5 and ARM servers pull the arm64 image; GitHub's ARM
+ # runner builds it natively and proves the server, the UI, the Data
+ # engine's native tree and the bots' Chromium all work on it.
+ runs-on: ubuntu-24.04-arm
+ timeout-minutes: 25
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - name: Build image
+ run: docker build -t openmausbot:arm64 .
+ - name: Boot the container; prove the server, UI, DuckDB and browser work on arm64
+ run: |
+ set -euo pipefail
+ test "$(docker image inspect -f '{{.Architecture}}' openmausbot:arm64)" = arm64
+ docker run -d --init --shm-size=512m --name omb openmausbot:arm64
+ for i in $(seq 1 40); do
+ if docker exec omb curl -sf http://127.0.0.1:8799/api/health | grep -q openmausbot; then break; fi
+ sleep 2
+ if [ "$i" = "40" ]; then docker logs omb; echo "server never became healthy"; exit 1; fi
+ done
+ docker exec omb curl -sf http://127.0.0.1:8799/ | grep -qi "<html" || { docker logs omb; echo "UI not served"; exit 1; }
+ docker exec -w /app/duckdb omb node --input-type=module -e "const { DuckDBInstance } = await import('@duckdb/node-api'); const c = await (await DuckDBInstance.create()).connect(); const r = await c.runAndReadAll('select 42 as x'); if (Number(r.getRows()[0][0]) !== 42) process.exit(1)"
+ test "$(docker exec omb id -un)" = maus
+ timeout 90 docker exec omb agent-browser --session ci-browser open 'data:text/html,<title>OMB browser smoke</title><h1>Browser ready</h1>'
+ timeout 15 docker exec omb agent-browser --session ci-browser get title | grep -Fx 'OMB browser smoke'
+ timeout 15 docker exec omb agent-browser --session ci-browser close
+
publish:
name: publish to GHCR
- needs: build-and-smoke
+ needs: [build-and-smoke, arm64-smoke]
# Release dispatches on its published tag because GITHUB_TOKEN-created
# tags do not start another workflow. A manual branch run is smoke-only.
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v'))
@@ -403,6 +431,8 @@ jobs:
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ # The server image is published for linux/amd64 and linux/arm64.
+ - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
@@ -430,21 +460,26 @@ jobs:
today="date-$(date -u +%F)"
chrome=$(curl -fsSL --max-time 30 https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -er .channels.Stable.version) || chrome=""
[[ "$chrome" =~ ^[0-9]+(\.[0-9]+)+$ ]] || chrome=$today
+ # An arm64 image takes Debian's Chromium instead: key it on the newest bookworm build, security updates included.
+ chromium=$(curl -fsSL --max-time 30 'https://qa.debian.org/madison.php?package=chromium&s=bookworm,bookworm-security&a=arm64&text=on' | awk -F'|' '{gsub(/ /, "", $2); print $2}' | sort -V | tail -n 1) || chromium=""
+ [[ "$chromium" =~ ^[0-9][0-9A-Za-z.+~:-]*$ ]] || chromium=$today
engines="" engines_tag=""
for package in $CLOUD_HOME_ENGINES; do
version=$(npm view "$package@latest" version 2>/dev/null) || version=""
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9][0-9A-Za-z.+-]*$ ]]; then engines=$CLOUD_HOME_ENGINES engines_tag=$today; break; fi
engines="$engines $package@$version"
done
- { echo "chrome=$chrome"; echo "engines=${engines# }"; echo "engines_tag=$engines_tag"; } | tee -a "$GITHUB_OUTPUT"
+ { echo "chrome=$chrome"; echo "chromium=$chromium"; echo "engines=${engines# }"; echo "engines_tag=$engines_tag"; } | tee -a "$GITHUB_OUTPUT"
- uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
+ platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
CHROME_CACHE_TAG=${{ steps.keys.outputs.chrome }}
+ CHROMIUM_CACHE_TAG=${{ steps.keys.outputs.chromium }}
cache-from: type=gha
cache-to: type=gha,mode=max
# The Cloud Pro home machine (the Dockerfile's cloud-home target), on the
@@ -469,6 +504,7 @@ jobs:
target: cloud-home
build-args: |
CHROME_CACHE_TAG=${{ steps.keys.outputs.chrome }}
+ CHROMIUM_CACHE_TAG=${{ steps.keys.outputs.chromium }}
CLOUD_HOME_ENGINES=${{ steps.keys.outputs.engines }}
ENGINES_CACHE_TAG=${{ steps.keys.outputs.engines_tag }}
push: true
diff --git a/Dockerfile b/Dockerfile
index c06caf4d8a..f429fbb563 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,6 +14,7 @@
# docker build -t openmausbot .
# docker build --build-arg ENGINES="@anthropic-ai/claude-code @openai/codex" -t openmausbot .
# docker build --target cloud-home -t omb-cloud-home .
+# docker buildx build --platform linux/arm64 -t openmausbot . # Raspberry Pi 4/5, ARM servers
#
# HOME is the /data volume, so engine CLI logins (~/.claude, ~/.codex, ~/.grok,
# ...) and OpenMausBot's own state (~/.openmausbot) persist across container
@@ -30,7 +31,9 @@ FROM caddy:2.10.2 AS edge
# capability (and the build user's ownership).
RUN cp /usr/bin/caddy /caddy
-FROM node:24-bookworm-slim AS build
+# The JavaScript build is the same for every CPU, so it runs once on the build
+# host's own; only the Data engine's native tree below follows the image's CPU.
+FROM --platform=$BUILDPLATFORM node:24-bookworm-slim AS build
WORKDIR /src
# pinned to package.json#packageManager; corepack is being removed from Node
RUN npm install -g [email protected]
@@ -48,10 +51,15 @@ COPY scripts/install-git-hooks.mjs ./scripts/install-git-hooks.mjs
RUN pnpm install --frozen-lockfile
COPY . .
# The Cloud home runs these as root, so nobody else may write them.
-# The Data engine's native modules (server/data/engine.ts), staged like the
-# desktop app's extraResources; the runtime stages copy this tree.
-RUN node scripts/prepare-duckdb.mjs && chmod -R go-w dist-native/duckdb
RUN pnpm build:server && pnpm exec vite build && chmod -R go-w dist dist-server skills
+# The Data engine's native modules (server/data/engine.ts), staged like the
+# desktop app's extraResources for the image's CPU (amd64 -> x64, arm64), into
+# one tree the runtime stages copy. pnpm installed both CPUs' packages
+# (pnpm-workspace.yaml supportedArchitectures).
+ARG TARGETARCH
+RUN arch=x64 && if [ "$TARGETARCH" = arm64 ]; then arch=arm64; fi \
+ && OMB_DUCKDB_ARCH=$arch node scripts/prepare-duckdb.mjs \
+ && mv "dist-native/duckdb/linux-$arch" dist-native/duckdb/target && chmod -R go-w dist-native/duckdb
FROM node:24-bookworm-slim AS runtime
# Install Chrome's Bookworm libraries directly: agent-browser --with-deps
@@ -75,12 +83,21 @@ ARG AGENT_BROWSER_VERSION=0.37.0
# `agent-browser install` fetches Chrome for Testing's last-known-good Stable;
# the publish job passes that version so a Chrome release rebuilds this layer.
ARG CHROME_CACHE_TAG=""
+# Chrome for Testing has no Linux ARM64 build, so an arm64 image takes
+# Debian's Chromium instead, linked at the same path; the publish job passes
+# its newest bookworm version so a Debian security update rebuilds it too.
+ARG CHROMIUM_CACHE_TAG=""
+ARG TARGETARCH
# The global link must be the native binary for this platform (agent-browser's
# postinstall points it there); the other platforms' binaries are never run.
-RUN echo "agent-browser ${AGENT_BROWSER_VERSION}, Chrome for Testing ${CHROME_CACHE_TAG:-Stable}" \
+RUN echo "agent-browser ${AGENT_BROWSER_VERSION}, Chrome for Testing ${CHROME_CACHE_TAG:-Stable}, Debian Chromium ${CHROMIUM_CACHE_TAG:-latest}" \
&& npm install -g --cache /tmp/npm-cache agent-browser@${AGENT_BROWSER_VERSION} \
- && HOME=/opt/openmausbot-browser agent-browser install \
- && ln -s /opt/openmausbot-browser/.agent-browser/browsers/chrome-*/chrome /opt/openmausbot-browser/chrome \
+ && if [ "$TARGETARCH" = arm64 ]; then \
+ apt-get update && apt-get install -y --no-install-recommends chromium && rm -rf /var/lib/apt/lists/* \
+ && mkdir -p /opt/openmausbot-browser && ln -s /usr/lib/chromium/chromium /opt/openmausbot-browser/chrome; \
+ else HOME=/opt/openmausbot-browser agent-browser install \
+ && ln -s /opt/openmausbot-browser/.agent-browser/browsers/chrome-*/chrome /opt/openmausbot-browser/chrome; \
+ fi \
&& native="$(readlink -f "$(command -v agent-browser)")" \
&& case "$native" in */agent-browser/bin/agent-browser-linux-*) ;; *) echo "agent-browser is not a native binary: $native" >&2; exit 1;; esac \
&& [ "$(head -c 4 "$native")" = "$(printf '\177ELF')" ] \
@@ -149,7 +166,7 @@ COPY deploy/fly/Caddyfile /app/cloud/Caddyfile
# copies stay root's. Only the /data volume is maus's; the launcher refuses to
# start otherwise (codeTrustProblem), and this check refuses to build.
# DuckDB and resvg change on a version bump, not per commit: beneath the app files.
-COPY --from=build /src/dist-native/duckdb/linux-x64 ./duckdb
+COPY --from=build /src/dist-native/duckdb/target ./duckdb
COPY --from=build /src/dist-server ./dist-server
COPY --from=build /src/dist ./dist
# The bundled skills (server/skill-library.ts reads ./skills from /app).
@@ -180,7 +197,7 @@ FROM runtime AS server
# Optional engine CLIs baked into the image (space-separated npm packages).
ARG ENGINES=""
RUN if [ -n "$ENGINES" ]; then HOME=/tmp/omb-build-home npm install -g $ENGINES && rm -rf /tmp/omb-build-home /tmp/node-compile-cache; fi
-COPY --from=build --chown=maus:maus /src/dist-native/duckdb/linux-x64 ./duckdb
+COPY --from=build --chown=maus:maus /src/dist-native/duckdb/target ./duckdb
COPY --from=build --chown=maus:maus /src/dist-server ./dist-server
COPY --from=build --chown=maus:maus /src/dist ./dist
COPY --from=build --chown=maus:maus /src/skills ./skills
diff --git a/apps/docs/content/docs/self-hosting/deploy-vps.mdx b/apps/docs/content/docs/self-hosting/deploy-vps.mdx
index 9370ee3a0c..4cbfe70390 100644
--- a/apps/docs/content/docs/self-hosting/deploy-vps.mdx
+++ b/apps/docs/content/docs/self-hosting/deploy-vps.mdx
@@ -128,6 +128,19 @@ In this path, every `npx openmausbot …` command below is run inside the contai
docker compose exec omb node dist-server/openmausbot.js pair --label "My MacBook"
```
+### On ARM64: Raspberry Pi 4/5 and ARM servers
+
+The image is published for both `linux/amd64` and `linux/arm64`, and Docker
+pulls the one that matches the machine, so the steps above are the same on an
+ARM64 server or a Raspberry Pi 4 or 5. Use a 64-bit system (Raspberry Pi OS
+64-bit or Ubuntu Server for ARM; `uname -m` prints `aarch64`) and at least 4 GB
+of RAM. When you change `ENGINES`, `docker compose build` builds the image on
+the machine itself.
+
+On ARM64 the bots' browser is Debian's Chromium, because Chrome for Testing has
+no Linux ARM64 build. Once it runs, open `https://maus.example.com` from any
+browser and pair it as below.
+
## Path C: only your Tailscale network
From the administrator shell, install Tailscale on the server and sign in (`curl -fsSL https://tailscale.com/install.sh | sh && sudo tailscale up`). Enable HTTPS certificates for your tailnet once in the admin console (DNS → HTTPS Certificates), then run this from the `maus` shell:
diff --git a/scripts/docker-image.test.ts b/scripts/docker-image.test.ts
index 32b7d14650..3a565ac94b 100644
--- a/scripts/docker-image.test.ts
+++ b/scripts/docker-image.test.ts
@@ -14,7 +14,7 @@ const dockerfile = readFileSync(new URL("../Dockerfile", import.meta.url), "utf8
const workflow = parse(readFileSync(new URL("../.github/workflows/docker.yml", import.meta.url), "utf8"));
interface Step { op: string; args: string }
-interface Stage { name: string; from: string; steps: Step[] }
+interface Stage { name: string; from: string; platform?: string; steps: Step[] }
function stages(text: string): Stage[] {
const all: Stage[] = [];
@@ -26,8 +26,8 @@ function stages(text: string): Stage[] {
const [, op, args] = /^\s*(\S+)\s*([\s\S]*)$/.exec(pending)!;
pending = "";
if (op.toUpperCase() === "FROM") {
- const [, from, name] = /^(\S+)(?:\s+AS\s+(\S+))?$/i.exec(args.trim())!;
- all.push({ name: name ?? `#${all.length}`, from, steps: [] });
+ const [, platform, from, name] = /^(?:--platform=(\S+)\s+)?(\S+)(?:\s+AS\s+(\S+))?$/i.exec(args.trim())!;
+ all.push({ name: name ?? `#${all.length}`, from, platform, steps: [] });
} else all.at(-1)?.steps.push({ op: op.toUpperCase(), args: args.trim() });
}
return all;
@@ -107,7 +107,7 @@ describe("container images", () => {
expect(home.findIndex(step => step.args.startsWith("--from=edge "))).toBeLessThan(home.findLastIndex(npmInstall));
expect(home.filter(step => step.op === "RUN" && /\b(cp|mv)\b[^&]*caddy/.test(step.args))).toEqual([]);
expect(home.filter(step => step.args.includes("--from=build")).map(step => step.args)).toEqual([
- "/src/dist-native/duckdb/linux-x64 ./duckdb", "/src/dist-server ./dist-server", "/src/dist ./dist", "/src/skills ./skills",
+ "/src/dist-native/duckdb/target ./duckdb", "/src/dist-server ./dist-server", "/src/dist ./dist", "/src/skills ./skills",
].map(path => `--from=build ${path}`));
expect(chain("server").filter(step => step.args.includes("--from=build")).every(step => step.args.startsWith("--from=build --chown=maus:maus "))).toBe(true);
});
@@ -211,6 +211,48 @@ describe("container images", () => {
expect(script.left).toEqual(script.names);
});
+ it("builds the server image for linux/arm64 too: the DuckDB tree and the browser follow the image's CPU", () => {
+ // The JavaScript build runs once on the build host; only the native tree is per CPU, staged after it.
+ const build = all.find(s => s.name === "build")!;
+ expect(build.platform).toBe("$BUILDPLATFORM");
+ const declared = build.steps.findIndex(step => step.op === "ARG" && step.args === "TARGETARCH");
+ expect(declared).toBeGreaterThan(build.steps.findIndex(step => step.op === "RUN" && step.args.startsWith("pnpm build:server")));
+ const stage = build.steps.find(step => step.op === "RUN" && step.args.includes("prepare-duckdb.mjs"))!;
+ expect(build.steps.indexOf(stage)).toBeGreaterThan(declared);
+ if (process.platform !== "win32") {
+ for (const [targetArch, arch] of [["amd64", "x64"], ["arm64", "arm64"], ["", "x64"]]) {
+ const root = mkdtempSync(join(tmpdir(), "omb-duckdb-arch-"));
+ temporaryDirectories.push(root);
+ mkdirSync(join(root, "scripts"));
+ // A stand-in for the staging script: it stages the CPU it is told to, and records which.
+ writeFileSync(join(root, "scripts/prepare-duckdb.mjs"), 'import { mkdirSync, writeFileSync } from "node:fs"; const d = `dist-native/duckdb/linux-${process.env.OMB_DUCKDB_ARCH}`; mkdirSync(d, { recursive: true }); writeFileSync(`${d}/arch`, process.env.OMB_DUCKDB_ARCH);');
+ const result = spawnSync("sh", ["-c", stage.args], { cwd: root, env: { PATH: process.env.PATH, TARGETARCH: targetArch }, encoding: "utf8" });
+ expect(result.status, `${targetArch}: ${result.stderr}`).toBe(0);
+ expect(readdirSync(join(root, "dist-native/duckdb")), targetArch).toEqual(["target"]);
+ expect(readFileSync(join(root, "dist-native/duckdb/target/arch"), "utf8"), targetArch).toBe(arch);
+ }
+ }
+ // Chrome for Testing has no Linux ARM64 build: an arm64 image takes Debian's Chromium at the same path.
+ const runtime = chain("runtime");
+ expect(runtime.slice(0, runtime.indexOf(browserRun()))).toContainEqual({ op: "ARG", args: "TARGETARCH" });
+ expect(browserRun().args).toMatch(/if \[ "\$TARGETARCH" = arm64 \]; then .*apt-get install -y --no-install-recommends chromium .*ln -s \/usr\/lib\/chromium\/chromium \/opt\/openmausbot-browser\/chrome; +else .*agent-browser install .*; +fi/);
+ // Published for both CPUs; the Cloud home (Fly, amd64) stays as it is.
+ const steps = workflow.jobs.publish.steps as { id?: string; uses?: string; with?: Record<string, string> }[];
+ const server = steps.findIndex(step => step.uses?.startsWith("docker/build-push-action@") && step.id !== "home");
+ const qemu = steps.findIndex(step => step.uses?.startsWith("docker/setup-qemu-action@"));
+ expect(qemu).toBeGreaterThan(-1);
+ expect(qemu).toBeLessThan(server);
+ expect(steps[server].with!.platforms).toBe("linux/amd64,linux/arm64");
+ expect(steps.find(step => step.id === "home")!.with).not.toHaveProperty("platforms");
+ // and an arm64 runner proves the arm64 image boots, serves and browses before anything is published
+ const arm = workflow.jobs["arm64-smoke"];
+ expect(arm["runs-on"]).toBe("ubuntu-24.04-arm");
+ expect(workflow.jobs.publish.needs).toEqual(expect.arrayContaining(["build-and-smoke", "arm64-smoke"]));
+ const armRun = (arm.steps as { run?: string }[]).map(step => step.run ?? "").join("\n");
+ expect(armRun).toContain("/api/health");
+ expect(armRun).toContain("agent-browser --session ci-browser open");
+ });
+
it("builds Cloud home from the same Dockerfile in CI, with its own layer cache", () => {
const smoke = workflow.jobs["build-and-smoke"].steps.map((step: { run?: string }) => step.run ?? "").join("\n");
expect(smoke).toContain("docker build --target cloud-home --build-arg CLOUD_HOME_ENGINES= -t omb-cloud-home:ci .");
@@ -224,6 +266,8 @@ describe("container images", () => {
expect(home.with!["cache-to"]).toBe("type=gha,scope=cloud-home,mode=max");
// Both builds key the browser layer on the same Chrome, so they share it.
for (const build of [server, home]) expect(build.with!["build-args"]).toContain("CHROME_CACHE_TAG=${{ steps.keys.outputs.chrome }}");
+ // and the arm64 one on Debian's newest Chromium, so a security update rebuilds it
+ for (const build of [server, home]) expect(build.with!["build-args"]).toContain("CHROMIUM_CACHE_TAG=${{ steps.keys.outputs.chromium }}");
expect(home.with!["build-args"]).toContain("CLOUD_HOME_ENGINES=${{ steps.keys.outputs.engines }}");
expect(home.with!["build-args"]).toContain("ENGINES_CACHE_TAG=${{ steps.keys.outputs.engines_tag }}");
});
@@ -235,6 +279,8 @@ describe("container images", () => {
expect(declared).toBeGreaterThan(runtime.findIndex(step => step.op === "RUN" && step.args.startsWith("apt-get update")));
expect(declared).toBeLessThan(runtime.indexOf(browserRun()));
expect(browserRun().args).toContain("${CHROME_CACHE_TAG");
+ expect(runtime.findIndex(step => step.op === "ARG" && step.args.startsWith("CHROMIUM_CACHE_TAG="))).toBeLessThan(runtime.indexOf(browserRun()));
+ expect(browserRun().args).toContain("${CHROMIUM_CACHE_TAG");
const home = all.find(s => s.name === "cloud-home")!.steps;
expect(home).toContainEqual({ op: "ARG", args: 'CLOUD_HOME_ENGINES="@anthropic-ai/claude-code @openai/codex"' });
// the engines' install, not the tools layer's pinned pnpm beneath it
@@ -250,7 +296,7 @@ describe("container images", () => {
const root = mkdtempSync(join(tmpdir(), "omb-docker-keys-"));
temporaryDirectories.push(root);
const fake = (name: string, body: string) => writeFileSync(join(root, name), `#!/bin/sh\n${ok ? body : "exit 1"}\n`, { mode: 0o755 });
- fake("curl", `echo '{"channels":{"Stable":{"version":"154.0.8037.92","downloads":{}}}}'`);
+ fake("curl", `case "$*" in *madison*) printf ' chromium | 150.0.7871.100-1~deb12u1 | bookworm | arm64\\n chromium | 156.0.8078.73-1~deb12u1 | bookworm-security | arm64\\n';; *) echo '{"channels":{"Stable":{"version":"154.0.8037.92","downloads":{}}}}';; esac`);
fake("npm", `case "$2" in @anthropic-ai/claude-code@latest) echo 2.1.291;; @openai/codex@latest) echo 0.160.1;; *) exit 1;; esac`);
const output = join(root, "output");
writeFileSync(output, "");
@@ -262,11 +308,12 @@ describe("container images", () => {
};
expect(resolve(true)).toEqual({
chrome: "154.0.8037.92",
+ chromium: "156.0.8078.73-1~deb12u1",
engines: "@anthropic-ai/[email protected] @openai/[email protected]",
engines_tag: "",
});
const today = `date-${new Date().toISOString().slice(0, 10)}`;
- expect(resolve(false)).toEqual({ chrome: today, engines: "@anthropic-ai/claude-code @openai/codex", engines_tag: today });
+ expect(resolve(false)).toEqual({ chrome: today, chromium: today, engines: "@anthropic-ai/claude-code @openai/codex", engines_tag: today });
});
// An init collects browser processes whose parents exit, and Chrome gets the
diff --git a/scripts/prepare-duckdb.mjs b/scripts/prepare-duckdb.mjs
index 8796052d3b..74bf906c49 100644
--- a/scripts/prepare-duckdb.mjs
+++ b/scripts/prepare-duckdb.mjs
@@ -110,10 +110,14 @@ export async function packedPackage(name, version, cache, scope = SCOPE) {
}
/** The trees to stage on this host: both mac arches on macOS (each app is
- * single-arch), x64 elsewhere, matching electron-builder.yml. */
+ * single-arch), x64 elsewhere, matching electron-builder.yml. On Linux the
+ * Docker build names the image's CPU in OMB_DUCKDB_ARCH: it stages on the
+ * build host's CPU for either image. */
export function targetsFor(platform = process.platform, env = process.env) {
if (platform === "darwin") return resolveCuaMacArches(env).map((arch) => ({ platform, arch }));
- return [{ platform, arch: "x64" }];
+ const arch = (platform === "linux" && env.OMB_DUCKDB_ARCH) || "x64";
+ if (arch !== "x64" && arch !== "arm64") throw new Error(`OMB_DUCKDB_ARCH must be x64 or arm64; found ${arch}`);
+ return [{ platform, arch }];
}
function requireRegularFile(file) {
diff --git a/scripts/prepare-duckdb.test.mjs b/scripts/prepare-duckdb.test.mjs
index ab8db83a09..e9c1e61b6b 100644
--- a/scripts/prepare-duckdb.test.mjs
+++ b/scripts/prepare-duckdb.test.mjs
@@ -92,6 +92,11 @@ describe("the pin", () => {
expect(targetsFor("darwin", {})).toEqual([{ platform: "darwin", arch: "arm64" }, { platform: "darwin", arch: "x64" }]);
expect(targetsFor("darwin", { OPENMAUSBOT_CUA_ARCHES: "arm64", OPENMAUSBOT_CUA_ARCHES_PARTIAL: "1" })).toEqual([{ platform: "darwin", arch: "arm64" }]);
expect(targetsFor("linux", {})).toEqual([{ platform: "linux", arch: "x64" }]);
+ // The Docker build stages the image's CPU, which need not be the build host's (linux/arm64 under buildx).
+ expect(targetsFor("linux", { OMB_DUCKDB_ARCH: "arm64" })).toEqual([{ platform: "linux", arch: "arm64" }]);
+ expect(targetsFor("linux", { OMB_DUCKDB_ARCH: "x64" })).toEqual([{ platform: "linux", arch: "x64" }]);
+ expect(() => targetsFor("linux", { OMB_DUCKDB_ARCH: "amd64" })).toThrow(/OMB_DUCKDB_ARCH/);
+ expect(targetsFor("win32", { OMB_DUCKDB_ARCH: "arm64" })).toEqual([{ platform: "win32", arch: "x64" }]);
expect(targetsFor("win32", {})).toEqual([{ platform: "win32", arch: "x64" }]);
});
});