Node.bcrypt.js: Bcrypt fails install on node11-alpine docker image even with rebuild from source

Created on 19 Jul 2019  Â·  4Comments  Â·  Source: kelektiv/node.bcrypt.js

Docker build output log:

Step 8/12 : RUN npm rebuild bcrypt --build-from-source
 ---> Running in d72bc81aad44

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

node-pre-gyp WARN Using request for node-pre-gyp https download
make: Entering directory '/opt/app/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 ../src/bcrypt_node.cc:1:
../node_modules/nan/nan.h: In function 'void Nan::AsyncQueueWorker(Nan::AsyncWorker*)':
../node_modules/nan/nan.h:2232:62: warning: cast between incompatible function types from 'void (*)(uv_work_t*)' {aka 'void (*)(uv_work_s*)'} to 'uv_after_work_cb' {aka 'void (*)(uv_work_s*, int)'} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
In file included from ../node_modules/nan/nan.h:53,
                 from ../src/bcrypt_node.cc:1:
../src/bcrypt_node.cc: At global scope:
/root/.node-gyp/11.15.0/include/node/node.h:544:43: warning: cast between incompatible function types from 'void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void (*)(v8::Local<v8::Object>)'} to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
       (node::addon_register_func) (regfunc),                          \
                                           ^
/root/.node-gyp/11.15.0/include/node/node.h:578:3: note: in expansion of macro 'NODE_MODULE_X'
   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
   ^~~~~~~~~~~~~
../src/bcrypt_node.cc:378:1: note: in expansion of macro 'NODE_MODULE'
 NODE_MODULE(bcrypt_lib, init);
 ^~~~~~~~~~~
In file included from /root/.node-gyp/11.15.0/include/node/node.h:63,
                 from ../node_modules/nan/nan.h:53,
                 from ../src/bcrypt_node.cc:1:
/root/.node-gyp/11.15.0/include/node/v8.h: In instantiation of 'void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)]':
/root/.node-gyp/11.15.0/include/node/node_object_wrap.h:84:78:   required from here
/root/.node-gyp/11.15.0/include/node/v8.h:9710:16: warning: cast between incompatible function types from 'v8::WeakCallbackInfo<node::ObjectWrap>::Callback' {aka 'void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)'} to 'Callback' {aka 'void (*)(const v8::WeakCallbackInfo<void>&)'} [-Wcast-function-type]
                reinterpret_cast<Callback>(callback), type);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/.node-gyp/11.15.0/include/node/v8.h: In instantiation of 'void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]':
../node_modules/nan/nan_object_wrap.h:65:61:   required from here
/root/.node-gyp/11.15.0/include/node/v8.h:9710:16: warning: cast between incompatible function types from 'v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback' {aka 'void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)'} to 'Callback' {aka 'void (*)(const v8::WeakCallbackInfo<void>&)'} [-Wcast-function-type]
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
  COPY /opt/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/opt/app/node_modules/bcrypt/build'
[email protected] /opt/app/node_modules/bcrypt

Once the app starts I get the following:

app_1  | internal/modules/cjs/loader.js:857
app_1  |   return process.dlopen(module, path.toNamespacedPath(filename));
app_1  |                  ^
app_1  |
app_1  | Error: Error loading shared library /opt/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: Exec format error
app_1  |     at Object.Module._extensions..node (internal/modules/cjs/loader.js:857:18)
app_1  |     at Module.load (internal/modules/cjs/loader.js:685:32)
app_1  |     at Function.Module._load (internal/modules/cjs/loader.js:620:12)
app_1  |     at Module.require (internal/modules/cjs/loader.js:723:19)
app_1  |     at require (internal/modules/cjs/helpers.js:14:16)
app_1  |     at Object.<anonymous> (/opt/app/node_modules/bcrypt/bcrypt.js:6:16)
app_1  |     at Module._compile (internal/modules/cjs/loader.js:816:30)
app_1  |     at Module._compile (/opt/app/node_modules/pirates/lib/index.js:99:24)
app_1  |     at Module._extensions..js (internal/modules/cjs/loader.js:827:10)
app_1  |     at Object.newLoader [as .js] (/opt/app/node_modules/pirates/lib/index.js:104:7)
app_1  | npm ERR! code ELIFECYCLE

