From de3859bbf63d00cff40a05e5eb47e8457f71f2f7 Mon Sep 17 00:00:00 2001 From: Alexandre Nizoux Date: Fri, 25 Oct 2019 08:34:42 +0200 Subject: [PATCH 1/5] Add container timezone handling Allows to change the timezone with the TZ env variable, useful for cron tasks and other things. --- docker/images/n8n/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/images/n8n/Dockerfile b/docker/images/n8n/Dockerfile index 3fc6f9505a..b6fff9155f 100644 --- a/docker/images/n8n/Dockerfile +++ b/docker/images/n8n/Dockerfile @@ -5,8 +5,9 @@ ARG 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 +RUN apk add --update --no-cache \ + graphicsmagick tzdata +ENV TZ Europe/Berlin # # Set a custom user to not have n8n run as root USER root From 8861cb17c8f8f16ad8e6786ae55a1fd7c3c26cdc Mon Sep 17 00:00:00 2001 From: Alexandre Nizoux Date: Sat, 26 Oct 2019 13:36:15 +0200 Subject: [PATCH 2/5] Added entrypoint Setting up TZ and GENERIC_TIMEZONE env vars required to use an entrypoint script --- docker/images/n8n/Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docker/images/n8n/Dockerfile b/docker/images/n8n/Dockerfile index b6fff9155f..94e2bfc8f5 100644 --- a/docker/images/n8n/Dockerfile +++ b/docker/images/n8n/Dockerfile @@ -5,9 +5,7 @@ ARG 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 --no-cache \ - graphicsmagick tzdata -ENV TZ Europe/Berlin +RUN apk add --update graphicsmagick tzdata # # Set a custom user to not have n8n run as root USER root @@ -20,4 +18,7 @@ RUN apk --update add --virtual build-dependencies python build-base && \ WORKDIR /data -CMD "n8n" +COPY docker-entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD ["n8n"] From cc97cc7b713f5ea2fa3f4f35ba4c7cf18588b63f Mon Sep 17 00:00:00 2001 From: Alexandre Nizoux Date: Sat, 26 Oct 2019 13:38:46 +0200 Subject: [PATCH 3/5] added docker-entrypoint.sh Just setting timezone for system tools (`date` and others) to match app timezone defined with GENERIC_TIMEZONE env var. --- docker/images/n8n/docker-entrypoint.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docker/images/n8n/docker-entrypoint.sh diff --git a/docker/images/n8n/docker-entrypoint.sh b/docker/images/n8n/docker-entrypoint.sh new file mode 100644 index 0000000000..0388b2f56d --- /dev/null +++ b/docker/images/n8n/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +ln -s /usr/share/zoneinfo/${GENERIC_TIMEZONE:-America/New_York} /etc/localtime + +exec "$@" From d7775aa8ede37c431f0793cae8c0071b0e839eac Mon Sep 17 00:00:00 2001 From: Alexandre Nizoux Date: Sat, 26 Oct 2019 13:42:22 +0200 Subject: [PATCH 4/5] Double quotes to calm code autoreview Should now pass green on code review :) --- docker/images/n8n/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/images/n8n/docker-entrypoint.sh b/docker/images/n8n/docker-entrypoint.sh index 0388b2f56d..fe4561efb1 100644 --- a/docker/images/n8n/docker-entrypoint.sh +++ b/docker/images/n8n/docker-entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/sh -ln -s /usr/share/zoneinfo/${GENERIC_TIMEZONE:-America/New_York} /etc/localtime +ln -s "/usr/share/zoneinfo/${GENERIC_TIMEZONE:-America/New_York}" /etc/localtime exec "$@" From 97ba03e8b41ebdfdb256decf1f66ebe4f68e1f7f Mon Sep 17 00:00:00 2001 From: Alexandre Nizoux Date: Sat, 26 Oct 2019 15:32:10 +0200 Subject: [PATCH 5/5] docker-entrypoint.sh MUST be executable for the container to start correctly --- docker/images/n8n/docker-entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 docker/images/n8n/docker-entrypoint.sh diff --git a/docker/images/n8n/docker-entrypoint.sh b/docker/images/n8n/docker-entrypoint.sh old mode 100644 new mode 100755