-
Notifications
You must be signed in to change notification settings - Fork 536
Remove node-pre-gyp, use prebuildify #890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
recrsn
merged 12 commits into
kelektiv:master
from
thom-nic:prebuildify-and-docker-build
Nov 2, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4de3ed6
Remove node-pre-gyp, use prebuildify
thom-nic 0da2a15
updated CI scripts
thom-nic ea2a8fd
.github: added github actions
thom-nic 74ebe5a
Dockerfile: added alpine builders
thom-nic d321d0c
repetitions.test: increase timeout for ARM builds in CI
thom-nic 3c9e40d
package: remove unnecessary binary stuff
thom-nic a2855a4
test_alpine.sh remove outdated file
thom-nic 28a7198
fixed Makefile
thom-nic 96751d6
use --platform to consolidate dockerfiles
thom-nic 123a7ce
remove appveyor and travis CI
thom-nic 1f1b08f
.github: updated action versions
thom-nic ae21bf1
increase test timeout during (slow xplatform emulated) docker builds
thom-nic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.git/ | ||
.vscode/ | ||
Dockerfile* | ||
prebuilds/ | ||
node_modules/ | ||
build*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
name: Prebuildify, package, publish | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
release: | ||
types: [ prereleased, released ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
os: [linux] | ||
arch: [amd64, arm64, arm] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/setup-qemu-action@v3 | ||
with: | ||
image: tonistiigi/binfmt:latest | ||
platforms: arm,arm64 | ||
|
||
- run: > | ||
docker build . | ||
--build-arg TEST_TIMEOUT_SECONDS=30 | ||
--tag node-bcrypt-builder | ||
--platform ${{ matrix.os }}/${{ matrix.arch }} | ||
- run: > | ||
docker create | ||
--name node-bcryptjs-builder | ||
--platform ${{ matrix.os }}/${{ matrix.arch }} | ||
node-bcrypt-builder | ||
- run: docker cp "node-bcryptjs-builder:/usr/local/opt/bcrypt-js/prebuilds" . | ||
|
||
# build for Alpine: | ||
- run: > | ||
docker build -f Dockerfile-alpine . | ||
--build-arg TEST_TIMEOUT_SECONDS=30 | ||
--tag node-bcrypt-builder-alpine | ||
--platform ${{ matrix.os }}/${{ matrix.arch }} | ||
- run: > | ||
docker create | ||
--name node-bcryptjs-builder-alpine | ||
--platform ${{ matrix.os }}/${{ matrix.arch }} | ||
node-bcrypt-builder-alpine | ||
- run: docker cp "node-bcryptjs-builder-alpine:/usr/local/opt/bcrypt-js/prebuilds" . | ||
|
||
- run: find prebuilds | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: prebuild-${{ matrix.os }}-${{ matrix.arch }} | ||
path: ./prebuilds | ||
|
||
pack: | ||
needs: build | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
path: /tmp/prebuilds/ | ||
- name: Coalesce prebuilds from build matrix | ||
run: | | ||
mkdir prebuilds | ||
for d in /tmp/prebuilds/*; do | ||
cp -Rav $d/* prebuilds/ | ||
done | ||
- run: chmod a+x prebuilds/*/*.node && find prebuilds -executable -type f | ||
- run: echo "PACK_FILE=$(npm pack)" >> $GITHUB_ENV | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: package-tgz | ||
path: ${{ env.PACK_FILE }} | ||
|
||
publish-npm: | ||
needs: pack | ||
if: github.event_name == 'release' | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
registry-url: 'https://registry.npmjs.org' | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: package-tgz | ||
path: /tmp/package/ | ||
- run: npm publish /tmp/package/bcrypt*.tgz | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
|
||
publish-gpr: | ||
needs: pack | ||
if: github.event_name == 'release' | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
registry-url: https://npm.pkg.github.com/ | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: package-tgz | ||
path: /tmp/package/ | ||
- run: npm publish /tmp/package/bcrypt*.tgz | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
.lock* | ||
build* | ||
build*/ | ||
*.node | ||
*.sw[a-z] | ||
node_modules | ||
.idea/ | ||
prebuilds/ | ||
*.tgz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.lock* | ||
build*/ | ||
*.sw[a-z] |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Usage: | ||
# | ||
# docker build -t bcryptjs-builder . | ||
# CONTAINER=$(docker create bcryptjs-builder) | ||
# # Then copy the artifact to your host: | ||
# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . | ||
# docker rm "$CONTAINER" | ||
# | ||
# Use --platform to build cross-platform i.e. for ARM: | ||
# | ||
# docker build -t bcryptjs-builder --platform "linux/arm64/v8" . | ||
# CONTAINER=$docker create --platform "linux/arm64/v8" bcryptjs-builder) | ||
# # this copies the prebuilds/linux-arm artifacts | ||
# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . | ||
# docker rm "$CONTAINER" | ||
|
||
|
||
ARG FROM_IMAGE=node:18-bullseye | ||
#ARG FROM_IMAGE=arm32v7/node:16-bullseye | ||
#ARG FROM_IMAGE=arm64v8/node:16-bullseye | ||
FROM ${FROM_IMAGE} | ||
|
||
ENV project bcrypt-js | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV LC_ALL en_US.UTF-8 | ||
ENV LANG ${LC_ALL} | ||
|
||
RUN echo "#log: ${project}: Setup system" \ | ||
&& set -x \ | ||
&& apt-get update -y \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
python3 \ | ||
&& apt-get clean \ | ||
&& update-alternatives --install /usr/local/bin/python python /usr/bin/python3 20 \ | ||
&& npm i -g prebuildify@5 node-gyp@9 \ | ||
&& sync | ||
|
||
ADD . /usr/local/opt/${project} | ||
WORKDIR /usr/local/opt/${project} | ||
|
||
RUN echo "#log: ${project}: Running build" \ | ||
&& set -x \ | ||
&& npm ci \ | ||
&& npm run build | ||
|
||
ARG RUN_TESTS=true | ||
ARG TEST_TIMEOUT_SECONDS= | ||
|
||
RUN if "${RUN_TESTS}"; then \ | ||
echo "#log ${project}: Running tests" \ | ||
&& npm test; \ | ||
else \ | ||
echo "#log ${project}: Tests were skipped!"; \ | ||
fi | ||
|
||
CMD /bin/bash -l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Usage: | ||
thom-nic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# docker build -t bcryptjs-linux-alpine-builder -f Dockerfile-alpine . | ||
# CONTAINER=$(docker create bcryptjs-linux-alpine-builder) | ||
# # Then copy the artifact to your host: | ||
# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . | ||
# docker rm "$CONTAINER" | ||
|
||
ARG FROM_IMAGE=node:18-alpine | ||
FROM ${FROM_IMAGE} | ||
|
||
ENV project bcrypt-js | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV LC_ALL en_US.UTF-8 | ||
ENV LANG ${LC_ALL} | ||
|
||
RUN echo "#log: ${project}: Setup system" \ | ||
&& set -x \ | ||
&& apk add --update build-base python3 \ | ||
&& npm i -g prebuildify@5 node-gyp@9 \ | ||
&& sync | ||
|
||
ADD . /usr/local/opt/${project} | ||
WORKDIR /usr/local/opt/${project} | ||
|
||
RUN echo "#log: ${project}: Running build" \ | ||
&& set -x \ | ||
&& npm ci \ | ||
&& npm run build | ||
|
||
ARG RUN_TESTS=true | ||
ARG TEST_TIMEOUT_SECONDS= | ||
|
||
RUN if "${RUN_TESTS}"; then \ | ||
echo "#log ${project}: Running tests" \ | ||
&& npm test; \ | ||
else \ | ||
echo "#log ${project}: Tests were skipped!"; \ | ||
fi | ||
|
||
CMD /bin/bash -l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.