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