A Docker image to prebuild Node.js native addons using devtoolset-7-toolchain-centos7 image
With GitHub Actions:
- Create a workflow file (say,
.github/workflows/prebuild.yml
)
name: Prebuild Package
on:
push:
tags:
- '*'
jobs:
prebuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.3
with:
node-version: 14
- run: npm ci
- run: npm run build
- run: |
docker run --rm -v $(pwd):/usr/src/app wildwildangel/docker-prebuild-alpine npx prebuild -r napi -u ${{ secrets.GITHUB_TOKEN }}
docker run --rm -v $(pwd):/usr/src/app wildwildangel/docker-prebuild-devtoolset-7-toolchain-centos7 npx prebuild -r napi -u ${{ secrets.GITHUB_TOKEN }}
- Update your
package.json
, add something like this intoscripts
:
"install": "prebuild-install || node-gyp rebuild"
The actual command may differ, please consult with prebuild-install documentation for details.
- Add
prebuild-install
todependencies
, andprebuild
todevDependencies
:
npm i prebuild-install
npm i -D prebuild