ReloadNodesAndCredentials for custom nodes development using docker compose and a mounted volume

Describe the problem/error/question

Hi! I’m setting up a custom nodes development environment + deployment using docker (for easy sharing across OSs). The only thing I’m missing for making it great, is having the ReloadNodesAndCredentials functionality that I’ve seen it’s skipped for the docker images and production build.

I see different approaches going forward, but I would like to have your thoughts:

First, I assume that it’s removed to prevent any code injection into the docker.

  • I can build my own n8n image from the source code, but it has the problem of building it and keeping it up to date with your images
  • Or, you can add it to docker and conditionally remove it in the based on a Environment variable flag that we can change to keep that functionality while developing but not in the prod image.

My idea is to use this to improve the PR I made a week ago to the template repo to smooth everything out, specially with the problem with symlinks, mounted docker volumes and non-root users (Previous post). This is what I have:


version: "3"

    image: redacted-repo/n8n-customized
    restart: unless-stopped
    user: "1000:1000"
      dockerfile: ./docker/Dockerfile
      context: .
      target: base
      - "5678:5678"
      - NODE_OPTIONS="--max-old-space-size=2048"
      - N8N_LOG_LEVEL=debug
      - N8N_DEV_RELOAD=true
      - n8n-data:/home/node/.n8n
      - .:/custom-nodes

    name: n8n-data
    external: true


echo Starting...
mkdir -p "${N8N_PATH}" && echo "Created folder ${N8N_PATH}"
cd "${N8N_PATH}" && echo "Moved to folder ${N8N_PATH}"
pnpm add file:/custom-nodes && echo "Linked custom nodes to ${N8N_PATH}"


Dockerfile (I need to install PNPM globally but in a non-root folder because the issues with symlinks I mentioned previously)

# Base image for the final layer. Written here for ease of configuration
FROM redacted-repo/n8n:latest AS base
ENV PNPM_HOME="/home/node/pnpm"

ENV NPM_PACKAGES="/home/node/.npm-packages"
RUN npm config set prefix "/home/node/.npm-packages"
RUN npm i npm@latest -g
RUN npm install -g pnpm rimraf

# Debug reasons
COPY --chown=node:node --chmod=755 ./docker/ /
ENTRYPOINT [ "tini", "--", "/" ]

FROM node:18-alpine AS base-build
RUN npm i npm@latest -g
RUN npm install -g pnpm rimraf

FROM base-build AS build
WORKDIR /build
COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prefer-offline
RUN pnpm run build

FROM base-build as prod-deps
COPY --from=build /build/dist/package.json .
COPY --from=build /build/pnpm-lock.yaml .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile --prefer-offline

# Final build, from n8n
FROM base as final

WORKDIR /custom-nodes
COPY --from=build --chown=node:node /build/dist ./dist
COPY --from=build --chown=node:node /build/dist/package.json .
COPY --from=build --chown=node:node /build/pnpm-lock.yaml .
COPY --from=prod-deps --chown=node:node /deps/node_modules ./node_modules
COPY --from=build --chown=node:node --chmod=755 /build/docker/ /

WORKDIR /installed-nodes
RUN pnpm config set node-linker hoisted
RUN pnpm config set symlink false
RUN pnpm add file:/custom-nodes
RUN pnpm install

ENTRYPOINT [ "tini", "--", "/" ]

That’s a tough one for me tbh, but perhaps @netroy as the resident expert on deployment topics can share his thoughts on this one?

Hey @edwinem,

I think the key here is in your first line…

I’m setting up a custom nodes development environment + deployment using docker

I don’t think it really matters how you set up your own development environment and to me either of your 2 options look like they will work so it would be up to you on which one you use but I would rather not introduce more complexity to the template repo if it is not needed.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.