'fatal error: foundationdb/fdb_c.h: No such file or directory in Docker Container

I'm trying to install the foundationdb client on a Docker image where we currently have an existing nodejs distroless-base running. Including the relevant parts:

Essentially my node app requires foundationdb: 1.1.3 in the package.json.

So when I run this part of my container

FROM docker.io/node AS fdbcli
ARG FDB_VERSION="7.1.1"
RUN apt-get install curl dpkg
RUN curl -L -o /tmp/foundationdb-clients_${FDB_VERSION}-1_amd64.deb https://github.com/apple/foundationdb/releases/download/${FDB_VERSION}/foundationdb-clients_${FDB_VERSION}-1_amd64.deb
RUN dpkg -i /tmp/foundationdb-clients_${FDB_VERSION}-1_amd64.deb

FROM docker.io/library/node:16.14.0-alpine
COPY ["./src", "package.json", "package-lock.json", "/app/"]
WORKDIR /app
RUN apk add g++ make python3
COPY --from=fdbcli /tmp /app
`RUN --mount=type=secret,id=npm,target=/root/.npmrc npm ci --only=production` 

I get the error:

#19 6.527 npm ERR! code 1
#19 6.527 npm ERR! path /app/node_modules/foundationdb
#19 6.529 npm ERR! command failed
#19 6.529 npm ERR! command sh -c node-gyp-build
#19 6.529 npm ERR! make: Entering directory '/app/node_modules/foundationdb/build'
#19 6.529 npm ERR!   CXX(target) Release/obj.target/fdblib/src/module.o
#19 6.529 npm ERR! make: Leaving directory '/app/node_modules/foundationdb/build'
#19 6.529 npm ERR! gyp info it worked if it ends with ok
#19 6.529 npm ERR! gyp info using [email protected]
#19 6.529 npm ERR! gyp info using [email protected] | linux | x64
#19 6.529 npm ERR! gyp info find Python using Python version 3.9.7 found at "/usr/bin/python3"
#19 6.529 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.14.0/node-v16.14.0-headers.tar.gz
#19 6.529 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.14.0/node-v16.14.0-headers.tar.gz
#19 6.529 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.14.0/SHASUMS256.txt
#19 6.530 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.14.0/SHASUMS256.txt
#19 6.530 npm ERR! gyp info spawn /usr/bin/python3
#19 6.530 npm ERR! gyp info spawn args [
#19 6.530 npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
#19 6.530 npm ERR! gyp info spawn args   'binding.gyp',
#19 6.530 npm ERR! gyp info spawn args   '-f',
#19 6.530 npm ERR! gyp info spawn args   'make',
#19 6.530 npm ERR! gyp info spawn args   '-I',
#19 6.530 npm ERR! gyp info spawn args   '/app/node_modules/foundationdb/build/config.gypi',
#19 6.530 npm ERR! gyp info spawn args   '-I',
#19 6.530 npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
#19 6.530 npm ERR! gyp info spawn args   '-I',
#19 6.530 npm ERR! gyp info spawn args   '/root/.cache/node-gyp/16.14.0/include/node/common.gypi',
#19 6.531 npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
#19 6.531 npm ERR! gyp info spawn args   '-Dvisibility=default',
#19 6.531 npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.14.0',
#19 6.531 npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
#19 6.531 npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.14.0/<(target_arch)/node.lib',
#19 6.531 npm ERR! gyp info spawn args   '-Dmodule_root_dir=/app/node_modules/foundationdb',
#19 6.531 npm ERR! gyp info spawn args   '-Dnode_engine=v8',
#19 6.531 npm ERR! gyp info spawn args   '--depth=.',
#19 6.531 npm ERR! gyp info spawn args   '--no-parallel',
#19 6.531 npm ERR! gyp info spawn args   '--generator-output',
#19 6.531 npm ERR! gyp info spawn args   'build',
#19 6.531 npm ERR! gyp info spawn args   '-Goutput_dir=.'
#19 6.531 npm ERR! gyp info spawn args ]
#19 6.532 npm ERR! gyp info spawn make
#19 6.532 npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
#19 6.532 npm ERR! In file included from ../src/module.cpp:26:
#19 6.532 npm ERR! ../src/utils.h:13:10: fatal error: foundationdb/fdb_c.h: No such file or directory
#19 6.532 npm ERR!    13 | #include <foundationdb/fdb_c.h>
#19 6.532 npm ERR!       |          ^~~~~~~~~~~~~~~~~~~~~~
#19 6.532 npm ERR! compilation terminated.
#19 6.532 npm ERR! make: *** [fdblib.target.mk:119: Release/obj.target/fdblib/src/module.o] Error 1
#19 6.532 npm ERR! gyp ERR! build error 
#19 6.532 npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
#19 6.532 npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
#19 6.532 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
#19 6.532 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
#19 6.532 npm ERR! gyp ERR! System Linux 5.10.102.1-microsoft-standard-WSL2
#19 6.532 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#19 6.532 npm ERR! gyp ERR! cwd /app/node_modules/foundationdb
#19 6.532 npm ERR! gyp ERR! node -v v16.14.0
#19 6.532 npm ERR! gyp ERR! node-gyp -v v8.4.1
#19 6.532 npm ERR! gyp ERR! not ok

What do I need to do to install the foundationdb: 1.1.3 in a Docker container. I've tried just using the .so file and moving the file other places and can't seem to get foundationdb npm package installed in a container.

The guide indicates you should just be able to use the client.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source