Kylart / KawAnime

Desktop app for anime fans
MIT License
664 stars 50 forks source link

building dev branch with node:12 docker image fails #74

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi,

i tried to build KawAnime inside the offical node:12 docker image. But the Build Process (npm run build) terminates with the following error:

 ERROR  Failed to compile with 2 errors                                                                                                             1:20:21 PM

These relative modules were not found:

* ../build/Release/kawaparser.node in ./bindings/name_parser/index.js
* ../build/Release/kawatorrent.node in ./bindings/torrent/index.js
 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! KawAnime@0.4.2 build: `vue-cli-service electron:build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the KawAnime@0.4.2 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-06-11T13_20_21_744Z-debug.log

The debug log /root/.npm/_logs/2020-06-11T13_20_21_744Z-debug.log contains the following:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@6.14.4
3 info using node@v12.18.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle KawAnime@0.4.2~prebuild: KawAnime@0.4.2
6 info lifecycle KawAnime@0.4.2~build: KawAnime@0.4.2
7 verbose lifecycle KawAnime@0.4.2~build: unsafe-perm in lifecycle true
8 verbose lifecycle KawAnime@0.4.2~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/app/KawAnime/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle KawAnime@0.4.2~build: CWD: /app/KawAnime
10 silly lifecycle KawAnime@0.4.2~build: Args: [ '-c', 'vue-cli-service electron:build' ]
11 silly lifecycle KawAnime@0.4.2~build: Returned: code: 1  signal: null
12 info lifecycle KawAnime@0.4.2~build: Failed to exec build script
13 verbose stack Error: KawAnime@0.4.2 build: `vue-cli-service electron:build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid KawAnime@0.4.2
15 verbose cwd /app/KawAnime
16 verbose Linux 4.19.0-9-amd64
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v12.18.0
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error KawAnime@0.4.2 build: `vue-cli-service electron:build`
22 error Exit status 1
23 error Failed at the KawAnime@0.4.2 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

From the error message and debug log i could not identify the actual problem.

I also created this repo if someone wants to try it out for themself. https://github.com/githuber0815/KawAnime-docker-build-node-12

Hopefully somebody can help me out here or point me in the right direction.

Update: The master branch does not seem to have this problem only the dev branch (i'll update the title of the issue)

Kylart commented 4 years ago

What is the link to this official KawAnime docker image?

I made one a very long time ago so it should be outdated.

ghost commented 4 years ago

Sorry, for the miscommunication. With official image i meant the docker Image maintained by the Node.js team.

See: https://hub.docker.com/_/node/

Note: I used Version 12.x since it is the current LTS Branch. (src: https://nodejs.org/en/download/)

If you have a docker instance availabe, you can just clone this test repo
https://github.com/githuber0815/KawAnime-docker-build-node-12

Kylart commented 4 years ago

Oh ok, that's pretty logical then. Here's what you need to add to this image to make it work: https://github.com/Kylart/KawAnime#for-linux-os

However, the executable made by this won't work outside of the image or so I fear.

ghost commented 4 years ago

Thanks for the quick reply.

The section you pointed out (https://github.com/Kylart/KawAnime#for-linux-os) is what i based the Dockerfile (https://github.com/githuber0815/KawAnime-docker-build-node-12/blob/master/Dockerfile) on. So dependencies wise everything should be available. At least there is no obvious error messages.

But why do you say that the executables should not work outside the container environment?

As far as i know if the architecture it is executed on is the same as in the container env. shouldnt it still work? (for the binaries?) Or does the javascript stuff (node / electron / ... ) have some drawback here?

Kylart commented 4 years ago

The dev version of the app relies on native C / C++ libraries like libtorrent and MPV. As Linux systems are all differents, when building the app, the bindings will be using the systems libraries.

For example, here you installed libtorrent into the image so the app will be using those links. However, if you use the executable outside of the image, the app will have a hard time finding those libtorrent libraries.

ghost commented 4 years ago

Maybe it's possible to build a static version, with the libs included? I would assume that it would require changing some compiler/linker switchtes to cmake/gcc?

Could that work?

Kylart commented 4 years ago

Yes it's possible by tweaking the dynamic links. I'm not sure how that would work though. Also it would go against the principle of Linux subsytems and it would be the same as simply building the app on your main computer as it would lead to the same disk space in the end.

ghost commented 4 years ago

Segementing the system into smaller replaceable and updatable parts (e.g. shared libs ) is indeed a smart move for "system" libs but for userspace utilities/apps i thinks thats not so much an issue/requirement. But i guess that is a matter of option.

I think i'll read up on how node loads/binds the external libs and see if it can replaced them with a static version. (as far as i can see libtorrent is the main issue since libmpv is only for internal playback which can be disabled anyway.)

If i get it to work, i'll report back.

Guess you can close this issue, since its not really docker related.

Thanks for helping out.

Kylart commented 4 years ago

A few pointers:

Good luck!