julianhille / MuhammaraJS

Muhammara a node module with c/cpp bindings to modify PDF with js for node or electron (based/replacement on/of galkhana/hummusjs)
Other
205 stars 43 forks source link

`GLIBC_2.29' not found` Nodejs app is run on docker #333

Closed EmmanDizon closed 9 months ago

EmmanDizon commented 9 months ago

encountered an error when running on docker:

node:internal/modules/cjs/loader:1282
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /app/node_modules/muhammara/binding/muhammara.node)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1282:18)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/app/node_modules/muhammara/lib/muhammara.js:6:35)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12) {
  code: 'ERR_DLOPEN_FAILED'
}
EmmanDizon commented 9 months ago

My current dockerfile:

# Use an official Node.js 16 runtime as the base image
FROM ubuntu:20.04

# Install dependencies
RUN apt-get update && \
    apt-get install -y wget gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
    libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
    libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 \
    libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
    libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 \
    lsb-release xdg-utils

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json to the container
COPY package*.json ./

# Install the app dependencies
RUN npm install

# Copy the rest of the application code to the container
COPY ./src ./src

# Set the non-root user for running the application
USER node

# Expose the port on which your application runs
EXPOSE 3000

# Specify the command to run your application
CMD [ "node", "src/index.js" ]
julianhille commented 9 months ago

try a newer version of muhammara please

EmmanDizon commented 9 months ago

@julianhille, I'm using "muhammara": "^4.0.0",

Now you said i tried a newer version, i uninstalled it and then run npm i muhammara again to get the latest version now i get the same version of 4.0.0

julianhille commented 9 months ago

Please provide uname -ar and ldd --version output

EmmanDizon commented 9 months ago

i dont get what you literally mean, can you type exactly what you mean? you said i need to install new version of muhamara , i just did but i get same result of 4.0

npm i muhamara

@julianhille please help

EmmanDizon commented 9 months ago

btw, im deploying it on AWS, deploy image on ECR and run by a kubernetes EKS

kun101 commented 9 months ago

Facing the same issue, deploying on Google App Engine

EmmanDizon commented 9 months ago

help us please

kun101 commented 9 months ago

Hi @EmmanDizon with NodeJS v16, use Muhammara v3.8.0 that's what worked for me. Muhammara v4.0.0 seems to be working with NodeJS v18 and above.

julianhille commented 9 months ago

Please provide uname -ar and ldd --version output

You should type that on the machine running muhammara. It seems like the ec2 / lambda tells its ubuntu 20.04 but it's not at least not from glibc perspective.

Long story: Linux comes with a specific glibc version. This version can not be up or downgraded. Newer versions (ex. glibc 2.31) are backwards compatible to older ones (ex. 2.29) That said: ubuntu 18.04 comes normally with an glibc 2.27 and so is not compatible to 2.29. Ubuntu 20.04 comes with 2.31 and so should be backwards compatible to 2.29. Github as deprecated ubuntu machines 18.04 as action runner in april this year and that stopped me from releasing any new versions. At least pre-builts for 18.04.

That is why i introduced 4.0 as this is a breaking change for all older linux versions (cause it compiles with newer glibc [2.29]). From 4.0 on the pre built binaries are compiling on an ubuntu 20.04 runner.

So you have three options here:

  1. downgrade to any 3.x version as this comes with older glibc versions
  2. compile it yourself on a system wit glibc
  3. upgrade the host system

Btw. Muhammara v4 works from "node >=15" as long as you have the correct or newer glibc version.

There was no other option for me then to upgrade as i have no machines which could be used as runner to compile it.

Does that clarify a bit?

david-robinson-practiceweb commented 9 months ago

In case it helps anyone else, had a similar issue to the OP when installing 4.0 on amazonlinux 2. AL2 only has glibc2.26 so hits the same 2.29 error. AmazonLinux 2023 seems to be fine ( they use 2.34)

julianhille commented 9 months ago

Thanks for reporting.

julianhille commented 9 months ago

There is little, from muhammara perspective, i can do. So if anything changes, feel free to reopen.