Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting a Sample Application Guide Fails on dnmonster port #2039

Open
techalchemy opened this issue Jan 23, 2025 · 5 comments
Open

Porting a Sample Application Guide Fails on dnmonster port #2039

techalchemy opened this issue Jan 23, 2025 · 5 comments
Assignees
Labels

Comments

@techalchemy
Copy link
Contributor

Describe the bug
Following along with the porting a sample application guide, I was able to build the original Dockerfile, but after I made the first round of changes to the dnmonster nodejs microservice using the provided Dockerfile, I was unable to successfully rebuild the microservice.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the porting a sample application guide
  2. Follow the instructions to update the nodejs microservice
  3. Use the provided updated Dockerfile
  4. `docker build -t

Expected behavior
I would expect the build to succeed as described in the documentation. Note that the build initially fails due to claiming a need for a python runtime. I did attempt to rebuild with the python runtime added in the dockerfile, but got another failure which is what led me to file this bug.

Initial Failure

$ docker build --pull -t dnmonster-cg .
[+] Building 46.4s (12/14)                                                                                                                                                                                                                                         docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                         0.0s
 => => transferring dockerfile: 685B                                                                                                                                                                                                                                         0.0s
 => [internal] load metadata for cgr.dev/chainguard/node:latest-dev                                                                                                                                                                                                          2.2s
 => [internal] load .dockerignore                                                                                                                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                              0.0s
 => [ 1/10] FROM cgr.dev/chainguard/node:latest-dev@sha256:e0edbc930256c37344540f6f111f4e29a4ec01db3ddf199f418292f57c3f9620                                                                                                                                                  9.9s
 => => resolve cgr.dev/chainguard/node:latest-dev@sha256:e0edbc930256c37344540f6f111f4e29a4ec01db3ddf199f418292f57c3f9620                                                                                                                                                    0.0s
 => => sha256:193c8dda9fe8142bc27b098dd7c5cd132347f81fe2c55b352a8b19a42ff05636 248.45MB / 248.45MB                                                                                                                                                                           7.4s
 => => sha256:e0edbc930256c37344540f6f111f4e29a4ec01db3ddf199f418292f57c3f9620 921B / 921B                                                                                                                                                                                   0.0s
 => => sha256:4b20ad7dd52f4653e110d58cd3e2b62c8ea2d5b28a1b330216d9894acb6bcdaf 838B / 838B                                                                                                                                                                                   0.0s
 => => sha256:d1febe3a7fb85f3e6654aab7be7f2cfad2567745be6cb6892c1f9ac1c402d8db 1.02kB / 1.02kB                                                                                                                                                                               0.0s
 => => extracting sha256:193c8dda9fe8142bc27b098dd7c5cd132347f81fe2c55b352a8b19a42ff05636                                                                                                                                                                                    2.5s
 => [internal] load build context                                                                                                                                                                                                                                            0.0s
 => => transferring context: 127B                                                                                                                                                                                                                                            0.0s
 => [ 2/10] RUN apk update && apk add     cairo-dev libjpeg-turbo-dev pango-dev giflib-dev     librsvg-dev glib-dev harfbuzz-dev fribidi-dev expat-dev libxft-dev                                                                                                           30.0s
 => [ 3/10] RUN addgroup dnmonster && adduser -D -G dnmonster dnmonster                                                                                                                                                                                                      0.1s 
 => [ 4/10] RUN install -d -o dnmonster -g dnmonster /home/dnmonster                                                                                                                                                                                                         0.2s 
 => [ 5/10] RUN mkdir -p /usr/src/app                                                                                                                                                                                                                                        0.2s 
 => [ 6/10] WORKDIR /usr/src/app                                                                                                                                                                                                                                             0.0s 
 => [ 7/10] COPY package.json /usr/src/app/                                                                                                                                                                                                                                  0.0s 
 => ERROR [ 8/10] RUN npm install                                                                                                                                                                                                                                            3.7s 
------                                                                                                                                                                                                                                                                            
 > [ 8/10] RUN npm install:                                                                                                                                                                                                                                                       
2.790 npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.                          
2.813 npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported                                                                                                                                                                                           
2.845 npm warn deprecated [email protected]: This package is no longer supported.                                                                                                                                                                                                       
2.874 npm warn deprecated [email protected]: This package is no longer supported.                                                                                                                                                                                            
3.043 npm warn deprecated [email protected]: This package is no longer supported.
3.044 npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
3.560 npm error code 1
3.560 npm error path /usr/src/app/node_modules/canvas
3.560 npm error command failed
3.560 npm error command sh -c node-pre-gyp install --fallback-to-build --update-binary
3.560 npm error Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=10 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v131 --python=/usr/bin/python3' (1)
3.560 npm error node-pre-gyp info it worked if it ends with ok
3.560 npm error node-pre-gyp info using [email protected]
3.560 npm error node-pre-gyp info using [email protected] | linux | x64
3.560 npm error (node:17) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
3.560 npm error (Use `node --trace-deprecation ...` to show where the warning was created)
3.560 npm error node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v131-linux-glibc-x64.tar.gz
3.560 npm error node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v131-linux-glibc-x64.tar.gz 
3.560 npm error node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v131 ABI, glibc) (falling back to source compile with node-gyp) 
3.560 npm error node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v131-linux-glibc-x64.tar.gz 
3.560 npm error gyp info it worked if it ends with ok
3.560 npm error gyp info using [email protected]
3.560 npm error gyp info using [email protected] | linux | x64
3.560 npm error gyp info ok 
3.560 npm error gyp info it worked if it ends with ok
3.560 npm error gyp info using [email protected]
3.560 npm error gyp info using [email protected] | linux | x64
3.560 npm error gyp ERR! find Python 
3.560 npm error gyp ERR! find Python checking Python explicitly set from command line or npm configuration
3.560 npm error gyp ERR! find Python - "--python=" or "npm config get python" is "/usr/bin/python3"
3.560 npm error gyp ERR! find Python - executable path is ""
3.560 npm error gyp ERR! find Python - "" could not be run
3.560 npm error gyp ERR! find Python Python is not set from environment variable PYTHON
3.560 npm error gyp ERR! find Python checking if "python3" can be used
3.560 npm error gyp ERR! find Python - executable path is ""
3.560 npm error gyp ERR! find Python - "" could not be run
3.560 npm error gyp ERR! find Python checking if "python" can be used
3.560 npm error gyp ERR! find Python - executable path is ""
3.560 npm error gyp ERR! find Python - "" could not be run
3.560 npm error gyp ERR! find Python 
3.560 npm error gyp ERR! find Python **********************************************************
3.560 npm error gyp ERR! find Python You need to install the latest version of Python.
3.560 npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
3.560 npm error gyp ERR! find Python you can try one of the following options:
3.560 npm error gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
3.560 npm error gyp ERR! find Python (accepted by both node-gyp and npm)
3.560 npm error gyp ERR! find Python - Set the environment variable PYTHON
3.560 npm error gyp ERR! find Python - Set the npm configuration variable python:
3.560 npm error gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
3.560 npm error gyp ERR! find Python For more information consult the documentation at:
3.560 npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
3.560 npm error gyp ERR! find Python **********************************************************
3.560 npm error gyp ERR! find Python 
3.560 npm error gyp ERR! configure error 
3.560 npm error gyp ERR! stack Error: Could not find any Python installation to use
3.560 npm error gyp ERR! stack at PythonFinder.fail (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:306:11)
3.560 npm error gyp ERR! stack at PythonFinder.findPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:164:17)
3.560 npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
3.560 npm error gyp ERR! stack at async configure (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:27:18)
3.560 npm error gyp ERR! stack at async run (/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:81:18)
3.560 npm error gyp ERR! System Linux 6.8.0-51-generic
3.560 npm error gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/usr/src/app/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/src/app/node_modules/canvas/build/Release" "--napi_version=10" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v131" "--python=/usr/bin/python3"
3.560 npm error gyp ERR! cwd /usr/src/app/node_modules/canvas
3.560 npm error gyp ERR! node -v v23.6.1
3.560 npm error gyp ERR! node-gyp -v v11.0.0
3.560 npm error gyp ERR! not ok 
3.560 npm error node-pre-gyp ERR! build error 
3.560 npm error node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=10 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v131 --python=/usr/bin/python3' (1)
3.560 npm error node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/src/app/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
3.560 npm error node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:507:28)
3.560 npm error node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1101:16)
3.560 npm error node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
3.560 npm error node-pre-gyp ERR! System Linux 6.8.0-51-generic
3.560 npm error node-pre-gyp ERR! command "/usr/bin/node" "/usr/src/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
3.560 npm error node-pre-gyp ERR! cwd /usr/src/app/node_modules/canvas
3.560 npm error node-pre-gyp ERR! node -v v23.6.1
3.560 npm error node-pre-gyp ERR! node-pre-gyp -v v1.0.11
3.560 npm error node-pre-gyp ERR! not ok
3.561 npm error A complete log of this run can be found in: /root/.npm/_logs/2025-01-23T22_08_55_665Z-debug-0.log
------
Dockerfile:17
--------------------
  15 |     
  16 |     COPY package.json /usr/src/app/
  17 | >>> RUN npm install
  18 |     COPY ./src /usr/src/app
  19 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1

Failure w/ python added to dockerfile

$ docker build --pull -t dnmonster-cg .
[+] Building 26.8s (12/14)                                                                                                                                                                                                                                         docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                         0.0s
 => => transferring dockerfile: 629B                                                                                                                                                                                                                                         0.0s
 => [internal] load metadata for cgr.dev/chainguard/node:latest-dev                                                                                                                                                                                                          0.8s
 => [internal] load .dockerignore                                                                                                                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                              0.0s
 => [internal] load build context                                                                                                                                                                                                                                            0.0s
 => => transferring context: 127B                                                                                                                                                                                                                                            0.0s
 => [ 1/10] FROM cgr.dev/chainguard/node:latest-dev@sha256:e0edbc930256c37344540f6f111f4e29a4ec01db3ddf199f418292f57c3f9620                                                                                                                                                  0.0s
 => CACHED [ 2/10] RUN apk update && apk add     cairo-dev libjpeg-turbo-dev pango-dev giflib-dev     librsvg-dev glib-dev harfbuzz-dev fribidi-dev expat-dev libxft-dev     python3-dev                                                                                     0.0s
 => CACHED [ 3/10] RUN addgroup dnmonster && adduser -D -G dnmonster dnmonster                                                                                                                                                                                               0.0s
 => CACHED [ 4/10] RUN install -d -o dnmonster -g dnmonster /home/dnmonster                                                                                                                                                                                                  0.0s
 => CACHED [ 5/10] RUN mkdir -p /usr/src/app                                                                                                                                                                                                                                 0.0s
 => CACHED [ 6/10] WORKDIR /usr/src/app                                                                                                                                                                                                                                      0.0s
 => CACHED [ 7/10] COPY package.json /usr/src/app/                                                                                                                                                                                                                           0.0s
 => ERROR [ 8/10] RUN npm install                                                                                                                                                                                                                                           26.0s
------                                                                                                                                                                                                                                                                            
 > [ 8/10] RUN npm install:                                                                                                                                                                                                                                                       
3.078 npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.                          
3.096 npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported                                                                                                                                                                                           
3.153 npm warn deprecated [email protected]: This package is no longer supported.                                                                                                                                                                                                       
3.155 npm warn deprecated [email protected]: This package is no longer supported.                                                                                                                                                                                            
3.352 npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
3.354 npm warn deprecated [email protected]: This package is no longer supported.
25.88 npm error code 1
25.88 npm error path /usr/src/app/node_modules/canvas
25.88 npm error command failed
25.88 npm error command sh -c node-pre-gyp install --fallback-to-build --update-binary
25.88 npm error make: Entering directory '/usr/src/app/node_modules/canvas/build'
25.88 npm error   SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
25.88 npm error   COPY Release/canvas-postbuild.node
25.88 npm error   CXX(target) Release/obj.target/canvas/src/backend/Backend.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/backend/SvgBackend.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/bmp/BMPParser.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/Backends.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/Canvas.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/closure.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/color.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/Image.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/ImageData.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/init.o
25.88 npm error   CXX(target) Release/obj.target/canvas/src/register_font.o
25.88 npm error   SOLINK_MODULE(target) Release/obj.target/canvas.node
25.88 npm error make: Leaving directory '/usr/src/app/node_modules/canvas/build'
25.88 npm error Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=10 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v131' (1)
25.88 npm error node-pre-gyp info it worked if it ends with ok
25.88 npm error node-pre-gyp info using [email protected]
25.88 npm error node-pre-gyp info using [email protected] | linux | x64
25.88 npm error (node:17) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
25.88 npm error (Use `node --trace-deprecation ...` to show where the warning was created)
25.88 npm error node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v131-linux-glibc-x64.tar.gz
25.88 npm error node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v131-linux-glibc-x64.tar.gz 
25.88 npm error node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v131 ABI, glibc) (falling back to source compile with node-gyp) 
25.88 npm error node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v131-linux-glibc-x64.tar.gz 
25.88 npm error gyp info it worked if it ends with ok
25.88 npm error gyp info using [email protected]
25.88 npm error gyp info using [email protected] | linux | x64
25.88 npm error gyp info ok 
25.88 npm error gyp info it worked if it ends with ok
25.88 npm error gyp info using [email protected]
25.88 npm error gyp info using [email protected] | linux | x64
25.88 npm error gyp info find Python using Python version 3.13.1 found at "/usr/bin/python3"
25.88 npm error gyp http GET https://nodejs.org/download/release/v23.6.1/node-v23.6.1-headers.tar.gz
25.88 npm error gyp http 200 https://nodejs.org/download/release/v23.6.1/node-v23.6.1-headers.tar.gz
25.88 npm error gyp http GET https://nodejs.org/download/release/v23.6.1/SHASUMS256.txt
25.88 npm error gyp http 200 https://nodejs.org/download/release/v23.6.1/SHASUMS256.txt
25.88 npm error gyp info spawn /usr/bin/python3
25.88 npm error gyp info spawn args [
25.88 npm error gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
25.88 npm error gyp info spawn args 'binding.gyp',
25.88 npm error gyp info spawn args '-f',
25.88 npm error gyp info spawn args 'make',
25.88 npm error gyp info spawn args '-I',
25.88 npm error gyp info spawn args '/usr/src/app/node_modules/canvas/build/config.gypi',
25.88 npm error gyp info spawn args '-I',
25.88 npm error gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
25.88 npm error gyp info spawn args '-I',
25.88 npm error gyp info spawn args '/root/.cache/node-gyp/23.6.1/include/node/common.gypi',
25.88 npm error gyp info spawn args '-Dlibrary=shared_library',
25.88 npm error gyp info spawn args '-Dvisibility=default',
25.88 npm error gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/23.6.1',
25.88 npm error gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
25.88 npm error gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/23.6.1/<(target_arch)/node.lib',
25.88 npm error gyp info spawn args '-Dmodule_root_dir=/usr/src/app/node_modules/canvas',
25.88 npm error gyp info spawn args '-Dnode_engine=v8',
25.88 npm error gyp info spawn args '--depth=.',
25.88 npm error gyp info spawn args '--no-parallel',
25.88 npm error gyp info spawn args '--generator-output',
25.88 npm error gyp info spawn args 'build',
25.88 npm error gyp info spawn args '-Goutput_dir=.'
25.88 npm error gyp info spawn args ]
25.88 npm error gyp info ok 
25.88 npm error gyp info it worked if it ends with ok
25.88 npm error gyp info using [email protected]
25.88 npm error gyp info using [email protected] | linux | x64
25.88 npm error gyp info spawn make
25.88 npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
25.88 npm error In file included from /root/.cache/node-gyp/23.6.1/include/node/v8-local-handle.h:13,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/v8-array-buffer.h:12,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/v8.h:24,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/node.h:73,
25.88 npm error                  from ../../nan/nan.h:62,
25.88 npm error                  from ../src/backend/Backend.h:6,
25.88 npm error                  from ../src/backend/Backend.cc:1:
25.88 npm error In member function 'bool v8::api_internal::IndirectHandleBase::IsEmpty() const',
25.88 npm error     inlined from 'void v8::PersistentBase<T>::Reset() [with T = v8::Object]' at /root/.cache/node-gyp/23.6.1/include/node/v8-persistent-handle.h:450:20,
25.88 npm error     inlined from 'void v8::PersistentBase<T>::Reset(v8::Isolate*, const v8::Local<S>&) [with S = v8::Object; T = v8::Object]' at /root/.cache/node-gyp/23.6.1/include/node/v8-persistent-handle.h:463:8,
25.88 npm error     inlined from 'void Nan::Persistent<T, M>::Reset(const v8::Local<S>&) [with S = v8::Object; T = v8::Object; M = v8::NonCopyablePersistentTraits<v8::Object>]' at ../../nan/nan_persistent_12_inl.h:29:33,
25.88 npm error     inlined from 'void Nan::ObjectWrap::Wrap(v8::Local<v8::Object>)' at ../../nan/nan_object_wrap.h:56:23,
25.88 npm error     inlined from 'static void Backend::init(const Nan::FunctionCallbackInfo<v8::Value>&)' at ../src/backend/Backend.cc:23:16:
25.88 npm error /root/.cache/node-gyp/23.6.1/include/node/v8-handle-base.h:56:43: warning: array subscript 0 is outside array bounds of 'Nan::Persistent<v8::Object> [0]' [-Warray-bounds=]
25.88 npm error    56 |   V8_INLINE bool IsEmpty() const { return location_ == nullptr; }
25.88 npm error       |                                           ^~~~~~~~~
25.88 npm error In static member function 'static void Backend::init(const Nan::FunctionCallbackInfo<v8::Value>&)':
25.88 npm error cc1plus: note: source object is likely at address zero
25.88 npm error In member function 'void v8::api_internal::IndirectHandleBase::Clear()',
25.88 npm error     inlined from 'void v8::PersistentBase<T>::Reset() [with T = v8::Object]' at /root/.cache/node-gyp/23.6.1/include/node/v8-persistent-handle.h:452:14,
25.88 npm error     inlined from 'void v8::PersistentBase<T>::Reset(v8::Isolate*, const v8::Local<S>&) [with S = v8::Object; T = v8::Object]' at /root/.cache/node-gyp/23.6.1/include/node/v8-persistent-handle.h:463:8,
25.88 npm error     inlined from 'void Nan::Persistent<T, M>::Reset(const v8::Local<S>&) [with S = v8::Object; T = v8::Object; M = v8::NonCopyablePersistentTraits<v8::Object>]' at ../../nan/nan_persistent_12_inl.h:29:33,
25.88 npm error     inlined from 'void Nan::ObjectWrap::Wrap(v8::Local<v8::Object>)' at ../../nan/nan_object_wrap.h:56:23,
25.88 npm error     inlined from 'static void Backend::init(const Nan::FunctionCallbackInfo<v8::Value>&)' at ../src/backend/Backend.cc:23:16:
25.88 npm error /root/.cache/node-gyp/23.6.1/include/node/v8-handle-base.h:59:38: warning: array subscript 0 is outside array bounds of 'Nan::Persistent<v8::Object> [0]' [-Warray-bounds=]
25.88 npm error    59 |   V8_INLINE void Clear() { location_ = nullptr; }
25.88 npm error       |                            ~~~~~~~~~~^~~~~~~~~
25.88 npm error In static member function 'static void Backend::init(const Nan::FunctionCallbackInfo<v8::Value>&)':
25.88 npm error cc1plus: note: source object is likely at address zero
25.88 npm error In file included from /root/.cache/node-gyp/23.6.1/include/node/v8-object.h:11,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/v8-array-buffer.h:13:
25.88 npm error In member function 'void v8::PersistentBase<T>::Reset(v8::Isolate*, const v8::Local<S>&) [with S = v8::Object; T = v8::Object]',
25.88 npm error     inlined from 'void Nan::Persistent<T, M>::Reset(const v8::Local<S>&) [with S = v8::Object; T = v8::Object; M = v8::NonCopyablePersistentTraits<v8::Object>]' at ../../nan/nan_persistent_12_inl.h:29:33,
25.88 npm error     inlined from 'void Nan::ObjectWrap::Wrap(v8::Local<v8::Object>)' at ../../nan/nan_object_wrap.h:56:23,
25.88 npm error     inlined from 'static void Backend::init(const Nan::FunctionCallbackInfo<v8::Value>&)' at ../src/backend/Backend.cc:23:16:
25.88 npm error /root/.cache/node-gyp/23.6.1/include/node/v8-persistent-handle.h:465:16: warning: array subscript 0 is outside array bounds of 'Nan::Persistent<v8::Object> [0]' [-Warray-bounds=]
25.88 npm error   465 |   this->slot() = New(isolate, *other);
25.88 npm error       |   ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
25.88 npm error In static member function 'static void Backend::init(const Nan::FunctionCallbackInfo<v8::Value>&)':
25.88 npm error cc1plus: note: source object is likely at address zero
25.88 npm error In file included from ../../nan/nan_callbacks.h:123,
25.88 npm error                  from ../../nan/nan.h:182,
25.88 npm error                  from ../src/backend/Backend.h:6,
25.88 npm error                  from ../src/Canvas.h:5,
25.88 npm error                  from ../src/Canvas.cc:3:
25.88 npm error ../../nan/nan_callbacks_12_inl.h: In instantiation of 'v8::Local<v8::Object> Nan::FunctionCallbackInfo<T>::Holder() const [with T = v8::Value]':
25.88 npm error ../src/Canvas.cc:649:63:   required from here
25.88 npm error   649 |   Canvas *canvas = Nan::ObjectWrap::Unwrap<Canvas>(info.Holder());
25.88 npm error       |                                                    ~~~~~~~~~~~^~
25.88 npm error ../../nan/nan_callbacks_12_inl.h:112:68: warning: 'v8::Local<v8::Object> v8::FunctionCallbackInfo<F>::Holder() const [with T = v8::Value]' is deprecated: V8 will stop providing access to hidden prototype (i.e. JSGlobalObject). Use This() instead. \nDO NOT try to workaround this by accessing JSGlobalObject via v8::Object::GetPrototype() - it'll be deprecated soon too. \nSee http://crbug.com/333672197.  [-Wdeprecated-declarations]
25.88 npm error   112 |   inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
25.88 npm error       |                                                        ~~~~~~~~~~~~^~
25.88 npm error In file included from /root/.cache/node-gyp/23.6.1/include/node/v8-isolate.h:22,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/v8-snapshot.h:9,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/v8-context.h:15,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/v8.h:26,
25.88 npm error                  from /root/.cache/node-gyp/23.6.1/include/node/node.h:73,
25.88 npm error                  from ../../nan/nan.h:62:
25.88 npm error /root/.cache/node-gyp/23.6.1/include/node/v8-function-callback.h:658:15: note: declared here
25.88 npm error   658 | Local<Object> FunctionCallbackInfo<T>::Holder() const {
25.88 npm error       |               ^~~~~~~~~~~~~~~~~~~~~~~
25.88 npm error In file included from ../src/Image.h:28,
25.88 npm error                  from ../src/CanvasPattern.cc:6:
25.88 npm error /usr/include/librsvg-2.0/librsvg/rsvg.h:1331:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
25.88 npm error  1331 | #if LIBRSVG_CHECK_FEATURE(PIXBUF)
25.88 npm error       | ^~~~~~~~~~~~~~~~~~~
25.88 npm error In file included from ../src/Image.h:28,
25.88 npm error                  from ../src/CanvasRenderingContext2d.cc:13:
25.88 npm error /usr/include/librsvg-2.0/librsvg/rsvg.h:1331:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
25.88 npm error  1331 | #if LIBRSVG_CHECK_FEATURE(PIXBUF)
25.88 npm error       | ^~~~~~~~~~~~~~~~~~~
25.88 npm error ../src/CanvasRenderingContext2d.cc: In member function 'void Context2d::setTextPath(double, double)':
25.88 npm error ../src/CanvasRenderingContext2d.cc:2500:10: warning: enumeration value 'TEXT_ALIGNMENT_LEFT' not handled in switch [-Wswitch]
25.88 npm error  2500 |   switch (state->textAlignment) {
25.88 npm error       |          ^
25.88 npm error ../src/CanvasRenderingContext2d.cc:2500:10: warning: enumeration value 'TEXT_ALIGNMENT_START' not handled in switch [-Wswitch]
25.88 npm error In file included from ../src/Image.h:28,
25.88 npm error                  from ../src/Image.cc:3:
25.88 npm error /usr/include/librsvg-2.0/librsvg/rsvg.h:1331:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
25.88 npm error  1331 | #if LIBRSVG_CHECK_FEATURE(PIXBUF)
25.88 npm error       | ^~~~~~~~~~~~~~~~~~~
25.88 npm error ../src/Image.cc: In member function 'cairo_status_t Image::loadSVGFromBuffer(uint8_t*, unsigned int)':
25.88 npm error ../src/Image.cc:1196:29: warning: 'void rsvg_handle_get_dimensions(RsvgHandle*, RsvgDimensionData*)' is deprecated: Use 'rsvg_handle_get_intrinsic_size_in_pixels' instead [-Wdeprecated-declarations]
25.88 npm error  1196 |   rsvg_handle_get_dimensions(_rsvg, dims);
25.88 npm error       |   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
25.88 npm error /usr/include/librsvg-2.0/librsvg/rsvg.h:661:6: note: declared here
25.88 npm error   661 | void rsvg_handle_get_dimensions (RsvgHandle *handle, RsvgDimensionData *dimension_data);
25.88 npm error       |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
25.88 npm error ../src/Image.cc: In member function 'cairo_status_t Image::renderSVGToSurface()':
25.88 npm error ../src/Image.cc:1235:48: warning: 'gboolean rsvg_handle_render_cairo(RsvgHandle*, cairo_t*)' is deprecated: Use 'rsvg_handle_render_document' instead [-Wdeprecated-declarations]
25.88 npm error  1235 |   gboolean render_ok = rsvg_handle_render_cairo(_rsvg, cr);
25.88 npm error       |                        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
25.88 npm error In file included from /usr/include/librsvg-2.0/librsvg/rsvg.h:1329:
25.88 npm error /usr/include/librsvg-2.0/librsvg/rsvg-cairo.h:90:10: note: declared here
25.88 npm error    90 | gboolean rsvg_handle_render_cairo (RsvgHandle *handle, cairo_t *cr);
25.88 npm error       |          ^~~~~~~~~~~~~~~~~~~~~~~~
25.88 npm error In file included from ../src/Image.h:28,
25.88 npm error                  from ../src/init.cc:22:
25.88 npm error /usr/include/librsvg-2.0/librsvg/rsvg.h:1331:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
25.88 npm error  1331 | #if LIBRSVG_CHECK_FEATURE(PIXBUF)
25.88 npm error       | ^~~~~~~~~~~~~~~~~~~
25.88 npm error /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lfontconfig: No such file or directory
25.88 npm error collect2: error: ld returned 1 exit status
25.88 npm error make: *** [canvas.target.mk:210: Release/obj.target/canvas.node] Error 1
25.88 npm error gyp ERR! build error 
25.88 npm error gyp ERR! stack Error: `make` failed with exit code: 2
25.88 npm error gyp ERR! stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:216:23)
25.88 npm error gyp ERR! System Linux 6.8.0-51-generic
25.88 npm error gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--update-binary" "--module=/usr/src/app/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/src/app/node_modules/canvas/build/Release" "--napi_version=10" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v131"
25.88 npm error gyp ERR! cwd /usr/src/app/node_modules/canvas
25.88 npm error gyp ERR! node -v v23.6.1
25.88 npm error gyp ERR! node-gyp -v v11.0.0
25.88 npm error gyp ERR! not ok 
25.88 npm error node-pre-gyp ERR! build error 
25.88 npm error node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=10 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v131' (1)
25.88 npm error node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/src/app/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
25.88 npm error node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:507:28)
25.88 npm error node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1101:16)
25.88 npm error node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
25.88 npm error node-pre-gyp ERR! System Linux 6.8.0-51-generic
25.88 npm error node-pre-gyp ERR! command "/usr/bin/node" "/usr/src/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
25.88 npm error node-pre-gyp ERR! cwd /usr/src/app/node_modules/canvas
25.88 npm error node-pre-gyp ERR! node -v v23.6.1
25.88 npm error node-pre-gyp ERR! node-pre-gyp -v v1.0.11
25.88 npm error node-pre-gyp ERR! not ok
25.88 npm error A complete log of this run can be found in: /root/.npm/_logs/2025-01-23T22_23_46_945Z-debug-0.log
------
Dockerfile:17
--------------------
  15 |     
  16 |     COPY package.json /usr/src/app/
  17 | >>> RUN npm install
  18 |     COPY ./src /usr/src/app
  19 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1

Desktop (please complete the following information):

  • OS: Ubuntu 24.04.1
@ltagliaferri
Copy link
Collaborator

@amouat looks like there is a bug in this tutorial now

@amouat
Copy link
Collaborator

amouat commented Jan 28, 2025

ohh, the node images changed. I'll take a look.

@amouat
Copy link
Collaborator

amouat commented Jan 28, 2025

So the fix is to add python3 to the apk install list and update the package.json to:

{
  "name": "dnmonster",
  "version": "1.1.0",
  "description": "Node server for KevinGaudin's monsterids",
  "main": "./src/server.js",
  "dependencies": {
    "express": "~4.21.2",
    "canvas": "~3.1.0",
    "seedrandom": "~3.0.5"
  },
  "devDependencies": {
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Adrian Mouat",
  "license": "BSD"
}

This will build for linux/amd64, but still seems to break for arm, so if you're on a mac, you may need to pass --platform linux/amd64 for the build to suceed.

@amouat
Copy link
Collaborator

amouat commented Jan 28, 2025

To get it to work on arm you need to add dependencies to allow it to build the node-gyp binary. The apk install line will change to:

RUN apk update && apk add \
    cairo-dev libjpeg-turbo-dev pango-dev giflib-dev python3 make gcc\
    librsvg-dev glib-dev harfbuzz-dev fribidi-dev expat-dev libxft-dev\
    libfontconfig1

And you also need to add node-gyp to the package.json:

{
  "name": "dnmonster",
  "version": "1.1.1",
  "description": "Node server for KevinGaudin's monsterids",
  "main": "./src/server.js",
  "dependencies": {
    "node-gyp": "~11.0.0",
    "express": "~4.21.2",
    "canvas": "~3.1.0",
    "seedrandom": "~3.0.5"
  },
  "devDependencies": {
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Adrian Mouat",
  "license": "BSD"
}

I'll get the tutorial updated in due course, but unfortunately it requires some re-writing so I'll need to allocate time.

@ltagliaferri
Copy link
Collaborator

I slotted in for the next cycle @amouat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants