Failing to install nodered-contrib-face-recognition

Hello

We are failling to install the node node-red-contrib-face-recognition in a Fargate container running nodered/node-red:3.0.2-16.
It fails even in a clean, created-from scratch, container so no existing dependencies from other nodes.
The error log is as follow.
Could someone help us to uderstand what it means ?

Many thanks


-----------------------------------------------------------
2023-01-02T16:09:22.139Z Install : node-red-contrib-face-recognition 2.0.4

2023-01-02T16:09:22.154Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-face-recognition@2.0.4
2023-01-02T16:09:22.760Z [err] npm
2023-01-02T16:09:22.761Z [err]  WARN config production Use `--omit=dev` instead.
2023-01-02T16:09:45.679Z [err] npm WARN deprecated formidable@1.2.6: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
2023-01-02T16:09:47.349Z [err] npm
2023-01-02T16:09:47.350Z [err]  WARN deprecated node-pre-gyp@0.13.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
2023-01-02T16:10:32.061Z [err] npm ERR! code 1
2023-01-02T16:10:32.061Z [err] npm ERR! path /data/node_modules/canvas
2023-01-02T16:10:32.064Z [err] npm ERR!
2023-01-02T16:10:32.065Z [err]  command failed
2023-01-02T16:10:32.065Z [err] npm ERR! command sh -c node-pre-gyp install --fallback-to-build --update-binary
2023-01-02T16:10:32.065Z [err] npm ERR! Failed to execute '/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=/data/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/data/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
2023-01-02T16:10:32.070Z [err] npm ERR! node-pre-gyp info it worked if it ends with ok
2023-01-02T16:10:32.070Z [err] npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10
2023-01-02T16:10:32.070Z [err] npm ERR! node-pre-gyp info using node@16.16.0 | linux | x64
2023-01-02T16:10:32.070Z [err] npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.0/canvas-v2.11.0-node-v93-linux-musl-x64.tar.gz
2023-01-02T16:10:32.070Z [err] npm 
2023-01-02T16:10:32.070Z [err] ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.0/canvas-v2.11.0-node-v93-linux-musl-x64.tar.gz 
2023-01-02T16:10:32.070Z [err] npm
2023-01-02T16:10:32.070Z [err]  ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.0 and node@16.16.0 (node-v93 ABI, musl) (falling back to source compile with node-gyp) 
2023-01-02T16:10:32.070Z [err] npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.0/canvas-v2.11.0-node-v93-linux-musl-x64.tar.gz 
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info it worked if it ends with ok
2023-01-02T16:10:32.070Z [err] npm ERR!
2023-01-02T16:10:32.070Z [err]  gyp info using node-gyp@9.0.0
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info using node@16.16.0 | linux | x64
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info ok 
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info it worked if it ends with ok
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info using node-gyp@9.0.0
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info using node@16.16.0 | linux | x64
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info find Python using Python version 3.10.5 found at "/usr/bin/python3"
2023-01-02T16:10:32.070Z [err] npm
2023-01-02T16:10:32.070Z [err]  ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.16.0/node-v16.16.0-headers.tar.gz
2023-01-02T16:10:32.070Z [err] npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.16.0/node-v16.16.0-headers.tar.gz
2023-01-02T16:10:32.070Z [err] npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.16.0/SHASUMS256.txt
2023-01-02T16:10:32.070Z [err] npm 
2023-01-02T16:10:32.070Z [err] ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.16.0/SHASUMS256.txt
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info spawn /usr/bin/python3
2023-01-02T16:10:32.070Z [err] npm ERR!
2023-01-02T16:10:32.070Z [err]  gyp info spawn args [
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info spawn args   'binding.gyp',
2023-01-02T16:10:32.070Z [err] npm ERR! gyp info spawn args   '-f',
2023-01-02T16:10:32.070Z [err] npm 
2023-01-02T16:10:32.071Z [err] ERR! gyp info spawn args   'make',
2023-01-02T16:10:32.071Z [err] npm ERR! gyp info spawn args   '-I',
2023-01-02T16:10:32.071Z [err] npm
2023-01-02T16:10:32.071Z [err]  ERR! gyp info spawn args   '/data/node_modules/canvas/build/config.gypi',
2023-01-02T16:10:32.071Z [err] npm ERR!
2023-01-02T16:10:32.071Z [err]  gyp info spawn args   '-I',
2023-01-02T16:10:32.071Z [err] npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
2023-01-02T16:10:32.071Z [err] npm ERR!
2023-01-02T16:10:32.071Z [err]  gyp info spawn args   '-I',
2023-01-02T16:10:32.071Z [err] npm ERR! gyp info spawn args   '/usr/src/node-red/.cache/node-gyp/16.16.0/include/node/common.gypi',
2023-01-02T16:10:32.071Z [err] npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
2023-01-02T16:10:32.071Z [err] npm ERR! gyp info spawn args   '-Dvisibility=default',
2023-01-02T16:10:32.071Z [err] npm ERR! gyp info spawn args   '-Dnode_root_dir=/usr/src/node-red/.cache/node-gyp/16.16.0',
2023-01-02T16:10:32.071Z [err] npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
2023-01-02T16:10:32.071Z [err] npm 
2023-01-02T16:10:32.072Z [err] ERR! gyp info spawn args   '-Dnode_lib_file=/usr/src/node-red/.cache/node-gyp/16.16.0/<(target_arch)/node.lib',
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args   '-Dmodule_root_dir=/data/node_modules/canvas',
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args   '-Dnode_engine=v8',
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args   '--depth=.',
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args   '--no-parallel',
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args   '--generator-output',
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args   'build',
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args   '-Goutput_dir=.'
2023-01-02T16:10:32.072Z [err] npm ERR! gyp info spawn args ]
2023-01-02T16:10:32.072Z [err] npm ERR! /bin/sh: pkg-config: not found
2023-01-02T16:10:32.072Z [err] npm ERR! gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! configure error 
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! System Linux 5.10.102.1-microsoft-standard-WSL2
2023-01-02T16:10:32.072Z [err] npm ERR! 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=/data/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/data/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! cwd /data/node_modules/canvas
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! node -v v16.16.0
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! node-gyp -v v9.0.0
2023-01-02T16:10:32.072Z [err] npm ERR! gyp ERR! not ok 
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! build error 
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/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=/data/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/data/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
2023-01-02T16:10:32.072Z [err] npm
2023-01-02T16:10:32.072Z [err]  ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/data/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
2023-01-02T16:10:32.072Z [err] npm 
2023-01-02T16:10:32.072Z [err] ERR! node-pre-gyp ERR! System Linux 5.10.102.1-microsoft-standard-WSL2
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/data/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! cwd /data/node_modules/canvas
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! node -v v16.16.0
2023-01-02T16:10:32.072Z [err] npm ERR!
2023-01-02T16:10:32.072Z [err]  node-pre-gyp ERR! node-pre-gyp -v v1.0.10
2023-01-02T16:10:32.072Z [err] npm ERR! node-pre-gyp ERR! not ok
2023-01-02T16:10:32.077Z [err] 
2023-01-02T16:10:32.078Z [err] npm ERR! A complete log of this run can be found in:
2023-01-02T16:10:32.078Z [err] npm ERR!     /data/.npm/_logs/2023-01-02T16_09_22_699Z-debug-0.log
2023-01-02T16:10:32.089Z rc=1

