abernix/meteord

Node inside node-12-base container has wrong timezone

Opened this issue · 2 comments

I am in the CET timezone, which means that new Date().getTimezoneOffset() should return -60 at the moment. However it returns 0. As a result, all timestamps saved as UTC in my meteor app are wrong.

Is there some breaking change I have missed? Is there a way to configure the timezone for node or meteor inside the node-12-base docker container?

~$ date
Thu Feb 20 16:10:00 CET 2020
~$ docker exec -it meteor bash
root@ meteor:/# date
Thu Feb 20 16:10:09 CET 2020
root@ meteor:/# node
Welcome to Node.js v12.14.0.
Type ".help" for more information.
> t = new Date()
2020-02-20T15:10:23.155Z
> t.getTimezoneOffset()
0

I found the solution already.

If you're working with meteor-up (mup)

Before I linked the/etc/localtime file in mup.js:

 volumes: {
      // passed as '-v /host/path:/container/path' to the docker run command
      '/mnt/appdata/files': '/datafiles',
      '/etc/timezone': '/etc/timezone',
      '/etc/localtime': '/etc/localtime'
},

Now we have to set a environment variable TZ:

 env: {
      // If you are using ssl, it needs to start with https://
      ROOT_URL: ,
      MONGO_URL:
      PORT: 3000,
      NODE_OPTIONS: '--max-old-space-size=512',
      TZ: 'Europe/Amsterdam'
},

It will work perfectly if we did a change in file:

meteord/base/scripts/lib/cleanup.sh

by not to remove /usr/share/zoneinfo from the base container.

From
rm -rf /usr/share/doc /usr/share/doc-base /usr/share/man /usr/share/locale /usr/share/zoneinfo

To
rm -rf /usr/share/doc /usr/share/doc-base /usr/share/man /usr/share/locale

With this solution, we can use the TZ environment variable to set the container timezone without mapping host's timezone and localtime files.