update Dockerfile

This commit is contained in:
tao.chen
2026-06-18 14:04:39 +08:00
parent 96487706e0
commit a849d0b3de
+18 -8
View File
@@ -32,11 +32,19 @@ FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# 安装 ripgrep 工具
COPY ripgrep-15.1.0-x86_64-unknown-linux-musl.tar.gz /tmp/
RUN tar -xzf /tmp/ripgrep-15.1.0-x86_64-unknown-linux-musl.tar.gz -C /opt && \
ln -s /opt/ripgrep-15.1.0-x86_64-unknown-linux-musl/rg /usr/local/bin/rg
RUN rg --version
# 1. 干净地为最终镜像配置 Node.js 22 环境 # 1. 干净地为最终镜像配置 Node.js 22 环境
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \ curl \
ca-certificates \ ca-certificates \
gnupg \ gnupg \
git \
&& mkdir -p /etc/apt/keyrings \ && mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
@@ -48,16 +56,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# 2. 从 builder 复制 uv 和由 uv 管理的 Python 3.11 # 2. 从 builder 复制 uv 和由 uv 管理的 Python 3.11
COPY --from=builder /opt/uv/uv /usr/local/bin/uv COPY --from=builder /opt/uv/uv /usr/local/bin/uv
COPY --from=builder /root/.local/share/uv/python /root/.local/share/uv/python COPY --from=builder /root/.local/share/uv/python /root/.local/share/uv/python
RUN uv --version
RUN uv venv /opt/venv --python 3.11
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt /tmp/requirements.txt
RUN uv pip install \
--index-url https://pypi.tuna.tsinghua.edu.cn/simple/ \
--requirements /tmp/requirements.txt
# 3. 核心修复:在最终镜像中用正规的 npm 安装 opencode-ai,确保系统全局软链接生成完整 # 3. 在最终镜像中用正规的 npm 安装 opencode-ai,确保系统全局软链接生成完整
RUN npm install -g opencode-ai && npm cache clean --force RUN npm install -g opencode-ai && npm cache clean --force
RUN opencode --version
# 4. 精准寻找 uv 的 Python 路径并建立全局 python / python3 软链接(消除通配符失败隐患) COPY skills /root/.config/opencode/skills
RUN UV_PYTHON_BIN=$(ls /root/.local/share/uv/python/cpython-3.11.*/bin/python3 | head -n 1) \
&& ln -s "$UV_PYTHON_BIN" /usr/local/bin/python3 \
&& ln -s /usr/local/bin/python3 /usr/local/bin/python
# 5. 验证成果
RUN opencode --version && uv --version && python3 --version
ENTRYPOINT ["opencode"] ENTRYPOINT ["opencode"]