How to pass environmental variable for Node.js in Docker instance

Hello.
I’m struggling with installation of the OpenCV into the Docker-compose instance of n8n.

As far as I understood I need to install openCV first inside the Linux using apk and then install a Nodes.js module via npm. So far my dockerfile looks like this:

ARG tag=latest
FROM n8nio/n8n:$tag
RUN apk --update add curl curl-dev libcurl linux-headers opencv
RUN npm install -g opencv

The problem with this setup comes from here:

There is a version check for opencv. I have ver. 4 and need to pass PKG_CONFIG_OPENCV4=1 into npm (not Docker). Can I just change something in RUN npm install command?

I found that there is a .npmrc file or a preinstall script. But I have very little idea where to put them since the whole stuff is in Docker. Do I need to RUN some other commands before RUN npm install?

Thanks a lot in advance.

Hey @Ed_P,

I am not sure this is really a question for us as it doesn’t appear to be related to n8n directly. The comment above what you have seems to suggest it is just a case of using RUN export PKG_CONFIG_OPENCV3=1 | npm install -g opencv.