I am getting back to working with n8n and I really have fun doing so. My problem is I have very limited Docker experience. I managed to get my container running and it is proxied with NGINX to serve via HTTPS.
I am getting to more complex use cases. A lot of my use cases involve XML processing. Back in November 2019 I allready opened this topic: XSLT/XSD processor or command line tool
Now I want to dig deeper into this. I would like to have some more command line tools available inside of the docker container. For example I would like to have xmllint so that I can lint/validate incoming XML against it. Also some XSLT processing would be good so that I can use one XML file and anXSLT translation file to map it to something different. Right now I use the Set Node for this and well it get’s the job done. But XSLT is much more portable than javascript dot notation object manipulation.
So my question is: how can I put external tools into my docker image. I use this very minimal docker-compose.yml to serve the container and make it work with the nginx reverse proxy:
Is it possible to use a docker-compose.yml or something to tell the image to apt-get install some packages? I then could use those via the Execute Command node.
Or is it possible to add npm packages to the image? so I can require them in a funciton node?
@vuchl Hi, i recently figured this out as well, how to use external npm packages, with help from @jan.
This is how i implement it now:
1.Create Dockerfile in the same folder as your docker-compose.yml
Dockerfile content:
FROM n8nio/n8n
RUN npm install -g he
RUN npm install -g uuid
RUN npm install -g object-deep-compare
RUN npm install -g validator
RUN npm install -g gm
RUN npm install -g node-qpdf
RUN npm install -g dayjs
RUN npm install -g generate-unique-id
2.Build the docker image with this command:
docker build -t n8np .
^ ‘n8np’ is a chosen name…could be anything. Don’t forget the ’ . ’ at the end (i did).
it works now.
But I didn’t manage to put everything in the Dockerfile.
As soon as the Container is up and running I could enter it then added python, make and g++ with separate commands
apk add python
apk add make
apk add g++
and then i could install the suitecrm node with this command:
UPDATE:
I still can’t put it in the Dockerfile. It gives me the Warning:
npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
therefore it can be installed and the module appears in n8n but I can’t do anything with it.
It doesn’t fetch or send something.
So I digged deeper to find the problem.
It seems that without the package.json file it doesn’t get the permissions or something to work.
How can I get the package.json file also into the Container?
Does someone know what to do here?
I don’t think I am the only person with this sort of problem. Aren’t there a lot of custom nodes with similar dependencies and needs?
Now it works. I needed to install peer dependencies on my own. So I added this to the end of the Dockerfile as well. The build works without errors.
This is what my dockerfile looks like now:
FROM n8nio/n8n
RUN apk --update add python
RUN apk --update add make
RUN apk --update add g++
RUN npm install -g n8n-nodes-suitecrm --unsafe
RUN npm install -g install-peerdeps