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

26 lines
1.2 KiB
Docker
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.

# Bun 运行沙箱镜像。
# 与 src/api/code_runner/languages.rs 的 bun 注册项对齐:
# image: yggdrasil-runner-bun:latest
# run_cmd: bun run /code/main.ts
#
# bun 在 Alpine 3.18 的官方仓库里没有,用 bun.sh 官方安装脚本(多架构、
# 自动检测 /etc/alpine-release 选 musl 变体。bun 的 musl 二进制是 C++ 写的,
# 运行时依赖 libstdc++ + libgccmusl 只带 libc不带 C++ 运行时),必须保留。
# 安装期另需 unzip + bash + curl安装后卸载 unzip/curl 减小镜像。
FROM yggdrasil-runner-base:latest
# libstdc++ / libgcc 是 bun 运行时依赖不能删curl/unzip/bash 仅供安装期。
# BUN_INSTALL 用 export 对管道两侧生效——「VAR=x cmd | bash」只给左侧设变量
# bash 侧读不到会 fallback 到 $HOME/.bun。指定到 /opt/bun 避免依赖 $HOME
# runner 用户 $HOME 可能不可写或不存在)。
RUN apk add --no-cache curl unzip bash libstdc++ libgcc \
&& export BUN_INSTALL=/opt/bun \
&& curl -fsSL https://bun.sh/install | bash \
&& ln -s /opt/bun/bin/bun /usr/local/bin/bun \
&& apk del curl unzip \
&& bun --version
COPY runner.toml /runner.toml
USER runner