0

I have a GraphqQL backend application which I've forked from https://github.com/w3tecch/express-typescript-boilerplate

I've been building my fork of the app in Docker successfully for a long time, however it suddenly started failing out of the blue not long ago. I suspect it's due to one of the dependencies changing in one of the Dockerfiles.

This is what I now see when building the app in Docker:

=> ERROR [stage-build 3/5] RUN yarn install   
...
#12 29.39 error /project/node_modules/bcrypt: Command failed.
#12 29.39 Exit code: 1
...
#12 29.39 gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
#12 29.39 make: Entering directory '/project/node_modules/bcrypt/build'
#12 29.39 make: printf: Operation not permitted
#12 29.39 make: *** [bcrypt_lib.target.mk:103: Release/obj.target/bcrypt_lib/src/blowfish.o] Error 127
#12 29.39 make: Leaving directory '/project/node_modules/bcrypt/build'
#12 29.39 gyp ERR! build error 
#12 29.39 gyp ERR! stack Error: `make` failed with exit code: 2
#12 29.39 gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
#12 29.39 gyp ERR! stack     at emitTwo (events.js:126:13)
#12 29.39 gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
#12 29.39 gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
#12 29.39 gyp ERR! System Linux 4.19.121-linuxkit
#12 29.39 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/project/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/project/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"
#12 29.39 gyp ERR! cwd /project/node_modules/bcrypt
#12 29.39 gyp ERR! node -v v8.15.1
#12 29.39 gyp ERR! node-gyp -v v3.8.0
#12 29.39 gyp ERR! not ok 
#12 29.39 node-pre-gyp ERR! build error 
#12 29.39 node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/project/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/project/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)
#12 29.39 node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/project/node_modules/bcrypt/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
#12 29.39 node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
#12 29.39 node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
#12 29.39 node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
#12 29.39 node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
#12 29.39 node-pre-gyp ERR! System Linux 4.19.121-linuxkit
#12 29.39 node-pre-gyp ERR! command "/usr/local/bin/node" "/project/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
#12 29.39 node-pre-gyp ERR! cwd /project/node_modules/bcrypt
#12 29.39 node-pre-gyp ERR! node -v v8.15.1
#12 29.39 node-pre-gyp ERR! node-pre-gyp -v v0.11.0
#12 29.39 node-pre-gyp ERR! not ok 
#12 29.39 Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/project/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/project/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1) executor failed running [/bin/sh -c yarn install]: exit code: 1
------

The Dockerfile structure is as follows:

  1. olliecaine/base (an Alpine container containing Node)
  2. olliecaine/dev (extends from olliecaine/base to add additional dev dependencies such as Chromium)
  3. The application's Dockerfile which has 3 stages:
    1. Develop - installs application dependencies and runs npm run dev
    2. Build - lints, tests and builds the app
    3. Host - uses olliecaine/base to host the app

These Dockerfiles can be found in my devops repo at https://github.com/olivercaine/devops

Everything relating to the issue can be found in https://github.com/olivercaine/express-typescript-boilerplate/blob/bugfix/docker-build-error/README%20-%20BUILD%20ISSUE.md

If anyone has any recommendation of how I can debug/fix the issue it would be really appreciated!

Oliver Caine
  • 648
  • 7
  • 9

1 Answers1

0

The failure is in make which is trying to compile the binary dependancies for the package. make is throwing the following error *** [bcrypt_lib.target.mk:103: Release/obj.target/bcrypt_lib/src/blowfish.o] Error 127 before it returns to npm with exit code 2.

Such problems are usually associated with missing dependancies (compiler tools, libraries, etc.). There is already similar issue opened with bycrypt on GitHub.

As per the GitHub thread, the library requires C/C++ compiler, make and Python as a build-set dependancies. For alpine this would be

RUN apk add --update alpine-sdk && \
    apk add libffi-dev openssl-dev && \
    apk add python-dev python3-dev
jordanvrtanoski
  • 5,104
  • 1
  • 20
  • 29