-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.arm64
More file actions
97 lines (84 loc) · 5.74 KB
/
Dockerfile.arm64
File metadata and controls
97 lines (84 loc) · 5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# ──────────────────────────────────────────────────────────────────────────────
# worker-sandbox:dev (linux/arm64 原生镜像)
#
# 使用 debian:bookworm-slim 作为基础(本地已有 ARM64 版本)
# 替代 ubuntu:24.04 基础镜像(后者仅有 AMD64 版本,需通过 QEMU 模拟)
#
# 包含:
# - opencode linux-arm64 自包含二进制(v1.15.0)
# - oh-my-openagent 插件预缓存(架构无关的 JS bundle)
# - Python 3 + 量化分析包(duckdb, pandas, numpy, requests, httpx)
#
# 构建命令(在项目根目录执行):
# DOCKER_HOST=unix://$HOME/.colima/default/docker.sock \
# docker build -t worker-sandbox:dev-arm64 \
# --platform linux/arm64 \
# -f docker/worker/Dockerfile.arm64 .
# ──────────────────────────────────────────────────────────────────────────────
FROM debian:bookworm-slim
# ── 系统依赖(使用阿里云镜像加速)────────────────────────────────────────────
RUN sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g; s|http://security.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g; s|http://security.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# ── 安装量化分析 Python 包(使用阿里云 PyPI 镜像)────────────────────────────
RUN pip3 install --no-cache-dir --break-system-packages \
-i https://mirrors.aliyun.com/pypi/simple/ \
"duckdb>=1.0" \
"pandas>=2.0" \
"numpy>=1.26" \
"requests>=2.31" \
"httpx>=0.27"
# ── 创建 sandbox 用户(uid/gid=1000)────────────────────────────────────────
RUN groupadd -g 1000 sandbox && \
useradd -u 1000 -g 1000 -m -d /home/sandbox -s /bin/bash sandbox
# ── 安装 opencode ARM64 自包含二进制 ─────────────────────────────────────────
# opencode-linux-arm64-1.15.0.tgz 由宿主机 npm pack 生成,含 package/bin/opencode
COPY docker/worker/dist/opencode-linux-arm64-1.15.0.tgz /tmp/opencode.tgz
RUN tar xzf /tmp/opencode.tgz -C /tmp && \
install -m 0755 /tmp/package/bin/opencode /usr/local/bin/opencode && \
rm -rf /tmp/opencode.tgz /tmp/package
# ── 预置 oh-my-openagent 插件 cache(架构无关 JS bundle)────────────────────
COPY docker/worker/dist/oh-my-openagent-cache.tar.gz /tmp/ohmy-cache.tar.gz
RUN mkdir -p /home/sandbox/.cache/opencode/packages && \
tar xzf /tmp/ohmy-cache.tar.gz -C /home/sandbox/.cache/opencode/packages && \
chown -R sandbox:sandbox /home/sandbox/.cache && \
mkdir -p /root/.cache/opencode/packages && \
cp -r /home/sandbox/.cache/opencode/packages/. /root/.cache/opencode/packages/ && \
rm -f /tmp/ohmy-cache.tar.gz
# 构建期断言:oh-my-openagent 包文件实际落盘成功
# (COPY 静默成功但 tar 解压失败的场景下,运行时校验才会爆,这里前置到 build 阶段)
# 与 entrypoint.sh 的运行时 GET /agent 校验配套,构成 build + runtime 双保险。
RUN find /home/sandbox/.cache/opencode/packages -name package.json -path '*oh-my-openagent*' \
| grep -q . \
|| (echo "FATAL: oh-my-openagent package.json missing after cache extraction" >&2 \
&& ls -laR /home/sandbox/.cache/opencode/packages | head -40 >&2 \
&& exit 1) \
&& echo "build-time assertion OK: oh-my-openagent cache extracted"
# ── 预置 @ai-sdk/openai-compatible 包 cache(架构无关 JS bundle)────────────
COPY docker/worker/dist/ai-sdk-openai-compatible-cache.tar.gz /tmp/aisdk-cache.tar.gz
RUN cd /home/sandbox/.cache/opencode/packages && \
tar xzf /tmp/aisdk-cache.tar.gz --strip-components=1 && \
cd /root/.cache/opencode/packages && \
tar xzf /tmp/aisdk-cache.tar.gz --strip-components=1 && \
rm /tmp/aisdk-cache.tar.gz && \
chown -R sandbox:sandbox /home/sandbox/.cache
# ── 目录准备 ──────────────────────────────────────────────────────────────────
RUN mkdir -p /home/sandbox/.config/opencode /workspace \
/root/.duckdb /home/sandbox/.duckdb && \
chown -R sandbox:sandbox /home/sandbox/.config && \
chown sandbox:sandbox /workspace
# ── 容器入口脚本 ───────────────────────────────────────────────────────────────
COPY docker/worker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# ── 环境变量 ───────────────────────────────────────────────────────────────────
ENV OPENCODE_DISABLE_AUTOUPDATE=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
USER sandbox
WORKDIR /workspace
EXPOSE 4096
ENTRYPOINT ["/entrypoint.sh"]