toni-moreno / snmpcollector

A full featured Generic SNMP data collector with Web Administration Interface for InfluxDB
MIT License
286 stars 53 forks source link

[Bug] Docker Build Error/Deprecated Node Depedencies #499

Closed brotherdust closed 2 years ago

brotherdust commented 2 years ago

First of all, thank you for making this software!

When I try to build the Docker image, I get this error:

Dockerfile:61
--------------------
  59 |     
  60 |     COPY --from=0 /go/src/github.com/toni-moreno/snmpcollector/bin/snmpcollector ./bin/
  61 | >>> COPY --from=1 /usr/src/app/public ./public
  62 |     
  63 |     EXPOSE 8090
--------------------
error: failed to solve: failed to compute cache key: "/usr/src/app/public": not found

After digging around a bit, it looks like Node is throwing a lot of errors and warnings. This one seems the most relevant:

#26 [stage-1 5/5] RUN npm install &&     PATH=$(npm bin):/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin &&     ng build --prod
 94% asset optimization(node:77) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token: name (n)
#26 125.0     at JS_Parse_Error.get (eval at <anonymous> (/usr/src/app/node_modules/webpack-concat-plugin/node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)
#26 125.0     at emitWarning (internal/process/promises.js:65:36)
#26 125.0     at emitPendingUnhandledRejections (internal/process/promises.js:109:11)
#26 125.0     at process._tickCallback (internal/process/next_tick.js:189:7)
#26 125.0 (node:77) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
#26 125.0 (node:77) [DEP0018] 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.

Given how old the Node version specified is, and the various modules, it looks like this Node code might be dependent on stuff that's too long deprecated to use at this point. Have you seen anything like this?

Thanks!

toni-moreno commented 2 years ago

Thank you @brotherdust to report this error. I will review it ASAP.

brotherdust commented 2 years ago

@toni-moreno , no problem and THANK YOU! I didn't know when you were going to respond so I already started porting to Node 16 lol. =)

toni-moreno commented 2 years ago

I will be happy if you could submit a PR with this upgrade to node 16 !!

brotherdust commented 2 years ago

@toni-moreno it might be a while! There's a lot of ... depreciations to resolve. No promises.

toni-moreno commented 2 years ago

@brotherdust I've been investigating a bit.. it seem like we have inserted this error in the last PR . you will be able to recreate docker image if you come back to 2 commits before git reset HEAD~2. Could you confirm please you can build image after this git history change?

brotherdust commented 2 years ago

Will check it out shortly and get back to you.

brotherdust commented 2 years ago

@toni-moreno , same error, apparently.

 => ERROR [stage-2 7/7] COPY --from=1 /usr/src/app/public ./public                                                                                                                                                0.0s
------
 > [stage-2 7/7] COPY --from=1 /usr/src/app/public ./public:
------
failed to compute cache key: "/usr/src/app/public" not found: not found

Update: whoops. I didn't do a git reset --hard after git reset HEAD~2. Trying another build. Update: failed for different reasons. I'm going to re-clone and try again.

brotherdust commented 2 years ago

Nope.

https://gist.github.com/brotherdust/2fcccf03812f4ac358afeee055728c6b

toni-moreno commented 2 years ago

try revert to 6e6eb3233be8ef91b8989298c4df081d96bd51e9 be and test again please.

toni-moreno commented 2 years ago

@brotherdust I've tested and you will be able to recreate image with git reset --hard 6e6eb3233be8ef91b8989298c4df081d96bd51e9 Could be nice if you could help me to fix this error without reverting features.

brotherdust commented 2 years ago

@toni-moreno , trying it now.

brotherdust commented 2 years ago

It worked. Thanks! =)