Reputation: 4627
I get following error when I try docker-compose up
graphql_1 | Error: Error loading shared library /usr/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: Exec format error
graphql_1 | at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
graphql_1 | at Module.load (internal/modules/cjs/loader.js:599:32)
graphql_1 | at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
graphql_1 | at Function.Module._load (internal/modules/cjs/loader.js:530:3)
graphql_1 | at Module.require (internal/modules/cjs/loader.js:637:17)
graphql_1 | at require (internal/modules/cjs/helpers.js:20:18)
graphql_1 | at Object.<anonymous> (/usr/app/node_modules/bcrypt/bcrypt.js:6:16)
graphql_1 | at Module._compile (internal/modules/cjs/loader.js:689:30)
graphql_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
graphql_1 | at Module.load (internal/modules/cjs/loader.js:599:32)
graphql_1 | at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
graphql_1 | at Function.Module._load (internal/modules/cjs/loader.js:530:3)
graphql_1 | at Module.require (internal/modules/cjs/loader.js:637:17)
graphql_1 | at require (internal/modules/cjs/helpers.js:20:18)
graphql_1 | at Object.<anonymous> (/usr/app/src/REST/auth.js:1:78)
graphql_1 | at Module._compile (internal/modules/cjs/loader.js:689:30)
graphql_1 | npm ERR! code ELIFECYCLE
graphql_1 | npm ERR! errno 1
graphql_1 | npm ERR! [email protected] start: `node server.js`
graphql_1 | npm ERR! Exit status 1
graphql_1 | npm ERR!
graphql_1 | npm ERR! Failed at the [email protected] start script.
graphql_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
graphql_1 |
graphql_1 | npm ERR! A complete log of this run can be found in:
graphql_1 | npm ERR! /root/.npm/_logs/2018-08-15T10_36_46_244Z-debug.log
When I delete bcrypt module from package.json, docker-compose runs without a problem. I have seen a few posts on stack overflow suggesting to rebuild bcrypt after installing but this does not solve the problem.
My dockerfile setting is below
FROM node:10.8.0-alpine
# Whispr work directory
WORKDIR /usr/app
# Copy dependencies first for effective caching
COPY package*.json ./
RUN apk add --no-cache --virtual .build-deps alpine-sdk python \
&& npm install \
&& npm rebuild bcrypt --build-from-source \
&& apk del .build-deps
COPY . .
My docker-compose file is below
version: '3'
services:
redis:
image: redis:5.0-rc
postgresql:
image: postgres:10
env_file:
- postgresql.env
graphql:
build: .
command: npm run start
ports:
- "3000:3000"
volumes:
- .:/usr/app
env_file:
- .env
depends_on:
- "redis"
- "postgresql"
links:
- "redis"
- "postgresql"
Upvotes: 6
Views: 3725
Reputation: 1
I set up this on docker-compose and dockerfile, it working now dockerfile:
Upvotes: 0
Reputation: 25
I finally got it working by adding an anonymous volume for node_modules
in my docker-compose.yml
. You'll find more details in this article: https://www.richardkotze.com/top-tips/install-bcrypt-docker-image-exclude-host-node-modules
volumes:
- .:/usr/app # named volume
- /usr/app/node_modules # anonymous volume for node_modules only
Upvotes: 2
Reputation: 4627
I have never managed to solve this in the end.
I ended up migrating the package to bcryptjs
which does not require any OS specific dependencies.
Upvotes: -1