Wechaty: Build Docker image from zixia/wechaty:onbuild,/bot/node_modules does not exist.

Created on 24 Apr 2017  路  4Comments  路  Source: wechaty/wechaty

Dockerfile

FROM zixia/wechaty:onbuild

Minimize the code at https://github.com/mukaiu/bot-docker-test

Actual behavior

/bot/node_modules does not exist.
image

Steps to reproduce the behavior (and fixes, if any)

Build code to reproduce.

bug

Most helpful comment

After did some tests, I found that it's related to the directory name: /bot.

/bot is the VOLUME of Wechaty Docker Image, we all know about it because we use --volume="$(pwd)":/bot to map local directory into Docker.

The previous version of our onbuild Docker image use /bot as WORKDIR, it works fine unless we want to do an npm install to it. It seems the directory will not store the 'node_modules directory for us for some reason, which I still have no idea of.

However, if we change the WORKDIR to another name, ie /app, then the npm install works without any problem.

https://github.com/Chatie/wechaty/commit/5642c5574f22b295783fcbb8b35f86ae07a1d290

Today I had changed the WORKDIR from /bot to /app and everything looks ok now. Please check out the latest version(v0.7.75 or above) of Wechaty Docker and have a try, and let me hear back from you.

Thanks!

All 4 comments

After did some tests, I found that it's related to the directory name: /bot.

/bot is the VOLUME of Wechaty Docker Image, we all know about it because we use --volume="$(pwd)":/bot to map local directory into Docker.

The previous version of our onbuild Docker image use /bot as WORKDIR, it works fine unless we want to do an npm install to it. It seems the directory will not store the 'node_modules directory for us for some reason, which I still have no idea of.

However, if we change the WORKDIR to another name, ie /app, then the npm install works without any problem.

https://github.com/Chatie/wechaty/commit/5642c5574f22b295783fcbb8b35f86ae07a1d290

Today I had changed the WORKDIR from /bot to /app and everything looks ok now. Please check out the latest version(v0.7.75 or above) of Wechaty Docker and have a try, and let me hear back from you.

Thanks!

When package.json contains wechaty, the startup will fail.

Starting Wechaty v0.7.78 with Node.js v7.9.0 ...

> [email protected] start /app
> node ./bin/www

19:54:16 INFO Wechaty v0.7.79 initializing...
19:54:16 WARN PuppetWebBrowserDriver valid() getSession() catch() rejected: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver valid() driver.getSession() exception: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() got invalid driver
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() with retry: 1
(node:28) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Server terminated early with status 1
(node:28) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
19:54:16 WARN PuppetWebBrowserDriver valid() getSession() catch() rejected: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver valid() driver.getSession() exception: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() got invalid driver
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() with retry: 2
(node:28) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver valid() getSession() catch() rejected: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver valid() driver.getSession() exception: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() got invalid driver
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() with retry: 3
(node:28) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver valid() getSession() catch() rejected: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver valid() driver.getSession() exception: Server terminated early with status 1
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() got invalid driver
19:54:16 WARN PuppetWebBrowserDriver initChromeDriver() not valid after retry: 4 times: Error: initChromeDriver() got invalid driver
    at BrowserDriver.<anonymous> (/app/node_modules/wechaty/dist/src/puppet-web/browser-driver.js:126:35)
    at Generator.next (<anonymous>)
    at fulfilled (/app/node_modules/wechaty/dist/src/puppet-web/browser-driver.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:109:7)
19:54:16 ERR PuppetWebBrowser init() exception: initChromeDriver() got invalid driver
19:54:16 ERR PuppetWebBrowser quit() this.driver.quit() exception Server terminated early with status 1
(node:28) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: Server terminated early with status 1
19:54:16 ERR PuppetWeb initBrowser() exception: initChromeDriver() got invalid driver
19:54:16 ERR PuppetWeb init() exception: Error: initChromeDriver() got invalid driver
    at BrowserDriver.<anonymous> (/app/node_modules/wechaty/dist/src/puppet-web/browser-driver.js:126:35)
    at Generator.next (<anonymous>)
    at fulfilled (/app/node_modules/wechaty/dist/src/puppet-web/browser-driver.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:109:7)
19:54:16 ERR Wechaty init() exception: initChromeDriver() got invalid driver
19:54:16 ERR Bot init() fail: Error: initChromeDriver() got invalid driver

Remove wechaty from package.json, start successfully.
Is it possible to remove wechaty on onbuild?

@mukaiu I do not think your issue is caused by onbuild because you can have a look on the Dockerfile.onbuild at here

Firstly, I suggest you do not use a Wechaty dependence if you are using Docker solution because of the discussion #281

Secondly, Wechaty should work if you use a Wechaty dependency. However, you will got two version of Wechaty, which might cause bug by this:

Starting Wechaty v0.7.78 with Node.js v7.9.0 ...

> [email protected] start /app
> node ./bin/www

19:54:16 INFO Wechaty v0.7.79 initializing...

You are using Wechaty v0.7.78 & v0.7.79 together...

At last, it seems you are defined your own CMD in the Dockerfile. If so, remove it and use a clean Dockerfile to have a try: (one line and the only one line)

FROM zixia/wechaty:onbuild

ok

Was this page helpful?
0 / 5 - 0 ratings