My Docker file:

FROM node:11-alpine

RUN mkdir -p /opt/app

ENV NODE_ENV production

WORKDIR /opt/app
COPY . /opt/app/

RUN apk add --no-cache make gcc g++ python && \
  npm install && \
  apk del make gcc g++ python

RUN npm rebuild bcrypt --build-from-source

RUN npm run build

EXPOSE 8000

CMD [ "npm", "start" ]

Most helpful comment

The logs show that the module is built correctly but I think you are
pulling in node_modules from the host. Check if node_modules is in your
dockerignore

On Fri, 19 Jul, 2019, 9:32 PM Carlos Matias, notifications@github.com
wrote:

Docker build output log:

Step 8/12 : RUN npm rebuild bcrypt --build-from-source
---> Running in d72bc81aad44

[email protected] install /opt/app/node_modules/bcrypt
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
make: Entering directory '/opt/app/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 ../src/bcrypt_node.cc:1:
../node_modules/nan/nan.h: In function 'void Nan::AsyncQueueWorker(Nan::AsyncWorker)':
../node_modules/nan/nan.h:2232:62: warning: cast between incompatible function types from 'void (
)(uv_work_t)' {aka 'void ()(uv_work_s)'} to 'uv_after_work_cb' {aka 'void ()(uv_work_s, int)'} [-Wcast-function-type]
, reinterpret_cast(AsyncExecuteComplete)
^
In file included from ../node_modules/nan/nan.h:53,
from ../src/bcrypt_node.cc:1:
../src/bcrypt_node.cc: At global scope:
/root/.node-gyp/11.15.0/include/node/node.h:544:43: warning: cast between incompatible function types from 'void (
)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void ()(v8::Local)'} to 'node::addon_register_func' {aka 'void ()(v8::Local, v8::Local, void)'} [-Wcast-function-type]
(node::addon_register_func) (regfunc), \
^
/root/.node-gyp/11.15.0/include/node/node.h:578:3: note: in expansion of macro 'NODE_MODULE_X'
NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
^~~~~
../src/bcrypt_node.cc:378:1: note: in expansion of macro 'NODE_MODULE'
NODE_MODULE(bcrypt_lib, init);
^~~
In file included from /root/.node-gyp/11.15.0/include/node/node.h:63,
from ../node_modules/nan/nan.h:53,
from ../src/bcrypt_node.cc:1:
/root/.node-gyp/11.15.0/include/node/v8.h: In instantiation of 'void v8::PersistentBase::SetWeak(P
, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfo&)]':
/root/.node-gyp/11.15.0/include/node/node_object_wrap.h:84:78: required from here
/root/.node-gyp/11.15.0/include/node/v8.h:9710:16: warning: cast between incompatible function types from 'v8::WeakCallbackInfo::Callback' {aka 'void (
)(const v8::WeakCallbackInfo&)'} to 'Callback' {aka 'void ()(const v8::WeakCallbackInfo&)'} [-Wcast-function-type]
reinterpret_cast(callback), type);
^~~~~~~~
/root/.node-gyp/11.15.0/include/node/v8.h: In instantiation of 'void v8::PersistentBase::SetWeak(P
, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfo&)]':
../node_modules/nan/nan_object_wrap.h:65:61: required from here
/root/.node-gyp/11.15.0/include/node/v8.h:9710:16: warning: cast between incompatible function types from 'v8::WeakCallbackInfo::Callback' {aka 'void (
)(const v8::WeakCallbackInfo&)'} to 'Callback' {aka 'void (*)(const v8::WeakCallbackInfo&)'} [-Wcast-function-type]
SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
COPY Release/bcrypt_lib.node
COPY /opt/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node
TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/opt/app/node_modules/bcrypt/build'
[email protected] /opt/app/node_modules/bcrypt

