0

I need to build a container based on RHEL 8 and then install LoopBack and IBM ApiConnect.

  • Run a container with the RedHat Enterprise Linux 8
docker run -it --name api-framework-rhel8 -v ~/api-framework-rhel8:/api-framework-rhel8 registry.access.redhat.com/ubi8/ubi:8.1 bash
  • Installing Node.js (v12) into the container
curl -sL https://rpm.nodesource.com/setup_12.x | bash -

yum install -y nodejs
  • Install development tools to build native addons
yum install gcc-c++ make

yum install python38

yum install python27
  • Use alternatives to map python to python2 (or python3) - Tried both and both failed during api-connect install.
alternatives --set python /usr/bin/python2
  • Install LoopBack
npm install -g loopback-cli

Install ApiConnect

npm install -g --unsafe-perm=true --allow-root apiconnect

However, this fails with the error message (from the console, 2 sets):

gyp: [Errno 2] No such file or directory while executing command '['python', './generate_build_id.py']' 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/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.19.76-linuxkit
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/apiconnect/node_modules/appmetrics
gyp ERR! node -v v12.18.4
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 

Note that python2 and python3 are installed under /usr/bin and accessible from the container, however, python can not be called.

The second set of errors from the console:

Error: appmetrics@3.1.3 install: `node extract_all_binaries.js || node-gyp rebuild`
error code ELIFECYCLE
error errno 1
error appmetrics@3.1.3 install: `node extract_all_binaries.js || node-gyp rebuild`
error Exit status 1
error Failed at the appmetrics@3.1.3 install script.
error This is probably not a problem with npm. There is likely additional logging output above.
  • Try running the npm install with `--loglevel verbose` for more detail, but as an initial guess, maybe you don't have Python 2.7 installed? That's likely required. – Matt Hamann Sep 22 '20 at 03:47
  • Hi Matt, Performed a `yum install -y python27` and then tried running with `--loglevel verbose`. ``` 60183 verbose stack Error: appmetrics@3.1.3 install: `node extract_all_binaries.js || node-gyp rebuild` 60190 error code ELIFECYCLE 60191 error errno 1 60192 error appmetrics@3.1.3 install: `node extract_all_binaries.js || node-gyp rebuild` 60192 error Exit status 1 60193 error Failed at the appmetrics@3.1.3 install script. 60193 error This is probably not a problem with npm. There is likely additional logging output above. ``` – Steven Ponessa Sep 22 '20 at 04:47
  • Will need to see more log output than that. In addition to the error messages, try capturing more of the log immediately preceding the error lines and add them to your question above. (Comments don't work well for that type of output!) – Matt Hamann Sep 22 '20 at 15:55
  • Matt, I have updated the errors in the question above. I can also make available in GitHub the complete set of console messages and the log file. – Steven Ponessa Sep 23 '20 at 04:57
  • run `python --version` after python install script check which version python using to build by default. – Harsh Vishwakarma Sep 23 '20 at 07:12
  • To answer Harsh's question, `python --version` returned `command not found`. I have subsequently used: `alternatives --set python /usr/bin/python2` and `python3`, and, either way, the `apiconnect` npm install fails – Steven Ponessa Sep 23 '20 at 13:53
  • @Steven Ponessa, is it still failing b/c it can't find `python`? That wasn't clear from your last comment when trying the `alternatives` command. – Matt Hamann Sep 26 '20 at 01:19
  • See the answer I just posted. I believe that will resolved your issue. – Matt Hamann Sep 26 '20 at 02:34

2 Answers2

0

I noticed that you're using Node.js 12.x. The apiconnect toolkit only supports Node.js 10.x.

I tried most of the steps in your question, but switched to Node 10, and that seemed to resolve the issue.

Also, be sure to install python27 and run alternatives --set python /usr/bin/python2 as you mentioned.

Here's the complete Dockerfile I used:

FROM registry.access.redhat.com/ubi8/ubi:8.1

RUN yum update -y && \
    yum install -y python27 gcc-c++ make

RUN alternatives --set python /usr/bin/python2

RUN curl -sL https://rpm.nodesource.com/setup_10.x | bash - && \
    yum install -y nodejs

RUN npm i -g --unsafe-perm=true apiconnect

CMD ["bash"]
Matt Hamann
  • 1,488
  • 12
  • 24
0

This Node version worked for me: node-v8.8.1

Jalaa Zahwa
  • 538
  • 5
  • 16