IBM/node-odbc

[HELP] npm install 'node-odbc' fails on Docker image

Closed this issue · 3 comments

I am able to install the package ok on my host machine, however it fails when attempting to install it on a local Linux-based Docker image.

Image: public.ecr.aws/docker/library/node:16.20.0-bullseye

Are there certain requirements like C++ libraries or peer dependencies that need to be present on the host machine? Is Node 16 ok? Appreciate any help or pointers.

Here's the error log after running 'npm i odbc':

PS C:\Users\U0157228\projects\vcc\host> docker build -t vcc .
[+] Building 43.7s (18/18) FINISHED                                                       docker:default 
 => [internal] load build definition from Dockerfile                                                0.0s 
 => => transferring dockerfile: 997B                                                                0.0s 
 => [internal] load .dockerignore                                                                   0.0s 
 => => transferring context: 2B                                                                     0.0s 
 => [internal] load metadata for public.ecr.aws/docker/library/node:16.20.0-bullseye                1.3s 
 => [internal] load build context                                                                   0.0s 
 => => transferring context: 21.75kB                                                                0.0s 
 => [vcc_host  1/12] FROM public.ecr.aws/docker/library/node:16.20.0-bullseye@sha256:46a861b32fa3e  0.0s 
 => CACHED [vcc_host  2/12] WORKDIR /usr/src/vcc                                                    0.0s 
 => CACHED [vcc_host  3/12] COPY package.json ./                                                    0.0s 
 => CACHED [vcc_host  4/12] COPY odbc.ini ./                                                        0.0s 
 => CACHED [vcc_host  5/12] COPY odbcinst.ini ./                                                    0.0s 
 => CACHED [vcc_host  6/12] COPY ./dist ./dist                                                      0.0s 
 => CACHED [vcc_host  7/12] COPY ./server.ts ./server.ts                                            0.0s 
 => CACHED [vcc_host  8/12] COPY ./tsconfig.json ./tsconfig.json                                    0.0s 
 => CACHED [vcc_host  9/12] COPY ./env/vcc.env ./env/vcc.env                                        0.0s 
 => CACHED [vcc_host 10/12] RUN apt-get update                                                      0.0s 
 => CACHED [vcc_host 11/12] RUN apt-get install -y unixodbc unixodbc-dev                            0.0s 
 => CACHED [vcc_host 12/12] RUN apt-get update     && apt-get install wget -y     && wget --no-che  0.0s 
 => CACHED [vcc_host1 1/2] RUN npm config set strict-ssl false                                      0.0s 
 => ERROR [vcc_host1 2/2] RUN npm install                                                          42.4s 
------
 > [vcc_host1 2/2] RUN npm install:
