docker-node icon indicating copy to clipboard operation
docker-node copied to clipboard

Node 6.2.2 & node.bcrypt.js

Open adam-beck opened this issue 9 years ago • 4 comments

When using bcrypt with this image you may run into a problem if you are mounting your local node_modules folder into your docker container. There may be times when you need to recompile C++ addons (which bcrypt has). So, to do this make sure that before your container starts executing code to run npm rebuild link.

I do this by building my container and then execing into it. I then manually run npm rebuild as I haven't found a better way to do this yet.

I hope this saves somebody else the hour I wasted trying to figure this out.

Edit So an easier solution for docker compose is command: bash -c "npm rebuild && npm start" assuming npm start kicks off your server. This same method can be applied to a Dockerfile or the command line.

Edit2 Another, albeit uglier, solution is to mount the Host machines g++ compiler:

/usr/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/

adam-beck avatar Jun 26 '16 02:06 adam-beck

Is this specific to v6.2.2?

Also, is this something that could be done in your own Docker file that builds on top of the current image?

chorrell avatar Jun 28 '16 01:06 chorrell

@chorrell I don't think this is specific to v6.2.2. I'm not for sure how to change the Dockerfile so that it will run the npm rebuild command at the correct time (because the directory is a mounted volume). I tried modifiying this one and ran RUN npm rebuild right before the CMD [ "node" ]. That doesn't work.

I did mention how when using this Dockerfile you can use the command bash -c "npm rebuild && npm start". This issue was more or less created for documentation.

adam-beck avatar Jun 28 '16 14:06 adam-beck

Thanks for this, been struggling to find a solution. Was hoping to find a solution where node_modules was not copied from the host to the container. Are there downsides to that approach that I have not considered?

djskinner-sky avatar Dec 12 '16 19:12 djskinner-sky

am using the Alpine docker (https://github.com/nodejs/docker-node/blob/3b038b8a1ac8f65e3d368bedb9f979884342fdcb/6.9/alpine/Dockerfile) and faced the same error. So, edited the docker file not to remove the "&& apk del .build-deps " build dependencies but rest all the same. and hence when the npm install was performed, it worked fine.

rasekar2000 avatar Feb 12 '17 03:02 rasekar2000