From 18ef2e19861440a4d1c899c61268882a6cf2798c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 1 Sep 2022 09:33:53 +0200 Subject: [PATCH] fix(docker): revert docker `USER` and `WORKDIR` changes Switching from `root` to another user needs a bit more testing, as we need to figure out how to auto-migrate all existing instances of n8n when people upgrade. --- docker/images/n8n/Dockerfile | 12 +++++------- docker/images/n8n/docker-entrypoint.sh | 13 +++++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docker/images/n8n/Dockerfile b/docker/images/n8n/Dockerfile index 99044a067ec98..b899a5f7f1d3d 100644 --- a/docker/images/n8n/Dockerfile +++ b/docker/images/n8n/Dockerfile @@ -17,10 +17,8 @@ RUN set -eux; \ find /usr/local/lib/node_modules/n8n -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" | xargs rm && \ rm -rf /root/.npm -RUN \ - mkdir .n8n && \ - chown node:node .n8n && \ - ln -s /docker-entrypoint.sh /home/node/docker-entrypoint.sh -USER node -COPY docker-entrypoint.sh ./ -ENTRYPOINT ["tini", "--", "./docker-entrypoint.sh"] +# Set a custom user to not have n8n run as root +USER root +WORKDIR /data +COPY docker-entrypoint.sh /docker-entrypoint.sh +ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"] diff --git a/docker/images/n8n/docker-entrypoint.sh b/docker/images/n8n/docker-entrypoint.sh index 57811eb0ab553..74dbdceaaf32d 100755 --- a/docker/images/n8n/docker-entrypoint.sh +++ b/docker/images/n8n/docker-entrypoint.sh @@ -1,8 +1,17 @@ #!/bin/sh + +if [ -d /root/.n8n ] ; then + chmod o+rx /root + chown -R node /root/.n8n + ln -s /root/.n8n /home/node/ +fi + +chown -R node /home/node + if [ "$#" -gt 0 ]; then # Got started with arguments - exec node "$@" + exec su-exec node "$@" else # Got started without arguments - exec n8n + exec su-exec n8n fi