invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
418 stars 268 forks source link

[Feature request] Set correct timezone by dockerfile #622

Closed n1smithy closed 1 month ago

n1smithy commented 1 month ago

Hi@ all.

It seems that the timezone within the containers are always UTC. If there's not yet a setting for this, I would invite to read this quote:

The secret here is that dpkg-reconfigure tzdata simply creates /etc/localtime as a copy, hardlink or symlink (a symlink is preferred) to a file in /usr/share/zoneinfo. So it is possible to do this entirely from your Dockerfile. Consider:

ENV TZ=America/Los_Angeles RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

And as a bonus, TZ will be set correctly in the container as well.

This is also distribution-agnostic, so it works with pretty much any Linux.

Note: if you are using an alpine based image you have to install the tzdata first. (see this issue here)

Looks like this:

RUN apk add --no-cache tzdata ENV TZ America/Los_Angeles

So one can set the correct time-zone by passing the right environment-variable.

Thanks for reading.

turbo124 commented 1 month ago

The application always requires the server to be set to UTC +0

The application itself converts as needed to the localization you choose in the application

n1smithy commented 1 month ago

@turbo124 Just one thing to think about it: If the servers, which stand usually somewhere else but in a UTC-timezone, use only UTC the internal dates are wrong just because there's software needing UTC? Wouldn't it be wise to compense this issue within the softwares which need UTC? They already have to compensate UTC to local time, why not otherwise and have a complete consistent state?

EDIT: I'm going to try something. Maybe I found a workaround for the log-date-problem.