0

I am behind a corporate firewall and I have a node.js application to deploy on Openshift container via a docker image. The application requires oracledb add-on binaries - Oracle InstantClient packages to be configured on the server.

I have following Dockerfile:

FROM devops-automation-docker<....>/rhel7-nodejs-10:latest
RUN mkdir -p /opt/oracle
# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app

ENV PATH /usr/src/app/node_modules/.bin:$PATH

COPY . .

RUN mv instantclient_11_2 /opt/oracle
ENV LD_LIBRARY_PATH /opt/oracle/instantclient_11_2

RUN sh -c "echo /opt/oracle/instantclient_11_2 > /etc/ld.so.conf.d/oracle-instantclient.conf" && \
    ldconfig && \ 
    echo ${LD_LIBRARY_PATH} && \
    npm ci 


EXPOSE 3002

CMD ["node", "server.js"]

The build is getting successful but when I deploy and run, it throws me following error:

/usr/src/app/design-pattern-exemplars/node_modules/oracledb/lib/oracledb.js:68 throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo)); ^

Error: NJS-045: cannot load the oracledb add-on binary for Node.js 10.16.0 (linux, x64) Cannot load /usr/src/app/design-pattern-exemplars/node_modules/oracledb/build/Release/oracledb.node /usr/src/app/design-pattern-exemplars/node_modules/oracledb/build/Release/oracledb.node: invalid ELF header Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig. If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

at Object.<anonymous> (/usr/src/app/design-pattern-exemplars/node_modules/oracledb/lib/oracledb.js:68:13)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/src/app/design-pattern-exemplars/node_modules/oracledb/index.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:776:30)

What am I doing wrong?

P.S. the first 2 commands were added after I saw some other post on SO which had some similar type of issue but it wasn't with docker and was run via sudo.

Please help! I went through other posts since last 10 days and I feel helpless now. Let me know if anything else is required.

1 Answer 1

1

At a first guess, you are copying the node-oracledb install from a different host architecture. Since node-oracledb has a binary component, this can cause problems. But having said that, newer node-oracledb versions can be copied between the operating systems that pre-supplied binaries are available for. What is your version of node-oracledb? The latest is 4.0. Do you have node-oracledb as a dependency in package.json?

My suggestions: start by doing an install in the Dockerfile following https://blogs.oracle.com/opal/dockerfiles-for-node-oracledb-are-easy-and-simple:

FROM oraclelinux:7-slim

RUN  yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \
     yum-config-manager --disable ol7_developer_EPEL && \
     yum -y install oracle-instantclient19.3-basiclite nodejs && \
     rm -rf /var/cache/yum

WORKDIR /myapp
ADD package.json /myapp/
ADD index.js /myapp/
RUN npm install

CMD exec node index.js

My package.json has oracledb as a dependency. Note I don't even run ldconfig because the 19.3 RPM Instant Client already does that.

If it turns out that there isn't a binary for your docker container architecture, you will have to compile from source code, again inside the Dockerfile.

Update: you may be interested in the new blog post Docker for Oracle Database Applications in Node.js and Python.

Some comments:

  • (i) why use such an old Instant Client - newer ones will connect to 11.2 DB or later. What's your DB version?
  • (ii) No need to set LD_LIBRARY_PATH if you have already run ldconfig.
  • (iii) when I am behind a fire wall, I add something like this to my Dockerfile: ENV https_proxy=http://example.com:80 and/or RUN npm config set proxy http://example.com:80
Sign up to request clarification or add additional context in comments.

3 Comments

In my package.json, the dependency version of oracledb is 3.1.1 and db version is 11g - 11.2.0.4.0.
Also, Since I am behind a corporate firewall, any installation would be a problem and the yum installations are not working perfectly. Currently, I do have instantclient zip of version 11.2. So If I upgrade to oracledb-4.0, will taht be compatible wioth my current instantclient version? Or I need a newer version of instantclient?
For yum I sometimes use RUN echo proxy=http://proxy.example.com:80 >> /etc/yum.conf in the Dockerfile. node-oracledb 4 works with Oracle client 11.2 or later. Make sure your num install when you build the image is downloading node-oracledb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.