brianc / node-libpq

Simple, low level native bindings to PostgreSQL's libpq from node.js
111 stars 41 forks source link

Failing pg-native installation on Docker with node 12.14-slim #80

Closed betsy-fu closed 3 years ago

betsy-fu commented 3 years ago

Hi all, I created an issue with node-gyp here, and they redirected me, as it seems to be an issue with libpq's use of node-gyp.

X-posting the text of the issue below:

I am doing an apt-get update && apt-get install with the following dependencies, some of which were suggested by the pg-native module, but am still getting this error.

It is installing fine on macOS Big Sur with node 12.18.3. Any help would be appreciated, thanks!

Verbose output (from npm or node-gyp): ``` error /app/node_modules/libpq: Command failed. Exit code: 1 Command: node-gyp rebuild Arguments: Directory: /app/node_modules/libpq Output: gyp info it worked if it ends with ok gyp info using node-gyp@5.0.5 gyp info using node@12.14.1 | linux | x64 gyp info find Python using Python version 2.7.13 found at "/usr/bin/python" gyp http GET https://nodejs.org/download/release/v12.14.1/node-v12.14.1-headers.tar.gz gyp http 200 https://nodejs.org/download/release/v12.14.1/node-v12.14.1-headers.tar.gz gyp http GET https://nodejs.org/download/release/v12.14.1/SHASUMS256.txt gyp http 200 https://nodejs.org/download/release/v12.14.1/SHASUMS256.txt gyp info spawn /usr/bin/python gyp info spawn args [ gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/app/node_modules/libpq/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/root/.cache/node-gyp/12.14.1/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/12.14.1', gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/12.14.1/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/app/node_modules/libpq', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] find: '/usr/pg*': No such file or directory gyp: Call to 'which pg_config || find /usr/bin /usr/local/bin /usr/pg* /opt -executable -name pg_config -print -quit' returned exit status 1 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:223:5) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) gyp ERR! System Linux 5.4.39-linuxkit gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /app/node_modules/libpq gyp ERR! node -v v12.14.1 gyp ERR! node-gyp -v v5.0.5 gyp ERR! not ok ```
betsy-fu commented 3 years ago

Turns out I had messed up some config in my Dockerfile, closing. apt-get update && apt-get install -y libpq-dev g++ make was sufficient

dberardo-com commented 11 months ago

have you managed to reduce the size of the docker image at the end ? is it possible to uninstall some component after build ?