Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node inside node-12-base container has wrong timezone #50

Open
ijager opened this issue Feb 20, 2020 · 2 comments
Open

Node inside node-12-base container has wrong timezone #50

ijager opened this issue Feb 20, 2020 · 2 comments

Comments

@ijager
Copy link

ijager commented Feb 20, 2020

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
@ijager
Copy link
Author

ijager commented Feb 20, 2020

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'
},

@tanutapi
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants