Search code examples
dockermeteorfabricjsnode-pre-gyp

Meteor app fails to deploy in Docker container because node-pre-gyp dependency (fabric js)


I have a simple Meteor project which contains only 1 page with a canvas on it. This canvas is using fabric js which was installed using:

meteor npm install --save fabric

It works when I run the app on my windows machine (fabric js works and I can draw on the canvas)

But when I deploy on ubuntu + docker it fails during node-pre-gyp install:

> node-pre-gyp install --fallback-to-build --update-binary
(node:98) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
/bin/sh: pkg-config: not found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Linux 5.4.0-137-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/opt/bundle/bundle/programs/server/npm/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/opt/bundle/bundle/programs/server/npm/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd /opt/bundle/bundle/programs/server/npm/node_modules/canvas
gyp ERR! node -v v14.19.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok here

in my Dockerfile i'm using following versions:

  • Meteor version = 2.10.0
  • docker container = geoffreybooth/meteor-base:2.10.0
  • node version = node:14.19.3-alpine

When I remove the fabric js package then I can deploy without any problems. Any ideas how to fix this?


Solution

  • ChatGPT just solved my problem in less then 10 minutes after I was waiting 2 days without response on stackoverflow. I think stackoverflow.com should be worried :)

    To be fair, Jankapunkt did give a reply/hint in the good direction, but my understanding of Docker is not very good so I didnt know what to do with the hint.

    ChatGPT did so much better, it answered to the point and correct, with examples and extra explanations.

    The solution:

    add following line to the Dockerfile and rebuild the docker image:

    RUN apk add --no-cache pkgconfig
    

    After that I had some more missing packages to make FiberJS work, in the end I had to add 3 more in Dockerfile:

    RUN apk add --no-cache pixman-dev
    RUN apk add --no-cache cairo-dev
    RUN apk add --no-cache pango-dev
    

    (all of them where identified very quickly by ChatGPT...)