I think that means that it cannot find pixman. Did you see the note about additional stuff that needs to be included for the docker image? node-red-contrib-face-recognition (node) - Node-RED

Ah...
Indeed I didn't catch all that
Thanks @Colin

So if I run the official docker image in my local Ubuntu, log-in as root and run the additional apk add ... command specified in "Official Docker Image" I can successfully install the face-recognition node. :+1:

Now I forked the repo for the official docker image and added that command in the Dockerfile.custom at the end of the "STAGE BUILD" section like below.
Build run without any error but unfortunately, the same problem occurs startig with pkg-config not found
If I log into the container and run the apt add command there, everything works fine.
So it looks like the location of my command is not correct
Is there a better place to insert that apk add command ?

Thanks

Modified Dockerfile.custom (without package python as it is already installed in the "Install Build tools" step:

#### Stage BUILD #######################################################################################################
FROM base AS build

# Install Build tools
RUN apk add --no-cache --virtual buildtools build-base linux-headers udev python3 && \
    npm install --unsafe-perm --no-update-notifier --no-fund --only=production && \
    /tmp/remove_native_gpio.sh && \
    cp -R node_modules prod_node_modules

RUN apk add g++ \
    build-base \
    cairo-dev \
    jpeg-dev \
    pango-dev \
    musl-dev \
    giflib-dev \
    pixman-dev \
    pangomm-dev \
    libjpeg-turbo-dev \
    freetype-dev

#### Stage RELEASE #####################################################################################################

docker build log without any error:

...
 => [base 10/10] COPY scripts/entrypoint.sh .                                                                                                                                                                 0.0s
 => [build 1/2] RUN apk add --no-cache --virtual buildtools build-base linux-headers udev python3 &&     npm install --unsafe-perm --no-update-notifier --no-fund --only=production &&     /tmp/remove_nati  26.4s
 => [build 2/2] RUN apk add g++     build-base     cairo-dev     jpeg-dev     pango-dev     musl-dev     giflib-dev     pixman-dev     pangomm-dev     libjpeg-turbo-dev     freetype-dev                     3.1s
 => [release 1/4] COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules                                                                                                                        0.4s