Docker file for building image locally

Does the repo contain the Dockerfile to build a local version of n8n? The Dockerfile available here is just installing original n8n from the npm repo.

What if we want to build n8n locally for testing and/or modifying something. Where is the actual Docker file that can be used to build an image locally.

Is it possible to get that file?

Actually, there should no special dockerfile as that needed. If you develop with Node.js you probably already have it either installed locally or if not, you have your own development dockerfile where Node.js is running inside. No matter what setup you have n8n will run there fine. Simply make sure you have at least Node.js version 10+ and follow the guide here:

If you really have neither you can simply create something very basic. Simple ubuntu base, add node.js and some other things like git, python and other stuff that could be handy and thats it. You can then simply mount in the folder where you have n8n checked out and then run n8n inside of there.

Here an example:

FROM ubuntu:18.04

USER root

# Update everything and install curl
RUN \
  apt-get update && \
  apt-get -y upgrade && \
  apt-get -y install \
  build-essential \
  curl \
  git-core \
  python \
  vim \
  wget \
  graphicsmagick

RUN wget https://nodejs.org/dist/v12.14.1/node-v12.14.1-linux-x64.tar.xz
RUN tar -C /usr/local --strip-components 1 -xJf node-v12.14.1-linux-x64.tar.xz

# Update latest npm version
RUN npm install -g npm

RUN \
  export USER=root && \
  npm install --unsafe-perm --global \
  gulp \
  @vue/cli

# The directory in which the data will be mounted we want to work with
WORKDIR /data

CMD "bash"

Hope that helps!

Thanks for the quick reply

I have gone through the guide in detail but I dont think it has anything to do with my question.

I dont think I understood what you meant by “there should be no special dockerfile as that needed”. Why not? If I am editing something inside n8n and adding a new module and want to publish this container with my changes, I will need a docker file that builds the local code rather than pulling the vanilla n8n from npm.

As for the 2nd example you gave, this wont build local changes in n8n.

In my view, the Dockerfile that is committed into the repo at path “https://github.com/n8n-io/n8n/blob/master/docker/images/n8n/Dockerfile” should be a real Dockerfile that creates the image from the local content rather than pulling the npm version from n8n. Thats a standard way of publishing packaging as part of the repo.

How do you and/or other contributors test their changes as part of a container setup. You will have some Dockerfile…Right?

I thought your question was more or less: “How do I build n8n locally for testing/modifying with docker?”

And my answer is that you do not need Docker to build n8n as n8n is a regular Node.js application. There is no need for Docker at all. Sure you can run it in Docker if you want (like I do) but you can also just run it directly on your computer without Docker as most people do.

If you want to modify n8n and release your own Docker image you would either have to publish all of the n8n npm modules you made changes to, to npm and then reference these new modules in your package.json file. Or you would have to link everything with lerna like in the CONTRIBUTING.md file described (probably easier) and then publish that.

The second example I gave you is an example Dockerfile which runs Node.js and in which you can run n8n. It is meant for development. Again you would have to then mount the n8n-folder and follow the CONTRIBUTING.md guide.

Never heard about real and unreal Dockerfiles. But if only one that links and builds all the modules and is then deployable like that is real, then there is currently sadly only the unreal one. You are however very welcome to create also the “real” one and open a pull-request. I am sure some people would find it useful.

About how other contributors do it. They either have Node.js installed locally or they use a Dockerfile similar to the one I did post and follow what is written in the CONTRIBUTING.md file.

I cooked up something in a short amount of time . The core of it can look something like this. Please see that this is not very optimized at this point but will build a deployable docker image from local changes.

FROM node:12.13.0-alpine as n8n-build

N8N_VERSION

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

# Update everything and install needed dependencies
RUN apk add --update graphicsmagick tzdata git

# # Set a custom user to not have n8n run as root
USER root

# Install n8n and the also temporary all the packages
# it needs to build it correctly.
RUN apk --update add --virtual build-dependencies python build-base ca-certificates

RUN npm i lerna -g --loglevel notice

WORKDIR /data

COPY package.json .
RUN npm install --loglevel notice

COPY packages/cli/ ./packages/cli/
COPY packages/core/ ./packages/core/
COPY packages/editor-ui/ ./packages/editor-ui/
COPY packages/nodes-base/ ./packages/nodes-base/
COPY packages/workflow/ ./packages/workflow/



COPY lerna.json .
RUN lerna bootstrap --hoist

RUN npm run build

So what I was saying about a “real” Dockerfile was that this file above will build the project container from the source code rather than relying on npm to fetch the vanilla n8n package. And such a file should be made part of the repo. I will be happy to raise this as a PR if you think this is ok.

Without having tested it, looks ok at first sight.

But you can then remove the “N8N_VERSION” related code as it does not get used anymore anyway.

To actually start n8n you would have to add that it runs: /usr/local/bin/node bin/n8n start

Sure if you tested it and everything is running fine would love a PR. The docker-image which will get pushed to docker hub will for sure still keep on using the other one as I want to make sure that npm modules and docker hub stay in sync but it will be helpful for other cases.

Created now an official Dockerfile to create a docker image with the local code.

It can be found here: