ci: upgrade toolchain in Docker (#1956)

This commit is contained in:
LongYinan 2024-02-18 13:42:10 +08:00 committed by GitHub
parent 97039b2f08
commit 1951b60786
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 106 additions and 39 deletions

View file

@ -6,8 +6,8 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build_image: build-alpine-image:
name: Build nodejs-rust:lts name: Build alpine image
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -34,6 +34,26 @@ jobs:
push: true push: true
tags: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine tags: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build-debian-image:
name: Build debian image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GH_CONTAINER_UNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push debian - name: Build and push debian
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
@ -42,20 +62,40 @@ jobs:
push: true push: true
tags: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian tags: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build-debian-aarch64-image:
name: Build debian image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GH_CONTAINER_UNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Install latest libc++-dev for cross build - name: Install latest libc++-dev for cross build
uses: addnab/docker-run-action@v3 uses: addnab/docker-run-action@v3
with: with:
image: node:lts-slim image: node:lts-slim
options: '--platform linux/arm64 --user 0:0 -e GITHUB_TOKEN -v ${{ github.workspace }}/lib/llvm-16:/usr/lib/llvm-16' options: '--platform linux/arm64 --user 0:0 -e GITHUB_TOKEN -v ${{ github.workspace }}/lib/llvm-18:/usr/lib/llvm-18'
run: >- run: >-
apt-get update && apt-get update &&
apt-get install -y wget gnupg2 && apt-get install -y wget gnupg2 &&
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - &&
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main" >> /etc/apt/sources.list && echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main" >> /etc/apt/sources.list &&
echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main" >> /etc/apt/sources.list && echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main" >> /etc/apt/sources.list &&
apt-get update && apt-get update &&
apt-get install libc++-16-dev libc++abi-16-dev -y --fix-missing --no-install-recommends && apt-get install libc++-18-dev libc++abi-18-dev -y --fix-missing --no-install-recommends &&
rm /usr/lib/llvm-16/lib/libc++abi.so rm /usr/lib/llvm-18/lib/libc++abi.so
- name: Build and push debian aarch64 cross - name: Build and push debian aarch64 cross
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@ -66,8 +106,28 @@ jobs:
tags: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 tags: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
context: . context: .
- name: Cleanup build-zig-image:
run: sudo rm -rf "${{ github.workspace }}/lib" name: Build zig image
runs-on: ubuntu-latest
needs:
- build-alpine-image
- build-debian-image
steps:
- uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GH_CONTAINER_UNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push debian with zig - name: Build and push debian with zig
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5

View file

@ -4,27 +4,30 @@ ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \ CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \ PATH=/usr/local/cargo/bin:$PATH \
CC=clang \ CC=clang \
CC_aarch64_unknown_linux_gnu=clang \
CXX=clang++ \ CXX=clang++ \
CC_aarch64_unknown_linux_gnu="clang --sysroot=/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot" \ CXX_aarch64_unknown_linux_gnu=clang++ \
CXX_aarch64_unknown_linux_gnu="clang++ --sysroot=/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot" \ CFLAGS="--sysroot=/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot" \
C_INCLUDE_PATH=/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include CXXFLAGS="--sysroot=/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot" \
C_INCLUDE_PATH="/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/include" \
LDFLAGS="-L/usr/aarch64-unknown-linux-gnu/lib/llvm-18/lib"
ADD ./lib/llvm-16 /usr/aarch64-unknown-linux-gnu/lib/llvm-16 ADD ./lib/llvm-18 /usr/aarch64-unknown-linux-gnu/lib/llvm-18
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --fix-missing --no-install-recommends curl gnupg gpg-agent ca-certificates openssl && \ apt-get install -y --fix-missing --no-install-recommends curl gnupg gpg-agent ca-certificates openssl && \
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 && \
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /etc/apt/keyrings/llvm-snapshot.gpg && \ curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /etc/apt/keyrings/llvm-snapshot.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" >> /etc/apt/sources.list && \ echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
echo "deb-src [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" >> /etc/apt/sources.list && \ echo "deb-src [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \ apt-get update && \
apt-get install -y --fix-missing --no-install-recommends \ apt-get install -y --fix-missing --no-install-recommends \
llvm-16 \ llvm-18 \
clang-16 \ clang-18 \
lld-16 \ lld-18 \
libc++-16-dev \ libc++-18-dev \
libc++abi-16-dev \ libc++abi-18-dev \
nodejs \ nodejs \
xz-utils \ xz-utils \
rcs \ rcs \
@ -36,7 +39,7 @@ RUN apt-get update && \
curl https://sh.rustup.rs -sSf | sh -s -- -y && \ curl https://sh.rustup.rs -sSf | sh -s -- -y && \
rustup target add aarch64-unknown-linux-gnu && \ rustup target add aarch64-unknown-linux-gnu && \
npm install -g npm yarn pnpm && \ npm install -g npm yarn pnpm && \
ln -sf /usr/bin/clang-16 /usr/bin/clang && \ ln -sf /usr/bin/clang-18 /usr/bin/clang && \
ln -sf /usr/bin/clang++-16 /usr/bin/clang++ && \ ln -sf /usr/bin/clang++-18 /usr/bin/clang++ && \
ln -sf /usr/bin/lld-16 /usr/bin/lld && \ ln -sf /usr/bin/lld-18 /usr/bin/lld && \
ln -sf /usr/bin/clang-16 /usr/bin/cc ln -sf /usr/bin/clang-18 /usr/bin/cc

View file

@ -9,24 +9,23 @@ ENV RUSTUP_HOME=/usr/local/rustup \
CXX=clang++ \ CXX=clang++ \
CC_x86_64_unknown_linux_gnu=clang \ CC_x86_64_unknown_linux_gnu=clang \
CXX_x86_64_unknown_linux_gnu=clang++ \ CXX_x86_64_unknown_linux_gnu=clang++ \
RUST_TARGET=x86_64-unknown-linux-gnu \ RUST_TARGET=x86_64-unknown-linux-gnu
LDFLAGS="-fuse-ld=lld"
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --fix-missing --no-install-recommends curl gnupg gpg-agent ca-certificates openssl && \ apt-get install -y --fix-missing --no-install-recommends curl gnupg gpg-agent ca-certificates openssl && \
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 && \
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /etc/apt/keyrings/llvm-snapshot.gpg && \ curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /etc/apt/keyrings/llvm-snapshot.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" >> /etc/apt/sources.list && \ echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
echo "deb-src [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" >> /etc/apt/sources.list && \ echo "deb-src [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \ apt-get update && \
apt-get install -y --fix-missing --no-install-recommends \ apt-get install -y --fix-missing --no-install-recommends \
llvm-16 \ llvm-18 \
clang-16 \ clang-18 \
lld-16 \ lld-18 \
libc++-16-dev \ libc++-18-dev \
libc++abi-16-dev \ libc++abi-18-dev \
nodejs \ nodejs \
xz-utils \ xz-utils \
rcs \ rcs \
@ -37,10 +36,10 @@ RUN apt-get update && \
apt-get autoremove -y && \ apt-get autoremove -y && \
curl https://sh.rustup.rs -sSf | sh -s -- -y && \ curl https://sh.rustup.rs -sSf | sh -s -- -y && \
npm install -g npm yarn pnpm && \ npm install -g npm yarn pnpm && \
ln -sf /usr/bin/clang-16 /usr/bin/clang && \ ln -sf /usr/bin/clang-18 /usr/bin/clang && \
ln -sf /usr/bin/clang++-16 /usr/bin/clang++ && \ ln -sf /usr/bin/clang++-18 /usr/bin/clang++ && \
ln -sf /usr/bin/lld-16 /usr/bin/lld && \ ln -sf /usr/bin/lld-18 /usr/bin/lld && \
ln -sf /usr/bin/clang-16 /usr/bin/cc ln -sf /usr/bin/clang-18 /usr/bin/cc
RUN wget https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.xz && \ RUN wget https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.xz && \
tar -xf nasm-${NASM_VERSION}.tar.xz && \ tar -xf nasm-${NASM_VERSION}.tar.xz && \
@ -51,3 +50,8 @@ RUN wget https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_
cd / && \ cd / && \
rm -rf nasm-${NASM_VERSION} && \ rm -rf nasm-${NASM_VERSION} && \
rm nasm-${NASM_VERSION}.tar.xz rm nasm-${NASM_VERSION}.tar.xz
ENV LDFLAGS="-fuse-ld=lld --sysroot=/usr/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot" \
CFLAGS="--sysroot=/usr/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot" \
CXXFLAGS="--sysroot=/usr/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot" \
C_INCLUDE_PATH="/usr/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot/usr/include"