-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #890 from thom-nic/prebuildify-and-docker-build
- Loading branch information
Showing
17 changed files
with
367 additions
and
901 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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: | ||
# | ||
# 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 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.