kelektiv / node.bcrypt.js

bcrypt for NodeJs
MIT License
7.43k stars 510 forks source link

Binaries missing for linux arm64 (docker on M1 Mac) #917

Closed geraintwhite closed 1 year ago

geraintwhite commented 2 years ago

Installing the module inside docker on an M1 Mac fails due to missing binaries at the URL https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-glibc.tar.gz.

I can see on the releases page that the darwin arm64 binary exists, but not the linux arm64 binary.

SamuelMS commented 2 years ago

Can confirm; build works on the M1 host but not within Docker. Downgrading to 5.0.0 solves the issue.

geraintwhite commented 2 years ago

The irony is that 5.0.0 doesn't have the darwin arm64 binaries uploaded so the build fails on the M1 host 🤷‍♂️

elisap360 commented 2 years ago

Hello, did you find a workaround for this issue ?

geraintwhite commented 2 years ago

I have version 5.0.1 in my package.json for use on macOS (M1 and x86) and put the following line in my Dockerfile.

RUN npm install bcrypt@5.0.0
elisap360 commented 2 years ago

Ok thanks ! It wasnt enough for me to just change the package I had to use this method https://vineethbharadwaj.medium.com/m1-mac-switching-terminal-between-x86-64-and-arm64-e45f324184d9 to switch from arm64 to x86 and reinstall all my packages :/

rbourgeat commented 2 years ago

I have the same problem, when i downgrade to 5.0.0 i have Error: Error loading shared library /app_backend/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: Exec format error and this https://github.com/kelektiv/node.bcrypt.js/issues/824 not solve my problem... Any idea ??? (i am on mac m1 and i use docker with node:16-alpine3.11)

pyc2invent commented 2 years ago

similarly, docker failed to build for 5.0.1 due to: https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-musl.tar.gz being missing from the release.

adam-ludgate commented 2 years ago

Any idea as to why 5.0.1 never got a linux arm64 build?

matiaschileno commented 2 years ago

similarly, docker failed to build for 5.0.1 due to: https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-musl.tar.gz being missing from the release.

Same here

pearnold commented 2 years ago

When using an image from dockerhub (basing on alpine), i worked around the issue by building it using this file:

FROM josephdadams/tallyarbiter:latest

RUN apk add --no-cache make gcc g++ python3 && \
    npm rebuild bcrypt --build-from-source && \
    apk del make gcc g++ python3

Replace "josephdadams/tallyarbiter:latest" with your source image.

fdelucchijr commented 2 years ago
FROM josephdadams/tallyarbiter:latest

RUN apk add --no-cache make gcc g++ python3 && \
    npm rebuild bcrypt --build-from-source && \
    apk del make gcc g++ python3

@pearnold I use this same command in order to execute bcrypt in docker, but it isn’t an elegant way because adds a lot of time into the build process. Is anyone using a more productive method? One idea I have was to upload a node image based in alpine with bcrypt already preinstaled and builded, but I haven’t had the time to do it in a more elegant way than only building a section of my dockerfile.

Please, any idea is welcomed. I even doubted if maybe it was better to move into something like Ory Kratos (ignoring at all that the project is still in MVP state) 🤣.

rfc2119 commented 2 years ago

As @adam-ludgate said, any idea why v5.0.1 did not get an arm64 build ?

ramonpaolo commented 2 years ago

same problem here

TeemuKoivisto commented 2 years ago

It's almost funny how such a crucial package is broken due to a missing release and the best fix is to pin the version.

recrsn commented 1 year ago

The best fix is to compile yourself.

The lack of CI infrastructure and the inability of me to get an ARM machine. Travis provided arm64 machines in the past during the 5.0 release but now they don't work anymore. Binaries were always best-effort basis.

The only decent ones are macs right now and I live in a country where it's not particularly cheap to get one (more than a month's salary, even after having top-of-the-market pay)

pketh commented 1 year ago

@recrsn Sorry to follow up on such an old thread, but if not being able to get an m1/m2 mac is still an issue for you, have you considered opening up github sponsorships? Soooo many people use/rely on this project and you definitely deserve something for all your work on this – especially if it helps enable something as helpful as native mac builds

CTimmerman commented 1 year ago

I read bcryptjs is a drop-in replacement which is cross-platform as it's written in a higher language.

pketh commented 1 year ago

oh that's v interesting , taking a look now. Are there performance implications of it being higher lvl?

CTimmerman commented 1 year ago

https://javascript.plainenglish.io/node-js-bcrypt-vs-bcryptjs-benchmark-69a9e8254cc2 says:

Async functions Bcrypt is 1.8 times faster than bcryptjs in generating hash passwords and 1.8 times faster in comparing function.

Sync functions Bcrypt is 3.1 times faster than bcryptjs in generating hash passwords and 1.3 times faster in comparing function.