ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

Working outside container but facing licensing issue when running on docker #890

Closed reenanfs closed 1 year ago

reenanfs commented 1 year ago

I have a query api that runs correctly on localhost on Windows, but when trying to run on docker container I am facing the following licensing problem:

[IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968

It's important to note that I already have the licensing file that works fine outside the container named db2consv_ee.lic, which is found on ibm_db folder on root project folder along with linuxx64_odbc_cli.tar.gz file, as seen in the picture below:

image

When running the project, on server.js, one of the first things it does is to send the licensing file to the correct location on node_modules, as seen in the picture below:

image

In my Dockerfile I am pointing the IBM_DB_INSTALLER_URL env variable to the ibm_db folder where the linuxx64_odbc_cli.tar.gz file is located :

# Base image
FROM node:16

# Create app directory
WORKDIR /app

# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

# Install ibm_db dependencies
RUN apt-get update && apt-get install -y apt-transport-https make g++ python-pip
RUN pip install --no-cache --upgrade pip setuptools 
ENV IBM_DB_INSTALLER /app/ibm_db

# Install app dependencies
RUN npm install --unsafe-perm ibm_db

# Bundle app source
COPY ./ ./

# Run the server in production mode
CMD ["npm", "start"]

This Dockerfile compiles normally and I believe the version of the license, db2 and linuxx64_odbc_cli.tar files are the correct ones, since when I run the project outside docker it's working correctly. I am only getting the error I mentioned above on runtime when calling the api and querying the database when the api is running inside the container.

Can this be considered a bug or am I doing something wrong? Thanks

reenanfs commented 1 year ago

I found out what was the issue already... I had I typo on the ENV variable: "IBM_DB_INSTALLER" instead of "IBM_DB_INSTALLER_URL"... On top of that, I was not copying the ibm_db folder to the container at the time of the npm install.

Find below working Dockerfile if it can help anyone:

# Base image
FROM node:14.17.5

# Create app directory
WORKDIR /app

# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

# Install ibm_db dependencies
RUN apt-get update && apt-get install -y apt-transport-https make gcc g++ python-pip
RUN pip install --no-cache --upgrade pip setuptools 
RUN mkdir /ibm_db
COPY ./ibm_db ./ibm_db
ENV IBM_DB_INSTALLER_URL /app/ibm_db

# Install project dependencies
RUN npm install --unsafe-perm ibm_db

# Bundle app source
COPY ./ ./

# Run the server in production mode
CMD ["npm", "start"]