node.bcrypt.js icon indicating copy to clipboard operation
node.bcrypt.js copied to clipboard

Binaries missing for linux arm64 (docker on M1 Mac)

Open geraintwhite opened this issue 2 years ago • 14 comments

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.

geraintwhite avatar Jan 28 '22 09:01 geraintwhite

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

SamuelMS avatar Feb 01 '22 08:02 SamuelMS

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

geraintwhite avatar Feb 01 '22 08:02 geraintwhite

Hello, did you find a workaround for this issue ?

elisap360 avatar Feb 23 '22 15:02 elisap360

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 [email protected]

geraintwhite avatar Feb 23 '22 16:02 geraintwhite

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 :/

elisap360 avatar Feb 24 '22 09:02 elisap360

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)

rbourgeat avatar Feb 26 '22 09:02 rbourgeat

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.

pyc2invent avatar Feb 27 '22 06:02 pyc2invent

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

adam-ludgate avatar Apr 13 '22 15:04 adam-ludgate

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

matiaschileno avatar May 13 '22 14:05 matiaschileno

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.

pearnold avatar Jun 18 '22 13:06 pearnold

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) 🤣.

fdelucchijr avatar Jun 19 '22 06:06 fdelucchijr

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

rfc2119 avatar Aug 29 '22 12:08 rfc2119

same problem here

ramonpaolo avatar Aug 29 '22 18:08 ramonpaolo

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.

TeemuKoivisto avatar Sep 03 '22 19:09 TeemuKoivisto

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)

recrsn avatar Oct 06 '22 07:10 recrsn

@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

pketh avatar Feb 13 '23 15:02 pketh

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

CTimmerman avatar Apr 03 '23 12:04 CTimmerman

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

pketh avatar Apr 03 '23 15:04 pketh

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.

CTimmerman avatar Apr 04 '23 13:04 CTimmerman