n8n-io / n8n-nodes-starter

Example starter module for custom n8n nodes.
MIT License
190 stars 128 forks source link

I can't make any custom nodes show up in my docker environment #47

Closed indierodo closed 3 months ago

indierodo commented 3 months ago

For the life of me, I've been struggling with this for days. I have tried every method described in the docs, and apparently something is happening but neither the starter or the custom node from npm appear.

I'll attach my dockerfile below. Please, if you need more information, let me know.

Thank you for your help.

FROM n8nio/base:18

USER root
COPY docker-entrypoint.sh /

ENV N8N_VERSION=1.30.1
ENV N8N_RELEASE_TYPE=stable
ENV NODE_ENV=production
RUN npm install -g --omit=dev n8n@${N8N_VERSION} --ignore-scripts && \
    npm rebuild --prefix=/usr/local/lib/node_modules/n8n sqlite3

# This is the n8n-nodes-starter, only modified the name in package.json
ADD n8n-nodes-pubsubtrigger n8n-nodes-pubsubtrigger

# Installing in /usr/local/lib/node_modules/n8n does not work. Installing in /root/.n8n/custom does not work. Running n8n as node and installing in /home/node/.n8n/custom does not work either.
RUN cd n8n-nodes-pubsubtrigger && \
        npm install --include=dev && \
    npm link && \
    cd /usr/local/lib/node_modules/n8n && \
    npm install n8n-nodes-python@0.1.4 && \
    npm link n8n-nodes-pubsubtrigger && \
    # rm -rf /usr/local/lib/node_modules/n8n/node_modules/@n8n/chat && \
    # rm -rf /usr/local/lib/node_modules/n8n/node_modules/n8n-design-system && \
    # rm -rf /usr/local/lib/node_modules/n8n/node_modules/n8n-editor-ui/node_modules && \
    # find /usr/local/lib/node_modules/n8n -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" | xargs rm -f && \
    # rm -rf /root/.npm && \
    mkdir -p /root/.n8n/custom && \
    cd /root/.n8n/custom && \
    npm install n8n-nodes-python@0.1.4 && \
    npm link n8n-nodes-pubsubtrigger

RUN chmod +x /docker-entrypoint.sh

ENV SHELL /bin/sh

ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
EXPOSE 5678/tcp
Joffcom commented 3 months ago

@indierodo are you planning to publish your nodes to npm or using your own custom image?

Your example is using the /root path which we stopped using as we should use the node user now so your nodes should be going into /home/node/.n8n/custom

indierodo commented 3 months ago

I tried a lot more stuff. It does not work.

USER: node FOLDER: /home/node/.n8n/custom

Does n8n work differently in production?

Here's the last Dockerfile:

ARG NODE_VERSION=18
FROM n8nio/base:${NODE_VERSION}

ARG N8N_VERSION=1.30.1
RUN if [ -z "$N8N_VERSION" ] ; then echo "The N8N_VERSION argument is missing!" ; exit 1; fi

ENV N8N_VERSION=${N8N_VERSION}
ENV NODE_ENV=production
ENV N8N_RELEASE_TYPE=stable
RUN set -eux; \
    npm install -g --omit=dev n8n@${N8N_VERSION} -- && \
    npm rebuild --prefix=/usr/local/lib/node_modules/n8n sqlite3 

COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

ADD n8n-nodes-pubsubtrigger /home/node/n8n-nodes-pubsubtrigger
RUN cd /home/node/n8n-nodes-pubsubtrigger && \
    npm install --include=dev && \
    npm run build && \
    npm link

RUN chown -R node:node /home/node

ENV SHELL /bin/sh

USER node
RUN mkdir -p /home/node/.n8n/custom && \
    cd /home/node/.n8n/custom && \
    npm init -y && \
    npm link n8n-nodes-pubsubtrigger

ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
Joffcom commented 3 months ago

Hey @indierodo

I guess the first thing to do is try and understand what you are actually trying to do.

Are you making a docker image to try testing your node or is this so you can deploy your node to your production environment without publishing to npm?

When your container starts does it show any errors and have you cleared the browser cache to rule out anything there?

indierodo commented 3 months ago

Hi, thank you very much for your time and support.

I am trying to create a custom docker image with our private node n8n-nodes-pubsubtrigger and the n8n-nodes-python node preinstalled so I can deploy n8n in a Kubernetes environment.

Just now, I was able to pinpoint what happened:

The node was not linking properly, I was getting the 'runtime-blob-types' error referenced in issue #43

I worked around #43 by using npm install on the "nodes" folder instead of "custom" folder.

Finally, I did not clear the browser cache, this issue n8n-io/n8n#9536 helped me (sorry about not noticing earlier).