Skip to content
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

Prebuildify and docker build #1

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5283ad1
Refactored example with async await
lpizzinidev Sep 23, 2021
2d97681
document ESM usage (#892)
mariusa Nov 5, 2021
184200e
Version bump, security updates to sub dep npmlog
adaniels-parabol Nov 19, 2021
28ccb37
Merge pull request #905 from adaniels-parabol/patch-1
recrsn Jan 14, 2022
4c49788
Merge pull request #899 from mariusa/patch-1
recrsn Jan 14, 2022
ed47b46
fix: update travis CI Docker image repository
cokia May 13, 2022
5ce7348
Merge pull request #930 from cokia/docker-repository-change
recrsn May 14, 2022
f7f3d15
chore(appveyor): not use latest npm
cokia May 14, 2022
721a27f
chore: update Appveyor readme badge
cokia May 14, 2022
35bb3a8
Update node versions in appveyor test matrix
p-kuen Jun 6, 2022
559405f
Merge pull request #936 from p-kuen/patch-1
recrsn Jun 6, 2022
20c0e7e
Merge pull request #932 from cokia/remove-appveyor-npm-latest-version
recrsn Sep 21, 2022
a05aac4
Merge pull request #933 from cokia/update-redeme
recrsn Sep 21, 2022
229900f
Use Github actions for CI
recrsn Sep 21, 2022
cdfe6b2
Merge pull request #858 from kelektiv/github-actions
recrsn Sep 21, 2022
7f1de8f
Update dependencies
recrsn Sep 21, 2022
42e86d9
Remove old NodeJS versions
recrsn Sep 21, 2022
094dc94
Remove x86 for newer node
recrsn Sep 22, 2022
86aa111
Merge pull request #953 from kelektiv/version-update
recrsn Sep 22, 2022
fa5bc55
Fix github actions
recrsn Sep 22, 2022
8ce7edc
removed -q flags
laijonathan Sep 29, 2022
ac42d3f
added node < v16 condition
laijonathan Sep 30, 2022
e08fdff
added napi exception flag
laijonathan Sep 30, 2022
ee9117c
changed node version <16
laijonathan Sep 30, 2022
4c99e9e
fix build errors
laijonathan Oct 3, 2022
fd00ae0
reverted bcrypt.js changes
laijonathan Oct 4, 2022
5a7082a
Merge pull request #955 from kelektiv/github-actions
recrsn Oct 6, 2022
8d201d1
Move tests to use Jest
recrsn Oct 6, 2022
5a2b952
Increase test timeout
recrsn Oct 6, 2022
9d6516a
Merge pull request #958 from kelektiv/jest
recrsn Oct 6, 2022
b309eaf
Pin NAPI to v3
recrsn Oct 6, 2022
9eec9e8
Merge pull request #959 from kelektiv/release-v5-1-0
recrsn Oct 6, 2022
809ad03
Prepare for v5.1.0
recrsn Oct 6, 2022
fc225b1
Merge pull request #960 from kelektiv/release-v5-1-0
recrsn Oct 6, 2022
0884c5b
Merge pull request #894 from lpizzinidev/patch-1
recrsn Oct 6, 2022
11d2ddd
Merge pull request #968 from laijonathan/zos_fix
recrsn Oct 29, 2022
24aa2a2
Update dependencies
recrsn Aug 3, 2023
571d7ab
Merge pull request #993 from kelektiv/deps-update
recrsn Aug 3, 2023
33043f5
v5.1.1
recrsn Aug 3, 2023
564a5d8
Include platform, arch, and libc in module path
johanholmerin Sep 15, 2023
2a3c445
Merge pull request #1002 from johanholmerin/master
recrsn Sep 24, 2023
4de3ed6
Remove node-pre-gyp, use prebuildify
thom-nic Sep 3, 2021
0da2a15
updated CI scripts
thom-nic Sep 14, 2021
ea2a8fd
.github: added github actions
thom-nic Dec 14, 2021
74ebe5a
Dockerfile: added alpine builders
thom-nic Dec 16, 2021
d321d0c
repetitions.test: increase timeout for ARM builds in CI
thom-nic Oct 27, 2023
3c9e40d
package: remove unnecessary binary stuff
thom-nic Oct 31, 2023
a2855a4
test_alpine.sh remove outdated file
thom-nic Oct 31, 2023
28a7198
fixed Makefile
thom-nic Oct 31, 2023
96751d6
use --platform to consolidate dockerfiles
thom-nic Oct 31, 2023
123a7ce
remove appveyor and travis CI
thom-nic Oct 31, 2023
1f1b08f
.github: updated action versions
thom-nic Oct 31, 2023
ae21bf1
increase test timeout during (slow xplatform emulated) docker builds
thom-nic Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git/
.vscode/
Dockerfile*
prebuilds/
node_modules/
build*/
124 changes: 124 additions & 0 deletions .github/workflows/build-pack-publish.yml
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}}




42 changes: 42 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: ci

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18, 20]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- name: Test
run: npm test

build-alpine:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18, 20]
container:
image: node:${{ matrix.node-version }}-alpine
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apk add make g++ python3
- run: npm ci
- name: Test
run: |
npm test --unsafe-perm
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.lock*
build*
build*/
*.node
*.sw[a-z]
node_modules
.idea/
prebuilds/
*.tgz
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.lock*
build*/
*.sw[a-z]
63 changes: 0 additions & 63 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 5.1.0 (2022-10-06)
* Update `node-pre-gyp` to 1.0.11

# 5.1.0 (2022-10-06)
* Update `node-pre-gyp` to 1.0.10
* Replace `nodeunit` with `jest` as the testing library

# 5.0.1 (2021-02-22)

* Update `node-pre-gyp` to 1.0.0
Expand Down
57 changes: 57 additions & 0 deletions Dockerfile
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
41 changes: 41 additions & 0 deletions Dockerfile-alpine
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ compile:
npm run install

test: build
@./node_modules/nodeunit/bin/nodeunit \
@./node_modules/.bin/jest \
$(TESTS)

clean:
Expand Down
Loading
Loading