42.28 npm notice
42.28 npm notice New major version of npm available! 8.19.4 -> 10.5.0
42.28 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>
42.28 npm notice Run `npm install -g npm@10.5.0` to update!
42.28 npm notice
42.28 npm ERR! code 1
42.28 npm ERR! path /usr/src/vcc/node_modules/odbc
42.28 npm ERR! command failed
42.28 npm ERR! command sh -c -- node-pre-gyp install --fallback-to-build
42.28 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 --module=/usr/src/vcc/node_modules/odbc/lib/bindings/napi-v6/odbc.node --module_name=odbc --module_path=/usr/src/vcc/node_modules/odbc/lib/bindings/napi-v6 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
42.28 npm ERR! node-pre-gyp info it worked if it ends with ok
42.28 npm ERR! node-pre-gyp info using node-pre-gyp@1.0.11
42.28 npm ERR! node-pre-gyp info using node@16.20.0 | linux | x64
42.28 npm ERR! node-pre-gyp info check checked for "/usr/src/vcc/node_modules/odbc/lib/bindings/napi-v6/odbc.node" (not found)
42.28 npm ERR! node-pre-gyp http GET https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-linux-x64-napi-v6.tar.gz
42.28 npm ERR! node-pre-gyp ERR! install request to https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-linux-x64-napi-v6.tar.gz failed, reason: unable to get local issuer certificate  
42.28 npm ERR! node-pre-gyp WARN Pre-built binaries not installable for odbc@2.4.8 and node@16.20.0 (node-v93 ABI, glibc) (falling back to source compile with node-gyp)
42.28 npm ERR! node-pre-gyp WARN Hit error request to https://github.com/markdirish/node-odbc/releases/download/v2.4.8/odbc-v2.4.8-linux-x64-napi-v6.tar.gz failed, reason: unable to get local issuer certificate
42.28 npm ERR! gyp info it worked if it ends with ok
42.28 npm ERR! gyp info using node-gyp@9.1.0
42.28 npm ERR! gyp info using node@16.20.0 | linux | x64
42.28 npm ERR! gyp info ok
42.28 npm ERR! gyp info it worked if it ends with ok
42.28 npm ERR! gyp info using node-gyp@9.1.0
42.28 npm ERR! gyp info using node@16.20.0 | linux | x64
42.28 npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
42.28 npm ERR! gyp http GET https://nodejs.org/download/release/v16.20.0/node-v16.20.0-headers.tar.gz    
42.28 npm ERR! gyp WARN install got an error, rolling back install
42.28 npm ERR! gyp ERR! configure error
42.28 npm ERR! gyp ERR! stack FetchError: request to https://nodejs.org/download/release/v16.20.0/node-v16.20.0-headers.tar.gz failed, reason: unable to get local issuer certificate
42.28 npm ERR! gyp ERR! stack     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
42.28 npm ERR! gyp ERR! stack     at ClientRequest.emit (node:events:513:28)
42.28 npm ERR! gyp ERR! stack     at TLSSocket.socketErrorListener (node:_http_client:494:9)
42.28 npm ERR! gyp ERR! stack     at TLSSocket.emit (node:events:525:35)
42.28 npm ERR! gyp ERR! stack     at emitErrorNT (node:internal/streams/destroy:157:8)
42.28 npm ERR! gyp ERR! stack     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
42.28 npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21) 
42.28 npm ERR! gyp ERR! System Linux 5.15.133.1-microsoft-standard-WSL2
42.28 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" "--module=/usr/src/vcc/node_modules/odbc/lib/bindings/napi-v6/odbc.node" "--module_name=odbc" "--module_path=/usr/src/vcc/node_modules/odbc/lib/bindings/napi-v6" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6"    
42.28 npm ERR! gyp ERR! cwd /usr/src/vcc/node_modules/odbc
42.28 npm ERR! gyp ERR! node -v v16.20.0
42.28 npm ERR! gyp ERR! node-gyp -v v9.1.0
42.28 npm ERR! gyp ERR! not ok
42.28 npm ERR! node-pre-gyp ERR! build error
42.28 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 --module=/usr/src/vcc/node_modules/odbc/lib/bindings/napi-v6/odbc.node --module_name=odbc --module_path=/usr/src/vcc/node_modules/odbc/lib/bindings/napi-v6 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
42.28 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/src/vcc/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
42.28 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
42.28 npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
42.28 npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
42.28 npm ERR! node-pre-gyp ERR! System Linux 5.15.133.1-microsoft-standard-WSL2
42.28 npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/src/vcc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
42.28 npm ERR! node-pre-gyp ERR! cwd /usr/src/vcc/node_modules/odbc
42.28 npm ERR! node-pre-gyp ERR! node -v v16.20.0
42.29 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
42.29 npm ERR! node-pre-gyp ERR! not ok
42.29
42.29 npm ERR! A complete log of this run can be found in:
42.29 npm ERR!     /root/.npm/_logs/2024-02-28T21_12_14_902Z-debug-0.log
------
Dockerfile:28
--------------------
  26 |     FROM vcc_host AS vcc_host1
  27 |     RUN npm config set strict-ssl false
  28 | >>> RUN npm install
  29 |     # COPY /opt/amazon/redshiftodbc/lib/64/amazon.redshiftodbc.ini ./
  30 |
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1     
PS C:\Users\U0157228\projects\vcc\host> 

This seems to be your problem:

42.28 npm ERR! gyp ERR! stack FetchError: request to https://nodejs.org/download/release/v16.20.0/node-v16.20.0-headers.tar.gz failed, reason: unable to get local issuer certificate

The docker image doesn't seem to have the CA certificate for Node.js in its trust store. I don't know why this would be the case, but maybe they changed the CA they use or something? Nothing to do with node-odbc, however. Maybe a newer image will solve it? FYI Node 16 went EOL in September 2023 so probably a good idea to move up to a supported Node.js anyway.

Yes, that was the issue. I tested it by temporarily adding this in my Dockerfile:
ENV NODE_TLS_REJECT_UNAUTHORIZED=0

I will look at upgrading the base image - thanks!

Issues resolved - closing, thanks.