yggdrasil/docker/build-runners.sh
xfy ca676a6146 feat(docker): 新增 yggdrasil-runner-bun 沙箱镜像
bun 在 Alpine 3.18 官方仓库不可用,用 bun.sh 安装脚本(多架构、自动检测
/etc/alpine-release 选 musl 变体)。踩坑三处:

1. BUN_INSTALL 必须对管道两侧生效——「VAR=x cmd | bash」只给左侧设变量,
   bash 侧读不到会 fallback 到 $HOME/.bun。改用 export。
2. bun 的 musl 二进制是 C++ 写的,依赖 libstdc++ + libgcc(musl libc 不带
   C++ 运行时),缺失时报 _ZNSt18condition_variable... symbol not found。
   这两个是运行时依赖,apk del 不得删除。
3. 安装路径固定到 /opt/bun + symlink /usr/local/bin/bun,避免依赖 $HOME
   (runner 用户 $HOME 可能不可写)。

本地验证通过:
- bun --version → 1.3.14
- runner 用户(1000:1000) + 只读根 + tmpfs(/code mode=1777, /tmp exec) 下
  成功执行含 interface/类型注解/循环的 TypeScript 代码。

build-runners.sh 加 bun 构建步骤;deploy-to-linux SKILL.md 的 build 循环、
docker save 列表、docker tag 列表、verify 循环全部补 bun(5→6 个镜像)。
2026-07-21 15:44:38 +08:00

37 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# 构建代码运行器所需的沙箱镜像base → python / node / go / rust / bun。
#
# 依赖:本机已安装 docker。构建顺序固定python/node/go/rust/bun 均为 FROM base
# 镜像 tag 与 src/api/code_runner/languages.rs 的注册项严格对应:
# yggdrasil-runner-base:latest
# yggdrasil-runner-python:latest
# yggdrasil-runner-node:latest
# yggdrasil-runner-go:latest
# yggdrasil-runner-rust:latest
# yggdrasil-runner-bun:latest
set -e
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
echo "==> Building yggdrasil-runner-base:latest"
docker build -t yggdrasil-runner-base:latest "$SCRIPT_DIR/runner-base"
echo "==> Building yggdrasil-runner-python:latest"
docker build -t yggdrasil-runner-python:latest "$SCRIPT_DIR/runner-python"
echo "==> Building yggdrasil-runner-node:latest"
docker build -t yggdrasil-runner-node:latest "$SCRIPT_DIR/runner-node"
echo "==> Building yggdrasil-runner-go:latest"
docker build -t yggdrasil-runner-go:latest "$SCRIPT_DIR/runner-go"
echo "==> Building yggdrasil-runner-rust:latest"
docker build -t yggdrasil-runner-rust:latest "$SCRIPT_DIR/runner-rust"
echo "==> Building yggdrasil-runner-bun:latest"
docker build -t yggdrasil-runner-bun:latest "$SCRIPT_DIR/runner-bun"
echo "==> Done. Images:"
docker images --filter "reference=yggdrasil-runner-*" \
--format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"