Once the app starts I get the following:

app_1 | internal/modules/cjs/loader.js:857
app_1 | return process.dlopen(module, path.toNamespacedPath(filename));
app_1 | ^
app_1 |
app_1 | Error: Error loading shared library /opt/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: Exec format error
app_1 | at Object.Module._extensions..node (internal/modules/cjs/loader.js:857:18)
app_1 | at Module.load (internal/modules/cjs/loader.js:685:32)
app_1 | at Function.Module._load (internal/modules/cjs/loader.js:620:12)
app_1 | at Module.require (internal/modules/cjs/loader.js:723:19)
app_1 | at require (internal/modules/cjs/helpers.js:14:16)
app_1 | at Object. (/opt/app/node_modules/bcrypt/bcrypt.js:6:16)
app_1 | at Module._compile (internal/modules/cjs/loader.js:816:30)
app_1 | at Module._compile (/opt/app/node_modules/pirates/lib/index.js:99:24)
app_1 | at Module._extensions..js (internal/modules/cjs/loader.js:827:10)
app_1 | at Object.newLoader [as .js] (/opt/app/node_modules/pirates/lib/index.js:104:7)
app_1 | npm ERR! code ELIFECYCLE

My Docker file:

FROM node:11-alpine

RUN mkdir -p /opt/app

ENV NODE_ENV production

WORKDIR /opt/app
COPY . /opt/app/

RUN apk add --no-cache make gcc g++ python && \
npm install && \
apk del make gcc g++ python

RUN npm rebuild bcrypt --build-from-source

RUN npm run build

EXPOSE 8000

CMD [ "npm", "start" ]

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/kelektiv/node.bcrypt.js/issues/741?email_source=notifications&email_token=AEAJUT4RR6CSQ4PZWJGP72TQAHQQ3A5CNFSM4IFHO2H2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HAJZ4NQ,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEAJUT25D4AH7IW3AJ62NQDQAHQQ3ANCNFSM4IFHO2HQ
.

All 4 comments

The logs show that the module is built correctly but I think you are
pulling in node_modules from the host. Check if node_modules is in your
dockerignore

On Fri, 19 Jul, 2019, 9:32 PM Carlos Matias, notifications@github.com
wrote:

Docker build output log:

Step 8/12 : RUN npm rebuild bcrypt --build-from-source
---> Running in d72bc81aad44

[email protected] install /opt/app/node_modules/bcrypt
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
make: Entering directory '/opt/app/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 ../src/bcrypt_node.cc:1:
../node_modules/nan/nan.h: In function 'void Nan::AsyncQueueWorker(Nan::AsyncWorker)':
../node_modules/nan/nan.h:2232:62: warning: cast between incompatible function types from 'void (
)(uv_work_t)' {aka 'void ()(uv_work_s)'} to 'uv_after_work_cb' {aka 'void ()(uv_work_s, int)'} [-Wcast-function-type]
, reinterpret_cast(AsyncExecuteComplete)
^
In file included from ../node_modules/nan/nan.h:53,
from ../src/bcrypt_node.cc:1:
../src/bcrypt_node.cc: At global scope:
/root/.node-gyp/11.15.0/include/node/node.h:544:43: warning: cast between incompatible function types from 'void (
)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void ()(v8::Local)'} to 'node::addon_register_func' {aka 'void ()(v8::Local, v8::Local, void)'} [-Wcast-function-type]
(node::addon_register_func) (regfunc), \
^
/root/.node-gyp/11.15.0/include/node/node.h:578:3: note: in expansion of macro 'NODE_MODULE_X'
NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
^~~~~
../src/bcrypt_node.cc:378:1: note: in expansion of macro 'NODE_MODULE'
NODE_MODULE(bcrypt_lib, init);
^~~
In file included from /root/.node-gyp/11.15.0/include/node/node.h:63,
from ../node_modules/nan/nan.h:53,
from ../src/bcrypt_node.cc:1:
/root/.node-gyp/11.15.0/include/node/v8.h: In instantiation of 'void v8::PersistentBase::SetWeak(P
, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfo&)]':
/root/.node-gyp/11.15.0/include/node/node_object_wrap.h:84:78: required from here
/root/.node-gyp/11.15.0/include/node/v8.h:9710:16: warning: cast between incompatible function types from 'v8::WeakCallbackInfo::Callback' {aka 'void (
)(const v8::WeakCallbackInfo&)'} to 'Callback' {aka 'void ()(const v8::WeakCallbackInfo&)'} [-Wcast-function-type]
reinterpret_cast(callback), type);
^~~~~~~~
/root/.node-gyp/11.15.0/include/node/v8.h: In instantiation of 'void v8::PersistentBase::SetWeak(P
, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void ()(const v8::WeakCallbackInfo&)]':
../node_modules/nan/nan_object_wrap.h:65:61: required from here
/root/.node-gyp/11.15.0/include/node/v8.h:9710:16: warning: cast between incompatible function types from 'v8::WeakCallbackInfo::Callback' {aka 'void (
)(const v8::WeakCallbackInfo&)'} to 'Callback' {aka 'void (*)(const v8::WeakCallbackInfo&)'} [-Wcast-function-type]
SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
COPY Release/bcrypt_lib.node
COPY /opt/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node
TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/opt/app/node_modules/bcrypt/build'
[email protected] /opt/app/node_modules/bcrypt

