[CI] RUSH!
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
# 第一阶段:构建基础环境(这层很少变动,缓存命中率高)
|
# 第一阶段:构建基础环境
|
||||||
FROM ubuntu:24.04 AS builder-base
|
FROM ubuntu:24.04 AS builder-base
|
||||||
|
|
||||||
# 1. 设置APT镜像源加速(可选,可替换为国内源如 mirrors.aliyun.com)
|
# 1. 设置APT镜像源加速(可选)
|
||||||
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
|
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
|
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
|
||||||
|
|
||||||
# 2. 一次性安装所有系统依赖和工具链(这一层如果不变,会完全复用缓存)
|
# 2. 一次性安装所有系统依赖和工具链
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
wget gnupg ca-certificates \
|
wget gnupg ca-certificates \
|
||||||
@@ -15,14 +15,15 @@ RUN apt-get update && \
|
|||||||
&& rm -rf /var/lib/apt/lists/* && \
|
&& 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 && \
|
||||||
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 && \
|
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 && \
|
||||||
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-19 100
|
# 创建 lld 的符号链接,确保 ld.lld 可用
|
||||||
|
ln -sf /usr/bin/ld.lld-19 /usr/bin/ld.lld
|
||||||
|
|
||||||
# 3. 安装xmake(独立一层,xmake更新时才需要重建)
|
# 3. 安装xmake
|
||||||
RUN wget -O /usr/local/bin/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 && \
|
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
|
chmod +x /usr/local/bin/xmake
|
||||||
|
|
||||||
# 第二阶段:创建最终镜像(极轻量)
|
# 第二阶段:创建最终镜像
|
||||||
FROM ubuntu:24.04
|
FROM ubuntu:24.04
|
||||||
|
|
||||||
# 1. 仅复制必要的运行时文件
|
# 1. 仅复制必要的运行时文件
|
||||||
@@ -32,7 +33,7 @@ COPY --from=builder-base /usr/bin/clang /usr/bin/clang
|
|||||||
COPY --from=builder-base /usr/bin/ld.lld /usr/bin/ld.lld
|
COPY --from=builder-base /usr/bin/ld.lld /usr/bin/ld.lld
|
||||||
# 复制MinGW交叉编译器的库和头文件(关键!)
|
# 复制MinGW交叉编译器的库和头文件(关键!)
|
||||||
COPY --from=builder-base /usr/x86_64-w64-mingw32 /usr/x86_64-w64-mingw32
|
COPY --from=builder-base /usr/x86_64-w64-mingw32 /usr/x86_64-w64-mingw32
|
||||||
# 复制标准C++库
|
# 复制标准C++库(确保目录存在)
|
||||||
COPY --from=builder-base /usr/lib/llvm-19 /usr/lib/llvm-19
|
COPY --from=builder-base /usr/lib/llvm-19 /usr/lib/llvm-19
|
||||||
|
|
||||||
# 2. 创建非root用户
|
# 2. 创建非root用户
|
||||||
|
|||||||
Reference in New Issue
Block a user