Skip to content

Commit a72f076

Browse files
murat-doganachingbrain
authored andcommitted
chore: build using docker
1 parent 7bbb7b3 commit a72f076

File tree

3 files changed

+90
-41
lines changed

3 files changed

+90
-41
lines changed

.github/workflows/build-linux.yml

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,34 @@ jobs:
2121
arch: [amd64, arm64, arm]
2222
platform: [debian, alpine]
2323
include:
24-
# Set baselines per platform
25-
- triple: "alpine-linux-musl"
26-
platform: alpine
24+
# Platform-specific baselines
25+
- platform: alpine
26+
triple: alpine-linux-musl
2727
version: 3.16
2828
libc: musl
2929
gcc_install: clang lld
3030
gcc: clang
3131
gxx: clang++
32-
# libc is intentionally not set here, as prebuild-install requires libc to not be set for glibc builds
33-
- triple: "linux-gnu"
34-
platform: debian
32+
- platform: debian
33+
triple: linux-gnu
3534
version: bullseye
36-
# Set baselines per architecture
37-
- triple_arch: x86_64
35+
# libc intentionally not set (prebuild requirement)
36+
37+
# Arch-specific baselines
38+
- arch: amd64
39+
triple_arch: x86_64
3840
node_arch: x64
39-
arch: amd64
40-
- triple_arch: armv7
41+
- arch: arm64
42+
triple_arch: aarch64
43+
node_arch: arm64
44+
flags: -march=armv8-a -fPIC
45+
- arch: arm
46+
triple_arch: armv7
4147
node_arch: arm
4248
triple_postfix: eabihf
43-
arch: arm
4449
flags: -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -fPIC
45-
- triple_arch: aarch64
46-
node_arch: arm64
47-
arch: arm64
48-
flags: -march=armv8-a -fPIC
49-
# Set edge case overrides for specific platform + architecture
50-
# also define gcc commands for each architecture
50+
51+
# Platform + Arch overrides (needed for proper toolchain)
5152
- arch: amd64
5253
platform: debian
5354
gcc_install: gcc g++
@@ -58,11 +59,9 @@ jobs:
5859
gcc_install: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
5960
gcc: aarch64-linux-gnu-gcc
6061
gxx: aarch64-linux-gnu-g++
61-
# debian uses the triple `arm-linux-gnueabihf` instead of alpine's `armv7-alpine-linux-musleabihf`
62-
# because of this, we explicitly override triple_arch for debian arm
63-
- triple_arch: arm
64-
arch: arm
62+
- arch: arm
6563
platform: debian
64+
triple_arch: arm
6665
gcc_install: gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
6766
gcc: arm-linux-gnueabihf-gcc
6867
gxx: arm-linux-gnueabihf-g++
@@ -74,42 +73,64 @@ jobs:
7473
echo "This workflow should not be triggered with workflow_dispatch on a branch other than master"
7574
exit 1
7675
- uses: actions/checkout@v4
76+
7777
- name: Use Node.js ${{ matrix.node-version }}
7878
uses: actions/setup-node@v4
7979
with:
8080
node-version: ${{ matrix.node-version }}
81+
8182
- name: Install node dependencies
8283
run: npm install --ignore-scripts
8384
env:
8485
CI: true
86+
8587
- if: matrix.arch != 'amd64'
8688
name: Set up QEMU
8789
uses: docker/setup-qemu-action@v3
8890
with:
8991
platforms: ${{ matrix.arch }}
92+
9093
- name: Install system dependencies
9194
run: |
9295
sudo apt update
93-
sudo apt install -y podman ninja-build ${{ matrix.gcc_install }}
94-
- name: List installed libc
95-
run: apt list --installed | grep libc6-dev
96-
- name: Build sysroot
97-
run: sudo podman build --isolation=chroot -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} ./build-containers --file Dockerfile.${{ matrix.platform }} --platform linux/${{ matrix.arch }} --build-arg="version=${{ matrix.version }}" --build-arg="node_version=${{ matrix.node-version }}"
98-
- name: Mount sysroot
99-
id: sysroot
100-
run: echo "sysroot=$(sudo podman image mount ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }})" >> $GITHUB_OUTPUT
96+
sudo apt install -y podman
97+
98+
- name: Prepare build container
99+
run: >
100+
sudo podman build
101+
--isolation=chroot
102+
-t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }}
103+
./build-containers
104+
--file Dockerfile.${{ matrix.platform }}
105+
--platform linux/${{ matrix.arch }}
106+
--build-arg version=${{ matrix.version }}
107+
--build-arg node_version=${{ matrix.node-version }}
108+
--build-arg gcc_install="${{ matrix.gcc_install }}"
109+
101110
- name: Build
102-
run: sudo --preserve-env=SYSROOT,TRIPLE,COMPILER_FLAGS,LIBC,GCC,GXX,CI,PATH node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --backend cmake-js -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/ci.cmake
103-
env:
104-
SYSROOT: ${{ steps.sysroot.outputs.sysroot }}
105-
TRIPLE: ${{ matrix.triple_arch }}-${{ matrix.triple }}${{ matrix.triple_postfix }}
106-
COMPILER_FLAGS: ${{ matrix.flags }}
107-
LIBC: ${{ matrix.libc }}
108-
GCC: ${{ matrix.gcc }}
109-
GXX: ${{ matrix.gxx }}
110-
CI: true
111+
run: |
112+
sudo podman run --rm \
113+
-e TRIPLE=${{ matrix.triple_arch }}-${{ matrix.triple }}${{ matrix.triple_postfix }} \
114+
-e COMPILER_FLAGS="${{ matrix.flags }}" \
115+
-e LIBC=${{ matrix.libc }} \
116+
-e GCC=${{ matrix.gcc }} \
117+
-e GXX=${{ matrix.gxx }} \
118+
-e CI=true \
119+
-v ${{ github.workspace }}:/usr/app \
120+
--platform linux/${{ matrix.arch }} \
121+
-w /usr/app \
122+
ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} \
123+
node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --backend cmake-js -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/ci.cmake
124+
111125
- name: Test
112-
run: sudo podman run --rm -v $(pwd):/usr/app/ -e CI=true --platform linux/${{ matrix.arch }} -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} npm run test
126+
run: >
127+
sudo podman run --rm
128+
-v ${{ github.workspace }}:/usr/app/
129+
-e CI=true
130+
--platform linux/${{ matrix.arch }}
131+
-t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }}
132+
npm run test
133+
113134
- name: Upload
114135
run: sudo --preserve-env=CI,LIBC node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --upload -u ${{ secrets.GITHUB_TOKEN }}
115136
env:

build-containers/Dockerfile.alpine

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
ARG version=3.16
22
ARG node_version=18
3+
4+
# Accept build args
5+
ARG gcc_install
6+
37
FROM node:${node_version}-alpine${version}
4-
RUN apk add build-base openssl-libs-static openssl-dev
8+
9+
RUN apk add \
10+
build-base \
11+
git \
12+
libc-dev \
13+
python3 \
14+
make \
15+
musl-dev \
16+
openssl-libs-static \
17+
openssl-dev \
18+
cmake \
19+
ninja \
20+
clang \
21+
lld \
22+
${gcc_install}
523

624
WORKDIR /usr/app/

build-containers/Dockerfile.debian

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
ARG version=bullseye
22
ARG node_version=18
3+
4+
# Accept build args
5+
ARG gcc_install
6+
37
FROM node:${node_version}-${version}
8+
49
RUN apt update
5-
RUN apt install -y build-essential libssl-dev
10+
RUN apt install -y --no-install-recommends \
11+
build-essential \
12+
libssl-dev \
13+
cmake \
14+
ninja-build \
15+
${gcc_install}
616

717
WORKDIR /usr/app/

0 commit comments

Comments
 (0)