diff --git a/docker/images/n8n-custom/Dockerfile b/docker/images/n8n-custom/Dockerfile new file mode 100644 index 0000000000..f4e4af4ed7 --- /dev/null +++ b/docker/images/n8n-custom/Dockerfile @@ -0,0 +1,44 @@ +# 1. Create an image to build n8n +FROM node:12.16-alpine as builder + +# Update everything and install needed dependencies +USER root + +# Install all needed dependencies +RUN apk --update add --virtual build-dependencies python build-base ca-certificates && \ + npm_config_user=root npm install -g lerna + +WORKDIR /data + +COPY lerna.json . +COPY package.json . +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/ +RUN rm -rf node_modules packages/*/node_modules packages/*/dist + +RUN npm install --production --loglevel notice +RUN lerna bootstrap --hoist -- --production +RUN npm run build + + +# 2. Start with a new clean image with just the code that is needed to run n8n +FROM node:12.16-alpine + +USER root + +RUN apk add --update graphicsmagick tzdata tini su-exec + +WORKDIR /data + +# Install all needed dependencies +RUN npm_config_user=root npm install -g full-icu + +ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu + +COPY --from=builder /data ./ + +COPY docker/images/n8n-custom/docker-entrypoint.sh /docker-entrypoint.sh +ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"] diff --git a/docker/images/n8n-custom/README.md b/docker/images/n8n-custom/README.md new file mode 100644 index 0000000000..fcd06d18a3 --- /dev/null +++ b/docker/images/n8n-custom/README.md @@ -0,0 +1,12 @@ +# n8n - Custom Image + +Dockerfile which allows to package up the local n8n code into +a docker image. + + +## Usage + +Execute the following in the n8n root folder: +```bash +docker build -t n8n-custom -f docker/images/n8n-custom/Dockerfile . +``` diff --git a/docker/images/n8n-custom/docker-entrypoint.sh b/docker/images/n8n-custom/docker-entrypoint.sh new file mode 100755 index 0000000000..2c9c35eb48 --- /dev/null +++ b/docker/images/n8n-custom/docker-entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +if [ -d /root/.n8n ] ; then + chmod o+rx /root + chown -R node /root/.n8n + ln -s /root/.n8n /home/node/ +fi + +if [ "$#" -gt 0 ]; then + # Got started with arguments + shift + exec su-exec node ./packages/cli/bin/n8n "$@" +else + # Got started without arguments + exec su-exec node ./packages/cli/bin/n8n +fi