Open PaulWieland opened 4 years ago
sorry, error in documentation, need to update. The @next refers to old release. Could you please try with the standard npm install node-rfc
?
@bsrdjan still the same error:
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: __strdup: symbol not found
Does the build from source starts after npm install ? If not, could you try to build from source on Alpine container? I need to test.
Yes, I believe it is building from source successfully. I had to RUN apk add cmake
, otherwise the npm install noderfc
fails due to missing cmake
.
Here is the output from the docker build (I truncated the beginning as I don't think its relevant). See Step 39/44
Step 23/44 : USER root
---> Running in ea96c7f7c6d0
Removing intermediate container ea96c7f7c6d0
---> bfa0523b4415
Step 24/44 : RUN mkdir -p /usr/local/sap/nwrfcsdk
---> Running in ac05a00d0d55
Removing intermediate container ac05a00d0d55
---> dde56f180dba
Step 25/44 : ENV SAPNWRFC_HOME /usr/local/sap/nwrfcsdk
---> Running in 1cc2c96a886c
Removing intermediate container 1cc2c96a886c
---> 8b2000e2e77e
Step 26/44 : WORKDIR ${SAPNWRFC_HOME}
---> Running in db63f248fcf3
Removing intermediate container db63f248fcf3
---> fa95d9f78d93
Step 27/44 : RUN curl -O http://some-local-host.net/saprfc/nwrfc750P_4-70002752.zip
---> Running in d7b26fe5a8a3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 18.7M 100 18.7M 0 0 946k 0 0:00:20 0:00:20 --:--:-- 1843k
Removing intermediate container d7b26fe5a8a3
---> b694544c9ed8
Step 28/44 : RUN unzip nwrfc750P_4-70002752.zip
---> Running in cf90291edeba
Archive: nwrfc750P_4-70002752.zip
creating: META-INF/
inflating: META-INF/MANIFEST.MF
creating: nwrfcsdk/
creating: nwrfcsdk/bin/
inflating: nwrfcsdk/bin/rfcexec
inflating: nwrfcsdk/bin/startrfc
creating: nwrfcsdk/demo/
inflating: nwrfcsdk/demo/companyClient.c
inflating: nwrfcsdk/demo/readme.txt
inflating: nwrfcsdk/demo/rfcexec.cpp
inflating: nwrfcsdk/demo/rfcexec.h
inflating: nwrfcsdk/demo/sapnwrfc.ini
inflating: nwrfcsdk/demo/sflightClient.c
inflating: nwrfcsdk/demo/sso2sample.c
inflating: nwrfcsdk/demo/startrfc.cpp
inflating: nwrfcsdk/demo/startrfc.h
inflating: nwrfcsdk/demo/stfcDeepTableServer.c
inflating: nwrfcsdk/demo/ThroughputSample.c
creating: nwrfcsdk/doc/
inflating: nwrfcsdk/doc/licenses.txt
inflating: nwrfcsdk/doc/release_notes.txt
creating: nwrfcsdk/include/
inflating: nwrfcsdk/include/sapdecf.h
inflating: nwrfcsdk/include/sapnwrfc.h
inflating: nwrfcsdk/include/sapuc.h
inflating: nwrfcsdk/include/sapucx.h
creating: nwrfcsdk/lib/
inflating: nwrfcsdk/lib/libicudata.so.50
inflating: nwrfcsdk/lib/libicudecnumber.so
inflating: nwrfcsdk/lib/libicui18n.so.50
inflating: nwrfcsdk/lib/libicuuc.so.50
inflating: nwrfcsdk/lib/libsapnwrfc.so
inflating: nwrfcsdk/lib/libsapucum.so
inflating: SIGNATURE.SMF
Removing intermediate container cf90291edeba
---> e9a5eb204d66
Step 29/44 : RUN mv nwrfcsdk/* ./
---> Running in 02306cb4a725
Removing intermediate container 02306cb4a725
---> 2f8247620436
Step 30/44 : RUN rmdir nwrfcsdk
---> Running in c8522822f8f8
Removing intermediate container c8522822f8f8
---> ba80eb3e755c
Step 31/44 : RUN rm nwrfc750P_4-70002752.zip
---> Running in 370f66e0250b
Removing intermediate container 370f66e0250b
---> 97f51c7ff501
Step 32/44 : ENV LD_LIBRARY_PATH /usr/local/sap/nwrfcsdk/lib
---> Running in c82de36ef0b1
Removing intermediate container c82de36ef0b1
---> e62948ee08cf
Step 33/44 : RUN apk add cmake
---> Running in 2f822c80632b
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/8) Installing libacl (2.2.53-r0)
(2/8) Installing lz4-libs (1.9.2-r0)
(3/8) Installing zstd-libs (1.4.4-r1)
(4/8) Installing libarchive (3.4.2-r0)
(5/8) Installing rhash-libs (1.3.9-r0)
(6/8) Installing libuv (1.34.0-r0)
(7/8) Installing cmake (3.15.5-r0)
(8/8) Installing cmake-bash-completion (3.15.5-r0)
Executing busybox-1.31.1-r9.trigger
OK: 337 MiB in 73 packages
Removing intermediate container 2f822c80632b
---> 56ecbc1f6b97
Step 34/44 : RUN apk add libuuid
---> Running in b4bf474b0004
(1/1) Installing libuuid (2.34-r1)
OK: 337 MiB in 74 packages
Removing intermediate container b4bf474b0004
---> 6efd04dc72aa
Step 35/44 : USER node-red
---> Running in 362cfd67193f
Removing intermediate container 362cfd67193f
---> 3d5736287d3d
Step 36/44 : ENV SAPNWRFC_HOME /usr/local/sap/nwrfcsdk
---> Running in fea8c6870fdf
Removing intermediate container fea8c6870fdf
---> cd182911835e
Step 37/44 : ENV LD_LIBRARY_PATH /usr/local/sap/nwrfcsdk/lib
---> Running in 5f88998d802b
Removing intermediate container 5f88998d802b
---> c8fe96c1221e
Step 38/44 : WORKDIR /data
---> Running in af1afa796f5f
Removing intermediate container af1afa796f5f
---> 4699364846d1
Step 39/44 : RUN npm install node-rfc
---> Running in c172fe33d26c
> node-rfc@1.2.0 preinstall /data/node_modules/node-rfc
> npm install cmake-js prebuild-install prebuild node-addon-api
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm notice created a lockfile as package-lock.json. You should commit this file.
+ node-addon-api@2.0.0
+ prebuild@10.0.0
+ prebuild-install@5.3.4
+ cmake-js@6.1.0
added 252 packages from 217 contributors and audited 252 packages in 29.732s
3 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
> node-rfc@1.2.0 install /data/node_modules/node-rfc
> prebuild-install --tag-prefix -r napi || cmake-js rebuild
prebuild-install WARN install No prebuilt binaries found (target=3 runtime=napi arch=x64 libc=musl platform=linux)
[
'/usr/local/bin/node',
'/data/node_modules/node-rfc/node_modules/.bin/cmake-js',
'rebuild'
]
info TOOL Using Unix Makefiles generator.
info DIST Downloading distribution files.
http DIST - https://nodejs.org/dist/v12.17.0/SHASUMS256.txt
http DIST - https://nodejs.org/dist/v12.17.0/node-v12.17.0-headers.tar.gz
info CMD CLEAN
info RUN cmake -E remove_directory "/data/node_modules/node-rfc/build"
info CMD CONFIGURE
info RUN cmake "/data/node_modules/node-rfc" --no-warn-unused-cli -G"Unix Makefiles" -DCMAKE_JS_VERSION="6.1.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/data/node_modules/node-rfc/build/Release" -DCMAKE_JS_INC="/usr/src/node-red/.cmake-js/node-x64/v12.17.0/include/node" -DCMAKE_JS_SRC="" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="12.17.0" -DNODE_ARCH="x64"
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- 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
-- Generating done
-- Build files have been written to: /data/node_modules/node-rfc/build
info CMD BUILD
info RUN cmake --build "/data/node_modules/node-rfc/build" --config Release
Scanning dependencies of target sapnwrfc
[ 16%] Building CXX object CMakeFiles/sapnwrfc.dir/src/node_sapnwrfc.cc.o
[ 33%] Building CXX object CMakeFiles/sapnwrfc.dir/src/Client.cc.o
[ 50%] Building CXX object CMakeFiles/sapnwrfc.dir/src/rfcio.cc.o
[ 66%] Building CXX object CMakeFiles/sapnwrfc.dir/src/noderfcsdk.cc.o
[ 83%] Building CXX object CMakeFiles/sapnwrfc.dir/src/Throughput.cc.o
[100%] Linking CXX shared library ../lib/binding/sapnwrfc.node
[100%] Built target sapnwrfc
npm WARN saveError ENOENT: no such file or directory, open '/data/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/data/package.json'
npm WARN data No description
npm WARN data No repository field.
npm WARN data No README data
npm WARN data No license field.
+ node-rfc@1.2.0
added 3 packages from 52 contributors and audited 3 packages in 41.279s
found 0 vulnerabilities
Removing intermediate container c172fe33d26c
---> 564c0b3f3fb0
Step 40/44 : RUN npm install node-red-contrib-saprfc
---> Running in 2f7644c778b4
npm WARN saveError ENOENT: no such file or directory, open '/data/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/data/package.json'
npm WARN data No description
npm WARN data No repository field.
npm WARN data No README data
npm WARN data No license field.
+ node-red-contrib-saprfc@1.2.4
added 2 packages from 2 contributors, removed 252 packages and audited 5 packages in 3.326s
found 0 vulnerabilities
Removing intermediate container 2f7644c778b4
---> 25bd206026ba
Step 41/44 : WORKDIR /usr/src/node-red
---> Running in 2a7b67a1b5fd
Removing intermediate container 2a7b67a1b5fd
---> 44b22ed5423e
Step 42/44 : VOLUME ["/data"]
---> Running in 519a9674d38c
Removing intermediate container 519a9674d38c
---> 762232ddcffb
Step 43/44 : EXPOSE 1880
---> Running in c8ddfc5505a1
Removing intermediate container c8ddfc5505a1
---> 5053f2cbd792
Step 44/44 : ENTRYPOINT ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data"]
---> Running in c2abbab87091
Removing intermediate container c2abbab87091
---> 16d81c70ae95
Successfully built 16d81c70ae95
Successfully tagged testing:node-red-build
Then run the container:
docker run -it -p1880:1880 testing:node-red-build
Error in startup:
> node-red-docker@1.0.6 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
29 May 15:17:04 - [info]
Welcome to Node-RED
===================
29 May 15:17:04 - [info] Node-RED version: v1.0.6
29 May 15:17:04 - [info] Node.js version: v12.17.0
29 May 15:17:04 - [info] Linux 4.19.76-linuxkit x64 LE
29 May 15:17:04 - [info] Loading palette nodes
29 May 15:17:05 - [warn] ------------------------------------------------------
29 May 15:17:05 - [warn] [node-red-contrib-saprfc/saprfc] Error: Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: __strdup: symbol not found
29 May 15:17:05 - [warn] ------------------------------------------------------
29 May 15:17:05 - [info] Settings file : /data/settings.js
EDIT: Repasted latest log which eliminates @latest tag from the npm install of node-rfc. Problem still persists.
I forked the node-red-docker project and commited the custom make file for noderfc. Hopefully it helps you if you want to test it
https://github.com/PaulWieland/node-red-docker/tree/master/docker-custom
Does it have to be Alpine Linux? SAP NWRFC SDK is not supported on Alpine, here the list of supported platforms: https://launchpad.support.sap.com/#/notes/2573790
Did it work on nodeRED before, was it another Linux?
The SDK usually works on common desktop/server Linux distros, with node-rfc built from source. Alpine is maybe different and SDK need to be compiled on that platform. That could be the feature request for SAP, because the SDK is closed source.
Hi @bsrdjan, yes it worked on NodeRED before. The issue is that they changed their docker base image to use alpine in order to make it small and efficient.
alpine is quite popular, it is the default base image for nodeJS docker containers (which is why NodeRED uses it), so a lot of nodeJS projects will be built on top of alpine. It would be really good to figure out how to get node-rfc and the NWRFC SDK working with it.
Small update - I think this problem is related to alpine's use of musl
instead of glibc
. There is a way to install glibc
under alpine (which I have done), however I think npm install node-rfc
is still building with musl.
Here's the truncated output of ldd
bash-5.0# ldd ./binding/sapnwrfc.node
/lib/ld-musl-x86_64.so.1 (0x7f9e87cd9000)
libsapnwrfc.so => /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so (0x7f9e8713a000)
libsapucum.so => /usr/local/sap/nwrfcsdk/lib/libsapucum.so (0x7f9e86e00000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f9e86c67000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f9e86c53000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f9e87cd9000)
libdl.so.2 => /lib/ld-musl-x86_64.so.1 (0x7f9e87cd9000)
librt.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f9e87cd9000)
libuuid.so.1 => /lib/libuuid.so.1 (0x7f9e86c4a000)
libm.so.6 => /lib/ld-musl-x86_64.so.1 (0x7f9e87cd9000)
libpthread.so.0 => /lib/ld-musl-x86_64.so.1 (0x7f9e87cd9000)
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: __strdup: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: pthread_mutexattr_setkind_np: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: fcvt_r: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: xdr_string: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: xdr_free: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: qecvt_r: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: rexec: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: __strtok_r: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: getservent_r: symbol not found
Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: backtrace: symbol not found
Notice that it's using /lib/ld-musl-x86_64.so.1
.
I'm trying to figure out how to force npm install node-rfc to use /usr/glibc-compat/lib
instead of /lib
Could you please send me the Dockerfile that I can build and logon to shell, to check?
The build with Dockerfile above ends with error:
$ docker build -t rfcami .
Sending build context to Docker daemon 1.084GB
Step 1/42 : ARG ARCH=amd64
Step 2/42 : ARG NODE_VERSION=10
Step 3/42 : ARG OS=alpine
Step 4/42 : FROM ${ARCH}/node:${NODE_VERSION}-${OS} AS base
---> a07f309c9753
Step 5/42 : COPY scripts/*.sh /tmp/
---> Using cache
---> 84762f076463
Step 6/42 : RUN set -ex && apk add --no-cache bash tzdata iputils curl nano git openssl openssh-client && mkdir -p /usr/src/node-red /data && deluser --remove-home node && adduser -h /usr/src/node-red -D -H node-red -u 1000 && chown -R node-red:root /data && chmod -R g+rwX /data && chown -R node-red:root /usr/src/node-red && chmod -R g+rwX /usr/src/node-red
---> Using cache
---> 4570acf7e6ce
Step 7/42 : WORKDIR /usr/src/node-red
---> Using cache
---> e669dcbbcd27
Step 8/42 : COPY package.json .
---> Using cache
---> f151bfc37138
Step 9/42 : FROM base AS build
---> f151bfc37138
Step 10/42 : RUN apk add --no-cache --virtual buildtools build-base linux-headers udev python && npm install --unsafe-perm --no-update-notifier --only=production && /tmp/remove_native_gpio.sh && cp -R node_modules prod_node_modules
---> Running in cf2018fa2ff5
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/28) Installing binutils (2.33.1-r0)
(2/28) Installing file (5.37-r1)
(3/28) Installing gmp (6.1.2-r1)
(4/28) Installing isl (0.18-r0)
(5/28) Installing libgomp (9.2.0-r4)
(6/28) Installing libatomic (9.2.0-r4)
(7/28) Installing mpfr4 (4.0.2-r1)
(8/28) Installing mpc1 (1.1.0-r1)
(9/28) Installing gcc (9.2.0-r4)
(10/28) Installing musl-dev (1.1.24-r2)
(11/28) Installing libc-dev (0.7.2-r0)
(12/28) Installing g++ (9.2.0-r4)
(13/28) Installing make (4.2.1-r2)
(14/28) Installing fortify-headers (1.1-r0)
(15/28) Installing build-base (0.5-r1)
(16/28) Installing linux-headers (4.19.36-r0)
(17/28) Installing udev-init-scripts (33-r0)
Executing udev-init-scripts-33-r0.post-install
(18/28) Installing eudev-libs (3.2.9-r1)
(19/28) Installing libblkid (2.34-r1)
(20/28) Installing xz-libs (5.2.4-r0)
(21/28) Installing kmod (26-r0)
(22/28) Installing eudev (3.2.9-r1)
(23/28) Installing libbz2 (1.0.8-r1)
(24/28) Installing libffi (3.2.1-r6)
(25/28) Installing gdbm (1.13-r1)
(26/28) Installing sqlite-libs (3.30.1-r2)
(27/28) Installing python2 (2.7.18-r0)
(28/28) Installing buildtools (20200530.044651)
Executing busybox-1.31.1-r9.trigger
Executing eudev-3.2.9-r1.trigger
OK: 252 MiB in 64 packages
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN docker-alpine@1.0.0 No repository field.
up to date in 0.451s
found 0 vulnerabilities
/bin/sh: /tmp/remove_native_gpio.sh: not found
The command '/bin/sh -c apk add --no-cache --virtual buildtools build-base linux-headers udev python && npm install --unsafe-perm --no-update-notifier --only=production && /tmp/remove_native_gpio.sh && cp -R node_modules prod_node_modules' returned a non-zero code: 127
$
This should work:
git clone https://github.com/PaulWieland/node-red-docker.git
node-red-docker/docker-custom
cd node-red-docker/docker-custom
./docker-make.sh
docker run -it -p1880:1880 testing:node-red-build
You can connect to the shell after it's running.
docker ps
- find conatiner iddocker exec -it <container id> /bin/bash
As you already found out, the problem is musl
implementation of the libc used on Alpine, while the glibc
used by SAP NWRFC SDK and by node-rfc. You already tried adding glibc to image and building the node-rfc with glibc added did not help. The problem could be the toolchain itself, built on musl
:
# Alpine
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/9.2.0/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-9.2.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 9.2.0' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-cloog-backend --enable-languages=c,c++,objc,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 9.2.0 (Alpine 9.2.0)
# GNU
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
According to Alpine wiki Running glibc programs it could be eventually possible, with try & errors ... Making glibc
work on Alpine would add a lot of weight to Alpine container, which would actually against musl philosophy (small, secure...). Some users might see that as a problem: node-rfc/#35 and I don't think the efforts are worth of the end-result. Easier path (for users) would be raising a feature request, for musl
platform support by NWRFC SDK. I could not find more information how it could otherwise work, which does not mean is not possible.
@bsrdjan agree the best case would be for SAP to support musl, I just don't know what the likely hood is of that ever happening (or where to even submit the request).
In the short term, it is possible to install glibc on alpine as there is a pretty well maintained add on for it. The problem is I don't know how to get npm install node-rfc
to get cmake to use glibc libs instead of musl. I think normally with make you can specify the library directory, but I haven't got enough experience with how npm builds software to be able to try it.
After the glibc added to node-rfc build script, the build fails with:
Linking CXX shared library ../lib/binding/sapnwrfc.node
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld:
cannot find /usr/glibc-compat/lib/libc_nonshared.a
No idea why but here the setup which can used for further testing.
Dockerfile.custom
I added sudo, use the latest NWRFC SDK PL6 and mapped the local node-rfc repository clone to docker volume, to test build options.
# setup:
# Clone the node-rfc repository and map the node-rfc folder to docker volume
# rebuild:
# docker stop node-rfc-red && docker rm node-rfc-red && docker rmi testing:node-red-build
# ./docker-make.sh
# run:
# docker run -it --name node-rfc-red -p1880:1880 -v /Users/d037732/src:/usr/src/node-red/src testing:node-red-build &
# docker exec -it node-rfc-red /bin/bash
#
# Build script to add SAP's node-rfc to Node RED.
# Download and save nwrfc750P_4-70002752.zip into the same directory as this build script
ARG ARCH=amd64
ARG NODE_VERSION=10
ARG OS=alpine
#### Stage BASE ########################################################################################################
FROM ${ARCH}/node:${NODE_VERSION}-${OS} AS base
# Copy scripts
COPY scripts/*.sh /tmp/
# Install tools, create Node-RED app and data dir, add user and set rights
RUN set -ex && \
apk add --no-cache \
bash \
tzdata \
iputils \
curl \
nano \
git \
openssl \
vim \
libstdc++6 musl-utils sudo su-exec \
openssh-client && \
mkdir -p /usr/src/node-red /data && \
deluser --remove-home node && \
adduser -h /usr/src/node-red -D -H node-red -u 1000 && \
chown -R node-red:root /data && chmod -R g+rwX /data && \
chown -R node-red:root /usr/src/node-red && chmod -R g+rwX /usr/src/node-red && \
echo "node-red ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# chown -R node-red:node-red /data && \
# chown -R node-red:node-red /usr/src/node-red
# Set work directory
WORKDIR /usr/src/node-red
# package.json contains Node-RED NPM module and node dependencies
COPY package.json .
#### Stage BUILD #######################################################################################################
FROM base AS build
# Install Build tools
RUN apk add --no-cache --virtual buildtools build-base linux-headers udev python && \
npm install --unsafe-perm --no-update-notifier --only=production && \
/tmp/remove_native_gpio.sh && \
cp -R node_modules prod_node_modules
#### Stage RELEASE #####################################################################################################
FROM base AS RELEASE
ARG BUILD_DATE
ARG BUILD_VERSION
ARG BUILD_REF
ARG NODE_RED_VERSION
ARG ARCH
ARG TAG_SUFFIX=default
LABEL org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.docker.dockerfile=".docker/Dockerfile.alpine" \
org.label-schema.license="Apache-2.0" \
org.label-schema.name="Node-RED" \
org.label-schema.version=${BUILD_VERSION} \
org.label-schema.description="Low-code programming for event-driven applications." \
org.label-schema.url="https://nodered.org" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-type="Git" \
org.label-schema.vcs-url="https://github.com/node-red/node-red-docker" \
org.label-schema.arch=${ARCH} \
authors="Dave Conway-Jones, Nick O'Leary, James Thomas, Raymond Mouthaan"
COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules
# Chown, install devtools & Clean up
RUN chown -R node-red:root /usr/src/node-red && \
/tmp/install_devtools.sh && \
rm -r /tmp/*
USER node-red
# Env variables
ENV NODE_RED_VERSION=$NODE_RED_VERSION \
NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules \
FLOWS=flows.json
# ENV NODE_RED_ENABLE_SAFE_MODE=true # Uncomment to enable safe start mode (flows not running)
# ENV NODE_RED_ENABLE_PROJECTS=true # Uncomment to enable projects option
#### SAP RFC Stuff
# Install SAP RFC per these instructions
# http://sap.github.io/node-rfc/install.html#sap-nw-rfc-library-installation
# Add bash
# RUN apk add --no-cache bash
# SHELL ["/bin/bash", "-c"]
USER root
RUN mkdir -p /usr/local/sap/nwrfcsdk
ENV SAPNWRFC_HOME /usr/local/sap/nwrfcsdk
WORKDIR ${SAPNWRFC_HOME}
# Copy SAP rfc sdk zip (the latest is PL6)
COPY ./nwrfc750P_6-70002752.zip ${SAPNWRFC_HOME}/
RUN unzip nwrfc750P_6-70002752.zip
RUN mv nwrfcsdk/* ./
RUN chmod a+x ${SAPNWRFC_HOME}/bin/*
RUN rmdir nwrfcsdk
RUN rm nwrfc750P_6-70002752.zip
# ENV LD_LIBRARY_PATH /usr/local/sap/nwrfcsdk/lib
ENV LD_LIBRARY_PATH /lib:/usr/lib:/usr/glibc-compat/lib:/usr/local/sap/nwrfcsdk/lib
# Add GLIBC
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-2.31-r0.apk
RUN apk add glibc-2.31-r0.apk
#
RUN apk add cmake
RUN apk add libuuid
USER node-red
ENV SAPNWRFC_HOME /usr/local/sap/nwrfcsdk
# ENV LD_LIBRARY_PATH /usr/local/sap/nwrfcsdk/lib
WORKDIR /data
# RUN ldconfig
RUN npm install node-rfc
RUN npm install node-red-contrib-saprfc
### END SAP RFC Stuff
WORKDIR /usr/src/node-red
# User configuration directory volume
VOLUME ["/data"]
# Expose the listening port of node-red
EXPOSE 1880
# Add a healthcheck (default every 30 secs)
# HEALTHCHECK CMD curl http://localhost:1880/ || exit 1
ENTRYPOINT ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data"]
The glibc is added to node-rfc build script (search for glibc):
Cmake
# cmake standard
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0042 NEW)
# verbose
set(CMAKE_VERBOSE_MAKEFILE ON)
# C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# project
execute_process(COMMAND node -p "require('./package.json').version"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION)
string(REPLACE "\n" "" VERSION ${VERSION})
project(sapnwrfc VERSION ${VERSION})
# node platform
execute_process(COMMAND node -p "process.platform"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_PLATFORM)
string(REPLACE "\n" "" NODE_PLATFORM ${NODE_PLATFORM})
string(REPLACE "\"" "" NODE_PLATFORM ${NODE_PLATFORM})
# node version
execute_process(COMMAND node -v WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE NODE_VERSION)
string(REPLACE "\n" "" NODE_VERSION ${NODE_VERSION})
# node abi version
execute_process(COMMAND node -p "process.versions.modules"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ABI_VERSION)
string(REPLACE "\n" "" NODE_ABI_VERSION ${NODE_ABI_VERSION})
string(REPLACE "\"" "" NODE_ABI_VERSION ${NODE_ABI_VERSION})
# N-API
set (NAPI_BUILD_VERSION 3)
add_compile_definitions(NAPI_VERSION=${NAPI_BUILD_VERSION})
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NAPI_INCLUDE_DIR
)
string(REPLACE "\n" "" NAPI_INCLUDE_DIR ${NAPI_INCLUDE_DIR})
string(REPLACE "\"" "" NAPI_INCLUDE_DIR ${NAPI_INCLUDE_DIR})
# NodeJS headers download, if needed
if (NOT DEFINED ENV{NODE_HEADERS_INCLUDE_DIR})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
execute_process(COMMAND cmd /c "npm -g prefix"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_HEADERS_INCLUDE_DIR
)
else()
execute_process(COMMAND npm -g prefix
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_HEADERS_INCLUDE_DIR
)
endif()
string(CONCAT NODE_HEADERS_INCLUDE_DIR ${NODE_HEADERS_INCLUDE_DIR} "/include")
string(REPLACE "\n" "" NODE_HEADERS_INCLUDE_DIR ${NODE_HEADERS_INCLUDE_DIR})
if (NOT EXISTS "${NODE_HEADERS_INCLUDE_DIR}")
set(NODE_HEADERS_FILENAME "node-${NODE_VERSION}-headers.tar.gz")
set(NODE_HEADERS_DOWNLD_PATH ${CMAKE_CURRENT_BINARY_DIR}/${NODE_HEADERS_FILENAME})
message("Downloading ${NODE_HEADERS_FILENAME} to ${NODE_HEADERS_DOWNLD_PATH} ...")
file(DOWNLOAD "https://nodejs.org/download/release/${NODE_VERSION}/${NODE_HEADERS_FILENAME}" "${NODE_HEADERS_DOWNLD_PATH}" ) # SHOW_PROGRESS)
execute_process(COMMAND tar -xzf ${NODE_HEADERS_DOWNLD_PATH})
file(REMOVE ${NODE_HEADERS_DOWNLD_PATH})
file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/node-${NODE_VERSION}/include" "${NODE_HEADERS_INCLUDE_DIR}")
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/node-${NODE_VERSION}")
endif()
endif()
# build and binding path
string(CONCAT ADDON_BINDING_PATH "node-v" ${NODE_ABI_VERSION} "-" ${NODE_PLATFORM} "-" ${NODE_ARCH} )
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/binding/)
# sapnwrfc dependencies
set(SAPNWRFC_INCLUDE_DIR $ENV{SAPNWRFC_HOME}/include)
set(SAPNWRFC_LIB_DIR $ENV{SAPNWRFC_HOME}/lib)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(SAPNWRFC_LIB_FILES sapnwrfc.lib libsapucum.lib)
else()
set(SAPNWRFC_LIB_FILES -lsapnwrfc -lsapucum)
endif()
# glibc dependency
set(GLIBC_LIB_DIR /usr/glibc-compat/lib)
set(GLIBC_LIB_FILES -lc)
# source files and target library
add_library(${PROJECT_NAME} SHARED src/node_sapnwrfc.cc src/Client.cc src/rfcio.cc src/noderfcsdk.cc src/Throughput.cc ) # src/Pool.cc)
# build path ignored on Windows, copy after build
if ( MSVC )
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${PROJECT_NAME}>"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}\\$<TARGET_FILE_NAME:${PROJECT_NAME}>"
COMMENT "Copying to output directory" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif ( MSVC )
#
# build
#
# All platforms
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions")
#target_compile_options(${PROJECT_NAME} PUBLIC -fno-exceptions)
# https://launchpad.support.sap.com/#/notes/2573953
target_compile_definitions(${PROJECT_NAME} PUBLIC
_CONSOLE
SAPwithUNICODE UNICODE _UNICODE
_FILE_OFFSET_BITS=64
_LARGEFILE_SOURCE
NDEBUG
SAPwithTHREADS
NAPI_CPP_EXCEPTION)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# show SAP NWRFC SDK version
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ci/utils/nwrfcsdk-version-linux.sh OUTPUT_VARIABLE SAPNWRFCSDK_VERSION)
message("SAP NWRFC SDK: " ${SAPNWRFCSDK_VERSION})
target_compile_options(${PROJECT_NAME} PUBLIC -std=c++11 -Wall)
add_compile_definitions(
SAPonLIN
SAPonUNIX
__NO_MATH_INLINES)
target_link_directories(${PROJECT_NAME} PRIVATE ${GLIBC_LIB_DIR})
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${GLIBC_LIB_FILES})
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# show SAP NWRFC SDK version
execute_process(
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}\\ci\\utils\\nwrfcsdk-version.bat"
OUTPUT_VARIABLE SAPNWRFCSDK_VERSION)
message("SAP NWRFC SDK: " ${SAPNWRFCSDK_VERSION})
# https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically
target_compile_options(${PROJECT_NAME} PUBLIC
-EHs
-Gy
-J
-MD
-nologo
-W3
-Z7
-GL -O2 -Oy-
/we4552 /we4700 /we4789
)
target_compile_definitions(${PROJECT_NAME} PUBLIC
SAP_PLATFORM_MAKENAME=ntintel
SAPonNT
_CRT_NON_CONFORMING_SWPRINTFS
_CRT_SECURE_NO_DEPRECATE
#_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_DEPRECATE
_AFXDLL
WIN32
_WIN32_WINNT=0x0502
_ATL_ALLOW_CHAR_UNSIGNED
)
# https://docs.microsoft.com/en-us/cpp/build/reference/linker-options?view=vs-2019
target_link_options(${PROJECT_NAME} PUBLIC
/NXCOMPAT
/SWAPRUN:NET
/OPT:REF
/NOLOGO
/LTCG
)
if (${NODE_ARCH} STREQUAL "ia32")
target_compile_definitions(${PROJECT_NAME} PUBLIC _X86_ )
target_link_options(${PROJECT_NAME} PUBLIC
-STACK:0x800000
-DEBUGTYPE:CV
-MACHINE:x86
-LARGEADDRESSAWARE
)
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC WIN64 _AMD64_ )
target_link_options(${PROJECT_NAME} PUBLIC
-STACK:0x2000000
-DEBUG
-DEBUGTYPE:CV,FIXUP
-MACHINE:amd64
)
endif()
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
# show SAP NWRFC SDK version
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ci/utils/nwrfcsdk-version-darwin.sh OUTPUT_VARIABLE SAPNWRFCSDK_VERSION)
message("SAP NWRFC SDK: " ${SAPNWRFCSDK_VERSION})
target_compile_options(${PROJECT_NAME} PUBLIC -stdlib=libc++ -std=c++0x -Wall -mmacosx-version-min=10.10)
add_compile_definitions(
SAPonDARW
__NO_MATH_INLINES)
endif()
# set .node extension without any "lib" prefix
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
set (${PROJECT_NAME}_USE_STATIC_LIBS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
# build target
target_include_directories(${PROJECT_NAME} PRIVATE "${NODE_HEADERS_INCLUDE_DIR}/node" ${NAPI_INCLUDE_DIR} ${SAPNWRFC_INCLUDE_DIR})
target_link_directories(${PROJECT_NAME} PRIVATE ${SAPNWRFC_LIB_DIR})
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${SAPNWRFC_LIB_FILES})
The node-rfc re-build is done by following command, resulting in above mentioned error:
npm run prebuild
The linker invocation command is traced in build/CMakeFiles/sapnwrfc.dir/link.txt
file:
/usr/bin/c++ -fPIC -O3 -DNDEBUG -shared -Wl,-soname,sapnwrfc.node -o ../lib/binding/sapnwrfc.node
CMakeFiles/sapnwrfc.dir/src/node_sapnwrfc.cc.o
CMakeFiles/sapnwrfc.dir/src/Client.cc.o
CMakeFiles/sapnwrfc.dir/src/rfcio.cc.o
CMakeFiles/sapnwrfc.dir/src/noderfcsdk.cc.o
CMakeFiles/sapnwrfc.dir/src/Throughput.cc.o
-L/usr/glibc-compat/lib -L/usr/local/sap/nwrfcsdk/lib
-Wl,-rpath,/usr/glibc-compat/lib:/usr/local/sap/nwrfcsdk/lib
-lc -lsapnwrfc -lsapucum
Following this thread I added libc-dev to Dockerfile.custom but no effect. Not sure why this lib is required and if that is the correct lib or perhaps there is a "compat" counterpart? glibc-compat experts might eventually help?
@bsrdjan Thank you so much for taking the time to troubleshoot this. I haven't got a lot of time today, but hopefully in the next few days I can take what you've done and do some further experimentation.
I got a hit for /usr/glibc-compat/lib/libc_nonshared.a
on https://github.com/sgerrand/alpine-pkg-glibc/pull/44. It looks like there may be a -dev
branch, so I will try that.
EDIT: it's here;
# RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-2.31-r0.apk
# RUN apk add glibc-2.31-r0.apk
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-dev-2.31-r0.apk
RUN apk add glibc-dev-2.31-r0.apk
The node-rfc
link error when using dev branch is different :
$ npm run prebuild
...
[100%] Linking CXX shared library ../lib/binding/sapnwrfc.node
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld:
/usr/glibc-compat/lib/libc.a(malloc.o): relocation R_X86_64_TPOFF32 against `tcache' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld:
/usr/glibc-compat/lib/libc.a(assert.o): relocation R_X86_64_PC32 against symbol `__progname' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: final link failed: bad value
Closing. I don't think this is possible or practical without a native MUSL version of nwrfc from SAP.
@bsrdjan agree the best case would be for SAP to support musl, I just don't know what the likely hood is of that ever happening (or where to even submit the request).
@PaulWieland I found the place where to submit the request: https://launchpad.support.sap.com/#/notes/11
I personally consider the requirement relevant and it would be great if you could describe in more detail and submit the request. No guarantee it will be adopted but it helps when others can find and support the request.
So i'm logged into the customer influence website. It seems that in order to submit an improvement request, I first have to pick a platform that I want improved - however I don't find anything seemingly relevant to the NWRFC software.
Searching for RFC
turned up a few improvements for product SAP Process Orchestration however it appears that it is closed.
Any ideas?
The feature request shall be created for Security Services
category of the SAP Cloud Platform – Platform Foundation campaign.
Please mention the SAP NWRFC SDK in the request title and share the request link here.
I am getting this error in alpine when installing node-rfc. I even tried command npm run addon. getting same error. Is their any solution for this?
To make the node-rfc available on Alpine Linux, SAP NWRFC SDK shall be supported on that platform.
You can create or vote for SAP NWRFC SDK feature request, please see my comment above: https://github.com/SAP/node-rfc/issues/148#issuecomment-716477460
Hello @bsrdjan Is there any update on this? Is Alpine supported currently?
I'm trying to deploy noderfc under Alpine Linux (specifically node-red docker), but it seems like I might be having issues with ldconfig.
My dockerfile builds, but when my program runs I get the following error:
Error: Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: __strdup: symbol not found
This is a really similar error as this one, so I am assuming this is an ldconfig problem. However I'm learning that under alpine
ldconfig
is somehow different from other mainstream linux distros.I read that under alpine linux
LD_LIBRARY_PATH=/usr/local/sap/nwrfcsdk/lib
should accomplish the same as loading the/etc/ld.so.conf.d/nwrfcsdk.conf
withldconfig
as you would do in other distros, but clearly something isn't working.Any ideas?
Here is my dockerfile (scroll to #### SAP RFC Stuff, the rest is standard node-red dockerfile).
P.S. There is a curl command to pull the nwrfcsdk.zip file from a local server since I do not think SAP hosts this file for public download - if I'm wrong about that please let me know so I can make a dockerfile that will work for everyone.