From dfd59697858ce1d8a76d1410c15d9638992a2964 Mon Sep 17 00:00:00 2001 From: PuqiAR Date: Sat, 3 Jan 2026 21:04:56 +0800 Subject: [PATCH] =?UTF-8?q?[CI]=20DS=E5=BF=98=E8=AE=B0=E4=BA=86git?= =?UTF-8?q?=E4=B9=9F=E8=A6=81=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ci/Dockerfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 2c8d993..6d8a663 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -1,11 +1,10 @@ # 第一阶段:构建基础环境 FROM ubuntu:24.04 AS builder-base -# 1. 设置APT镜像源加速(可选) +# 1. 设置APT镜像源加速 RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \ sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list -# 2. 一次性安装所有系统依赖和工具链 RUN apt-get update && \ apt-get install -y --no-install-recommends \ wget gnupg ca-certificates \ @@ -15,10 +14,8 @@ RUN apt-get update && \ && rm -rf /var/lib/apt/lists/* && \ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100 && \ update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 && \ - # 创建 lld 的符号链接,确保 ld.lld 可用 ln -sf /usr/bin/ld.lld-19 /usr/bin/ld.lld -# 3. 安装xmake RUN wget -O /usr/local/bin/xmake \ https://git.fig-lang.cn/PuqiAR/xmake-binary-copy/raw/commit/989d1f2dabb0bc8d5981a5f900c2cf7c2ac78ee4/xmake-bundle-v3.0.5.linux.x86_64 && \ chmod +x /usr/local/bin/xmake @@ -26,24 +23,28 @@ RUN wget -O /usr/local/bin/xmake \ # 第二阶段:创建最终镜像 FROM ubuntu:24.04 -# 1. 仅复制必要的运行时文件 +# 【关键修复】在最终镜像中安装CI必需的运行时工具 +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + git tar curl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# 1. 复制编译器、xmake和库文件 COPY --from=builder-base /usr/local/bin/xmake /usr/local/bin/xmake COPY --from=builder-base /usr/bin/clang++ /usr/bin/clang++ COPY --from=builder-base /usr/bin/clang /usr/bin/clang COPY --from=builder-base /usr/bin/ld.lld /usr/bin/ld.lld -# 复制MinGW交叉编译器的库和头文件(关键!) COPY --from=builder-base /usr/x86_64-w64-mingw32 /usr/x86_64-w64-mingw32 -# 复制标准C++库(确保目录存在) COPY --from=builder-base /usr/lib/llvm-19 /usr/lib/llvm-19 # 2. 创建非root用户 RUN useradd -m -s /bin/bash builder -# 3. 设置默认用户 USER builder WORKDIR /home/builder -# 4. 验证安装(可选) +# 3. 验证环境 RUN xmake --version | head -1 && \ clang++ --version | head -1 && \ - echo "构建环境就绪" \ No newline at end of file + git --version && \ + echo "✅ CI环境就绪" \ No newline at end of file