OWASP / Docker-Security

Getting a handle on container security
https://owasp.org/www-project-docker-top-10/
Other
628 stars 130 forks source link

Gitbook error: "TypeError: cb.apply is not a function" #32

Closed drwetter closed 3 years ago

drwetter commented 3 years ago

In addition to #31 there's also another error when using docker-compose run --rm build

image

cc @PauloASilva

drwetter commented 3 years ago

https://stackoverflow.com/questions/64211386/gitbook-cli-install-error-typeerror-cb-apply-is-not-a-function-inside-graceful

This is getting too compicated but if someone wants to give a hand here, please speak up

PauloASilva commented 3 years ago

I'll have a look on it.

drwetter commented 3 years ago

FYI: Just added locally below RUN npm i gitbook-cli -g

RUN cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/ && \
    npm install graceful-fs@latest --save

still running ...

PauloASilva commented 3 years ago

If you look into the Dockerfile I am running a "custom" version of GitBook: I've forked it to fix another issue.

I'll try to update GitBook dependencies in my fork. This way we avoid to maintain a hackish Dockerfile and the community will benefit from it.

drwetter commented 3 years ago
 ---> e76d1c1c2ca4
Step 4/7 : RUN cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/ &&     npm install graceful-fs@latest --save
 ---> Running in eac4f3c88243
npm ERR! code EISDIR
npm ERR! syscall copyfile
npm ERR! path /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/glob
npm ERR! dest /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/.glob-OKa8tj7S
npm ERR! errno -21
npm ERR! EISDIR: illegal operation on a directory, copyfile '/usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/glob' -> '/usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/.glob-OKa8tj7S'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-12-29T16_55_21_408Z-debug.log
ERROR: Service 'build' failed to build: The command '/bin/sh -c cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/ &&     npm install graceful-fs@latest --save' returned a non-zero code: 235
prompt> docker exec -ti e76d1c1c2ca4 /bin/sh
# # cat /root/.npm/_logs/2020-12-29T16_55_21_408Z-debug.log
cat: /root/.npm/_logs/2020-12-29T16_55_21_408Z-debug.log: No such file or directory
# cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/glob
# ls -la
total 80
drwxr-xr-x  3 root staff  4096 Dec 29 16:54 .
drwxr-xr-x 99 root staff  4096 Dec 29 16:54 ..
-rw-r--r--  1 root staff   765 Jul  5  2017 LICENSE
-rw-r--r--  1 root staff 14664 Jul  5  2017 README.md
-rw-r--r--  1 root staff  1430 Jul  5  2017 changelog.md
-rw-r--r--  1 root staff  6167 Jul  5  2017 common.js
-rw-r--r--  1 root staff 19433 Jul  5  2017 glob.js
drwxr-xr-x  5 root staff  4096 Dec 29 16:54 node_modules
-rw-r--r--  1 root staff  2124 Jul  6  2017 package.json
-rw-r--r--  1 root staff 12002 Jul  5  2017 sync.js
# id
uid=0(root) gid=0(root) groups=0(root)
#
drwetter commented 3 years ago

If you look into the Dockerfile I am running a "custom" version of GitBook: I've forked it to fix another issue.

I'll try to update GitBook dependencies in my fork. This way we avoid to maintain a hackish Dockerfile and the community will benefit from it.

That'll be the better approach that at least one can build again (FYI: EIS = Error, Is Directory . Probably you'll get the same error. Don't know what that is).

PauloASilva commented 3 years ago

Hi @drwetter, Can you please check/test PR #34 locally before merging?

You can do it running the following commands inside your repository root directory:

$ git fetch origin pull/34/head:pr-34
$ git checkout pr-34
$ docker-compose run --rm build

Instead of using latest node docker image as base image, I've locked it (something I should have done from the beginning) to the node:12.11.1-slim.

drwetter commented 3 years ago

For such easy changes it's easier for me to use a oneliner of sed