Node.bcrypt.js: Bcrypt on docker node:9.4-alpine crash application

Created on 6 Feb 2018  路  2Comments  路  Source: kelektiv/node.bcrypt.js

Hello !

I am working with docker for a dev environment and I am stuck to make bcrypt work on node alpine image.

I have of course read the wiki and the issue

Here is my dockerfile:

FROM node:9.4-alpine

WORKDIR /webapp

COPY package*.json ./

RUN apk update && apk upgrade \
    && apk add --no-cache git \
    && apk --no-cache add --virtual builds-deps build-base python \
    && npm install -g nodemon cross-env eslint npm-run-all node-gyp node-pre-gyp && npm install\
    && npm rebuild bcrypt --build-from-source

COPY . .

EXPOSE 3000 3123

ENTRYPOINT ["/usr/local/bin/npm", "run"]

Here is what I get in the install bcrypt

> [email protected] install /webapp/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

[bcrypt] Success: "/webapp/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote

And this in the rebuild script:

> [email protected] install /webapp/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

make: Entering directory '/webapp/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
In file included from ../../nan/nan.h:192:0,
                 from ../src/bcrypt_node.cc:1:
../../nan/nan_maybe_43_inl.h: In function 'Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)':
../../nan/nan_maybe_43_inl.h:112:73: warning: 'v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)' is deprecated: Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
                                                                         ^
In file included from /root/.node-gyp/9.4.0/include/node/v8.h:26:0,
                 from /root/.node-gyp/9.4.0/include/node/node.h:63,
                 from ../../nan/nan.h:49,
                 from ../src/bcrypt_node.cc:1:
/root/.node-gyp/9.4.0/include/node/v8.h:3115:29: note: declared here
                 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
                             ^
/root/.node-gyp/9.4.0/include/node/v8config.h:318:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
  COPY /webapp/node_modules/bcrypt/lib/binding/bcrypt_lib.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/webapp/node_modules/bcrypt/build'
[email protected] /webapp/node_modules/bcrypt
Removing intermediate container e65bf3d0c442

Everything is working well until I call bcrypt.compare and then the application crash without error message

I try to decrease version but I had other probleme with other repository so can't say if its specific to node 9.4 or not.

Most helpful comment

Hmm,
Looks like you can successfully compile, but something else is happening.

Do you have a dockerignore configured that excludes node_modules from the host?

I think the copy step might be replacing files from your host machine instead of the locally compiled ones. Try doing npm install after the COPY

All 2 comments

Hmm,
Looks like you can successfully compile, but something else is happening.

Do you have a dockerignore configured that excludes node_modules from the host?

I think the copy step might be replacing files from your host machine instead of the locally compiled ones. Try doing npm install after the COPY

You are rigth !

I copied the dockerfile from an other project of mine and forget the dockerignore.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surendra172001 picture surendra172001  路  5Comments

Z3roCoder picture Z3roCoder  路  5Comments

youngrrrr picture youngrrrr  路  5Comments

potts99 picture potts99  路  5Comments

alanosman picture alanosman  路  3Comments