How to bundle custom nodes in Docker-Container

Hello, i have written a custom node and want to bundle it in my docker container. I have found this topic: Installing custom nodes in Docker configuration

However i did copy the compiled module to the custom path as described in the other forum post.

// Deploy it to my local directory
npm run build && npm link
// Copy it to my docker directory
cp /opt/homebrew/lib/node_modules/n8n/n8n-nodes-shopware /my-docker/volume-mount/.n8n/custom

And this is my docker-compose configuration for the volume mount. I can see that the directory contains my custom node exactly like it does with my local deployment.

    volumes:
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n

However i can not find my custom module n8n-nodes-shopware. The only difference i can see is that a explicitly call npm link in my local environment. Do i have to explicitly load the custom module in my docker-setup, maybe extend the docker-entrypoint.sh-file?

Local:

npm link n8n-nodes-shopware && n8n start

Docker (docker-entrypoint.sh)

#!/bin/sh
if [ "$#" -gt 0 ]; then
  # Got started with arguments
  COMMAND=$1;

  if [[ "$COMMAND" == "n8n" ]]; then
    shift
    (cd packages/cli; exec node ./bin/n8n "$@")
  else
    exec node "$@"
  fi

else
# Got started without arguments
cd packages/cli; exec node ./bin/n8n
fi

Hm, in the past an npm install command in the Dockerfile would be the way to go. But tbh, I don’t know what the currently suggested “official” approach to this is.

Perhaps @marcus can take a look once he’s back next week?

What do you mean with npm install would be the way to go? Do you have an example of how this would be done with a custom module? I would take any solution which works.

I didn’t mean anything specify by it - it’s just how I have added npm modules in the past (adding the required npm install command to my Dockerfile) but our docker images have changed a lot since, so I am not sure if this is still applicable.

Have you tried out the approach described in our docs (this one: Install private nodes - n8n Documentation) and did you run into any trouble with this?

Hey @azngeek,
I just tried installing our n8n-nodes-starter into the .n8n/custom home directory and it worked. After running npm run build I copied the contents of the dist folder into .n8n/custom and restarted n8n.

My .n8n/custom folder looked like this.

I was able to add our example node from n8n-nodes-starter.

Did you try using the dist folder content after npm run build?

2 Likes

Hi @marcus, I would really like to get that working at my side too.

I tried to use the N8N_CUSTOM_EXTENSIONS environment variable and put in my local folder, which contain custom nodes. I tried with a folder type inside and outside the docker container but the nodes are not showing up.

I just add the environment variable and started the docker stack/container (running in queue mode).
Is there anything missing? How do I get the nodes working from the UI?