From 4d2c6e430cfd5475719f4ab880bbfc9665da7522 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 30 Oct 2024 18:31:06 +0200 Subject: [PATCH] Prebuild images also for arm64 --- .dockerignore | 9 +++++++++ .github/workflows/prebuild.yml | 34 ++++++++++++++-------------------- .prebuildrc | 4 ++-- Dockerfile.alpine | 9 +++++++++ Dockerfile.debian | 13 +++++++++++++ package.json | 4 ++-- 6 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile.alpine create mode 100644 Dockerfile.debian diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2393470 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.git +.gitignore +.dockerignore +Dockerfile* +examples +node_modules +out +prebuilds +spec diff --git a/.github/workflows/prebuild.yml b/.github/workflows/prebuild.yml index 0e30037..e1644c0 100644 --- a/.github/workflows/prebuild.yml +++ b/.github/workflows/prebuild.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ macos-latest, windows-latest ] steps: - uses: actions/checkout@v4 - name: Use nodejs @@ -30,38 +30,32 @@ jobs: npm install --ignore-scripts - name: Build run: | - npx prebuild --target 18.0.0 - npx prebuild --target 20.0.0 - npx prebuild --target 22.0.0 + npx -y prebuild - name: Upload run: | - npx prebuild --upload-all ${{ secrets.UPLOAD_TOKEN }} + npx -y prebuild --upload-all ${{ secrets.UPLOAD_TOKEN }} env: MAKEFLAGS: -j4 - prebuild-alpine: - name: alpine + prebuild-linux: + name: ${{ matrix.os }} runs-on: ubuntu-latest - container: node:alpine + strategy: + matrix: + os: [ debian, alpine ] steps: - uses: actions/checkout@v4 - name: Use nodejs uses: actions/setup-node@v4 with: node-version: latest - - name: Install build deps - run: | - apk add g++ make python3 - - name: Dependencies - run: | - npm install --ignore-scripts + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Build run: | - npx prebuild --target 18.0.0 - npx prebuild --target 20.0.0 - npx prebuild --target 22.0.0 + docker buildx build --platform linux/amd64,linux/arm64 . -f Dockerfile.${{ matrix.os }} --output prebuilds - name: Upload run: | - npx prebuild --upload-all ${{ secrets.UPLOAD_TOKEN }} - env: - MAKEFLAGS: -j4 + npx -y prebuild --upload-all ${{ secrets.UPLOAD_TOKEN }} diff --git a/.prebuildrc b/.prebuildrc index c9a5002..588cfb6 100644 --- a/.prebuildrc +++ b/.prebuildrc @@ -1,8 +1,8 @@ { "target": [ "18.20.4", - "20.16.0", - "22.5.1" + "20.18.0", + "22.11.0" ], "strip": true } diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 0000000..2a80996 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,9 @@ +FROM node:22-alpine3.20 AS build +WORKDIR /isolated-vm +RUN apk add g++ make python3 +COPY . . +RUN npm install --ignore-scripts +RUN MAKEFLAGS=-j$(nproc) npx -y prebuild + +FROM scratch +COPY --from=build /isolated-vm/prebuilds . diff --git a/Dockerfile.debian b/Dockerfile.debian new file mode 100644 index 0000000..fef1b1c --- /dev/null +++ b/Dockerfile.debian @@ -0,0 +1,13 @@ +FROM node:22-bookworm-slim AS build +WORKDIR /isolated-vm +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + g++ \ + make \ + python3 +COPY . . +RUN npm install --ignore-scripts +RUN MAKEFLAGS=-j$(nproc) npx -y prebuild + +FROM scratch +COPY --from=build /isolated-vm/prebuilds . diff --git a/package.json b/package.json index 8ddbb2b..57e91e2 100644 --- a/package.json +++ b/package.json @@ -14,11 +14,11 @@ "test": "node test.js" }, "dependencies": { - "prebuild-install": "^7.1.1" + "prebuild-install": "^7.1.2" }, "devDependencies": { "isolated-vm": ".", - "prebuild": "^13.0.0" + "prebuild": "^13.0.1" }, "binary": { "module_path": "out"