I am new at deployments and dockerfiles. I am having issues connecting to the oracledb in nodejs. I used the prebuilt instantclient image from docker and setting the LD_LIBRARY_PATH to the lib folder with all the files. Here's the dockerfile:
FROM node:14-slim AS build-stage
COPY . /home/app
ENV APPLICATION_NAME="::apiName::"
WORKDIR /home/app
RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get install -y libpq-dev zlib1g-dev libaio1 libaio-dev wget unzip
RUN wget get https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basiclite-linux.x64-21.7.0.0.0dbru.zip
RUN alien -i --scripts oracle-instantclient*.rpm
RUN unzip instantclient-basiclite-linux.x64-21.7.0.0.0dbru.zip
RUN echo /home/app/instantclient_21_7 > /etc/ld.so.conf.d/oracle-instantclient.conf
RUN ldconfig
RUN npm rm -rf node_modules &&\
npm install
CMD ["npm", "run", "dev"]
I get the following error when I try to run the connection file
(node:256) UnhandledPromiseRejectionWarning: Error: ORA-12154: TNS:could not resolve the connect identifier specified
(Use `node --trace-warnings ...` to show where the warning was created)
(node:256) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:256) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The connection file looks like this
const conn = {
user: "user",
password: "pass",
connectionString:"host:port/service_name",
};
try {
console.log("Here in DTO");
var connection = oracledb.getConnection(conn);
console.log("***** Connected to Oracle DB *****");
} catch (err) {
console.log(err);
}