I have set up a custom node and I’m now trying to deploy into a docker container I have, but first I’m setting up locally to see if everything works just fine. Locally, via n8n start, using npm, everything works just fine and I’ve been able to develop my action nodes quite well for the past few months. But after replicating the folders and copying everything into my container, I’m
still not being able to find my node.
There aren’t any errors as I am able to build and run docker compose up with success and then access n8n on my browser.
Dockerfile
ARG N8N_VERSION=1.47.3
RUN apk add --no-cache python3 py3-pip \
&& apk add --no-cache graphicsmagick tzdata git tini su-exec \
&& apk add --update --virtual build-dependencies python3 build-base ca-certificates \
&& npm install -g full-icu n8n@$N8N_VERSION \
&& apk del build-dependencies \
&& rm -rf /root /tmp/* /var/cache/apk/* \
&& mkdir /root
ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu
WORKDIR /home/.n8n/custom/n8n-node
EXPOSE 5678
COPY . .
WORKDIR /home/.n8n/custom/n8n-node/nodes/mynode
RUN npm link
WORKDIR /home/.n8n/custom/n8n-node
RUN npm link custom-n8n-node
RUN npm install \
#&& npm i --dev [email protected] @types/[email protected] @types/[email protected] gulp @types/tmp @types/express n8n-workflow n8n-core gulp-typescript @types/jest \
&& npm run build
CMD ["n8n", "start"]```
FROM node:20-alpine
ARG N8N_VERSION=1.47.3
RUN apk add --no-cache python3 py3-pip \
&& apk add --no-cache graphicsmagick tzdata git tini su-exec \
&& apk add --update --virtual build-dependencies python3 build-base ca-certificates \
&& npm install -g full-icu n8n@$N8N_VERSION \
&& apk del build-dependencies \
&& rm -rf /root /tmp/* /var/cache/apk/* \
&& mkdir /root
ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu
WORKDIR /home/.n8n/custom/unbabel-n8n-node
EXPOSE 5678
COPY . .
WORKDIR /home/.n8n/custom/unbabel-n8n-node/nodes/unbabel
# Create a local symlink for the custom node package
RUN npm link
WORKDIR /home/.n8n/custom/unbabel-n8n-node
RUN npm link n8n-nodes-unbabel
RUN npm install \
#&& npm i --dev [email protected] @types/[email protected] @types/[email protected] gulp @types/tmp @types/express n8n-workflow n8n-core gulp-typescript @types/jest \
&& npm run build
CMD ["n8n", "start"]
docker-compose.yml
version: "3.9"
x-env: &environment
environment:
N8N_TEMPLATES_ENABLED: "false"
# Basic auth credentials
N8N_ENCRYPTION_KEY: "s4p3rs3cr3t"
GENERIC_TIMEZONE: "Europe/Lisbon"
NODE_ENV: "development"
# List of external modules
NODE_FUNCTION_ALLOW_EXTERNAL: "axios,jwt-decode,tempy,tmp,dotenv,gulp,n8n,n8n-core,n8n-workflow"
# Increase node max memory
NODE_OPTIONS: "--max_old_space_size=1024"
# Set n8n to work as single thread instead of forking to worker threads
EXECUTIONS_PROCESS: "main"
services:
app:
<<: *environment
build: .
volumes:
- .:/home/node/.n8n/custom
ports:
- "5678:5678"
command: n8n start
n8n version: N8N 1.47.3 (same I am running locally)
Running Via - Docker compose on MACOS (M2)
I don’t have a DB
I’m thinking the problem is with where I’m copying the files into my image.
Have you attempted to install your link package globally?
RUN npm install -g link
Here’s an example of my Dockerfile:
FROM n8nio/n8n:latest
WORKDIR /data
USER root
# Install Python and pip
RUN apk add --no-cache libzbar python3 py3-pip libmagic poppler-utils && \
apk upgrade py3-pip
# Add your NodeJS packages here - make sure you install them globally (-g)
RUN npm install -g link
hey @Flavio_Orfano unfortunately those solutions won’t work. In my image I am copying the file into home/node/.n8n as you can see in my dockerfile, however it won’t show the node.
let me know if you have any other resources I could use.
FROM n8nio/n8n:latest
WORKDIR /data
USER root
# Install Python and pip
RUN apk add --no-cache libzbar python3 py3-pip libmagic poppler-utils && \
apk upgrade py3-pip
# Add your NodeJS packages here - make sure you install them globally (-g)
RUN npm install -g ldapjs zxcvbn [email protected] ip akamai-edgegrid xmlrpc
And then I’m building this image with:
docker build -t n8n-python .
Just a clarification: the npm packages installed with RUN npm install won’t appear in n8n as nodes, but you can use them in your code nodes.
For instance, here’s how I use the ldapjs package in a code node:
const ldap = require('ldapjs');
const client = ldap.createClient({
url: 'your_ldap_server'
});
rest of your code here
EDIT:
Oh, sorry, I might have read your question wrong. You’re asking about a custom node that you developed.
For that, I would ensure that the generated files (from your dist folder) are copied into the correct locations and that you’ve updated the package.json file to include your node and credential files.