Once the app starts I get the following:

app_1 | internal/modules/cjs/loader.js:857
app_1 | return process.dlopen(module, path.toNamespacedPath(filename));
app_1 | ^
app_1 |
app_1 | Error: Error loading shared library /opt/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: Exec format error
app_1 | at Object.Module._extensions..node (internal/modules/cjs/loader.js:857:18)
app_1 | at Module.load (internal/modules/cjs/loader.js:685:32)
app_1 | at Function.Module._load (internal/modules/cjs/loader.js:620:12)
app_1 | at Module.require (internal/modules/cjs/loader.js:723:19)
app_1 | at require (internal/modules/cjs/helpers.js:14:16)
app_1 | at Object. (/opt/app/node_modules/bcrypt/bcrypt.js:6:16)
app_1 | at Module._compile (internal/modules/cjs/loader.js:816:30)
app_1 | at Module._compile (/opt/app/node_modules/pirates/lib/index.js:99:24)
app_1 | at Module._extensions..js (internal/modules/cjs/loader.js:827:10)
app_1 | at Object.newLoader [as .js] (/opt/app/node_modules/pirates/lib/index.js:104:7)
app_1 | npm ERR! code ELIFECYCLE

My Docker file:

FROM node:11-alpine

RUN mkdir -p /opt/app

ENV NODE_ENV production

WORKDIR /opt/app
COPY . /opt/app/

RUN apk add --no-cache make gcc g++ python && \
npm install && \
apk del make gcc g++ python

RUN npm rebuild bcrypt --build-from-source

RUN npm run build

EXPOSE 8000

CMD [ "npm", "start" ]

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/kelektiv/node.bcrypt.js/issues/741?email_source=notifications&email_token=AEAJUT4RR6CSQ4PZWJGP72TQAHQQ3A5CNFSM4IFHO2H2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HAJZ4NQ,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEAJUT25D4AH7IW3AJ62NQDQAHQQ3ANCNFSM4IFHO2HQ
.

Thanks a lot @agathver, I was actually ignoring the host's node_modules but I was uncorrectly mouting my volumes which were passing the node_modules to the container.

Thanks @recrsn! This solution solved my problem.

thankkk @recrsn

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alanosman picture alanosman  Â·  3Comments

lagmanzaza picture lagmanzaza  Â·  6Comments

Z3roCoder picture Z3roCoder  Â·  5Comments

japita-se picture japita-se  Â·  4Comments

potts99 picture potts99  Â·  5Comments