SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
252 stars 74 forks source link

using node-rfc in a docker container on openshift #125

Closed skyd0me closed 4 years ago

skyd0me commented 4 years ago

Hi,

I try to use the node rfc in an docker container on a openshift cluster. Therefore I created a new base image with preinstalled sdk. That worked without any issues. But when I try to install the node-rfc lib to this container, it always tries to execute the prebuild step.

prebuild info build Preparing to prebuild node-rfc@1.0.3 for napi 3 on linux-x64 using cmake-js
prebuild verb starting build process cmake-js 
[
'/usr/bin/node',
'/home/jenkins/agent/workspace/myproject/node_modules/node-rfc/node_modules/.bin/cmake-js',
'rebuild',
'--arch=x64',
'--CDnapi_build_version=3'
]

As our jenkins pipeline has no connection to the internet and all dependencies are pulled from our internal artifactory, the prebuild process is failing somehow.

The image is based on RHEL8. Here are some details about the platform:

node -p process.arch = x64
node -p process.platform = linux
node --version = v12.4.0

My understanding is, that you are already providing the lib with prebuild sources for this platform.

bsrdjan commented 4 years ago

The node-rfc package comprises of nodejs platform independent code and platform specific binary.

npm install node-rfc is pulling the platform independent part (JavaScript) from the global npm: https://www.npmjs.com/package/node-rfc. In your case that part is downloaded from the local npm repository, correct?

After that done, the prebuild script identifies the client platform and pulls the platform specific binary for that platform, from the global github node-rfc release. If the binary is not found there, the build from source starts.

Forcing the build from source on client platform, even if the binary is available on github, could eventually prevent internet calls:

$ npm install --build-from-source node-rfc

Build from source is for Linux systems recommended anyway, because one platform "Linux" is too generic, to cover subtle differences among Linux distributions. Local build from source, requires native CMake installed on a client.

skyd0me commented 4 years ago

Thank you for the hint.
I tried npm install from source but it fails during the cmake step.

node -p "process.arch" --> x64
cmake --version --> 3.15.3
Env variable SAPNWRFC_HOME=/usr/local/sap/nwrfcsdk

> node-rfc@1.0.3 prebuild /code/node_modules/node-rfc
> prebuild --backend cmake-js -r napi --force --strip --verbose --tag-prefix

prebuild info begin Prebuild version 9.1.1
prebuild info build Preparing to prebuild node-rfc@1.0.3 for napi 3 on linux-x64 using cmake-js
prebuild verb starting build process cmake-js
[
  '/usr/bin/node',
  '/code/node_modules/node-rfc/node_modules/.bin/cmake-js',
  'rebuild',
  '--arch=x64',
  '--CDnapi_build_version=3'
]
info TOOL Using Unix Makefiles generator.
info DIST Downloading distribution files.
http DIST       - https://nodejs.org/dist/v12.4.0/SHASUMS256.txt
http DIST       - https://nodejs.org/dist/v12.4.0/node-v12.4.0-headers.tar.gz
info CMD CLEAN
info RUN cmake -E remove_directory "/code/node_modules/node-rfc/build"
info CMD CONFIGURE
info RUN cmake "/code/node_modules/node-rfc" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="5.3.2" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/code/node_modules/node-rfc/build/Release" -DCMAKE_JS_INC="/opt/app-root/src/.cmake-js/node-x64/v12.4.0/include/node" -DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="12.4.0" -DNODE_ARCH="x64" -Dnapi_build_version="3"
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
SAP NWRFC SDK: 
-- Configuring done
CMake Error at CMakeLists.txt:82 (add_library):
  Cannot find source file:

    src/client.cc

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at CMakeLists.txt:82 (add_library):
  No SOURCES given to target: sapnwrfc

CMake Generate step failed.  Build files cannot be regenerated correctly.
ERR! OMG Process terminated: 1
prebuild ERR! build Error: Failed to build cmake with exit code 1
prebuild ERR! build     at ChildProcess.<anonymous> (/code/node_modules/node-rfc/node_modules/prebuild/cmakebuild.js:32:19)
prebuild ERR! build     at ChildProcess.emit (events.js:200:13)
prebuild ERR! build     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
bsrdjan commented 4 years ago

Your npm install downloads from the local npm server, correct?

Then the prebuild installer shall download the node-rfc source code and looks at location defined in package.json, which is a public github, not reachable from your environment.

The reference to public github in package.json shall be changed to your local github instance, hosting the node-rfc (with patched package.json).

This modified node-rfc shall be then published on your local npm, which will then look into local github.

Perhaps a simpler solution possible, need to investigate.

skyd0me commented 4 years ago

hmm isn't the reason to use --build-from-source to exactly skip this step?

prebuild-install [options]
  --build-from-source           (skip prebuild download)

I tried it locally on my pc within the docker container with connection to the internet and I got the same results as mentioned above.

RUN npm install --build-from-source node-rfc  

I also did a manual git clone of your project to check if the connection to your github repo is possible and it worked fine.
So connection to your github should not be an issue in this setup.

UPDATE: I also did a short test with the sources downloaded via git clone:

RUN git clone --branch v1.0.3 https://github.com/SAP/node-rfc.git --depth 1
WORKDIR /node-rfc
RUN npm install
RUN npm run prebuild

The reason why I'm referencing the v1.0.3 branch and not the master branch is due to a required installation of nvm in the latest CMakeList, which is not installed on my linux containers.

bsrdjan commented 4 years ago

First, thank you for the NVM hint. The NVM dependency is now removed and master already updated.

The error log message above is telling that the compiler is not finding the node-rfc source code:

CMake Error at CMakeLists.txt:82 (add_library):
  Cannot find source file:

    src/client.cc

That made me think that the github is probably not reached. If the github is reachable, not sure what else could be the cause of the message? Is the source code indeed there?

bsrdjan commented 4 years ago

If easier, let have a Skype call ? Connect via LinkedIn eventually?

skyd0me commented 4 years ago

Yes that would be great. I added you in LinkedIn.

bsrdjan commented 4 years ago

Looks closed.