Fix Timezone Handling for Containers#375
Conversation
Add timezone setting option to template.env
- Add timezone environment variable to all services - Setting Default to "UTC"
- Add timezone configuration for PHP in docker-compose file. - Replace PHP timezone in misp-core with the new config-file tzone.ini Perhaps there are better solutions for changing the time zone from PHP during runtime.
docker-compose.yml
Outdated
| retries: 3 | ||
| start_period: 10s | ||
|
|
||
| configs: |
There was a problem hiding this comment.
Could you move this to a separate file and edit Dockerfile to COPY it at build time and run sed in there (like we do with the PHP files?
Your solution is much cleaner, but not everybody is using docker-compose.yml.
There was a problem hiding this comment.
In fact, I had primarily focused on the fact that when using docker-compose.yml, you have the option of setting the time zone everywhere. And as far as I can see, configs: must therefore remain in docker-compose.yml for the PHP-Settings.
As far as I can see, for the build-time is the timezone setting via ${PHP_TIMEZONE}.
misp-docker/core/files/entrypoint_fpm.sh
Line 50 in b12a20c
Therefore, in my opinion, no additional file would be necessary.
However, this variable has no effect on a finished image via
docker-Compose.yml.
I could imagine that you could ensure that either ${PHP_TIMEZONE} or ${TZ:-UTC} is used. This means you only have to set it once in .env in example like this
sed -i "s/;?date.timezone = .*/date.timezone = ${PHP_TIMEZONE:-${TZ:-UTC}}/" "$FILE"
And probably here
Line 116 in b12a20c
would be better
ENV TZ= ${TZ:-UTC}.
What do you think about it @ostefano ?
Updated PHP timezone configuration and added symlink for timezone for supervisord.
sed dosen´t use "?" so PHP_TIMEZONE was setting in php.ini
PHP_TIMEZONE wasn`t in template.env and so most not in use. TZ Variable the global Timezone variable in this Project
Removed timezone configuration from docker-compose. With the "sed fix" in the entrypoint_fpm.sh, No need to mount a separate file now
|
@ostefano |
Updated timezone setting method for supervisord compatibility with debian standard methode
ostefano
left a comment
There was a problem hiding this comment.
Sometimes we use ${TZ:UTC} and sometimes ${TZ:-UTC}, why?
Do we still need the PHP_TIMEZONE var, can't we just use TZ?
add `-` so default (UTC) is in use, if TZ is not in use
PHP_timezone isn`t in use TZ exist
CET or CEST not useable timezone in /usr/share/zoneinfo/
|
The missing Now everything should be fine, in my opinion. |
core/files/entrypoint.sh
Outdated
| export SUPERVISOR_PASSWORD=${SUPERVISOR_PASSWORD:-supervisor} | ||
|
|
||
| # Setting Timezone for supervisord | ||
| update-alternatives --install /etc/localtime localtime /usr/share/zoneinfo/${TZ:-UTC} 0 |
There was a problem hiding this comment.
Why do we always load the var with a fallback value, if we do it just a few lines above?
Maybe 107/109 should use a non-interpolated TZ var?
There was a problem hiding this comment.
Yes, you're right. That shouldn't and mustn't be the case here. I'll change it. Thanks for pointing that out.
There was a problem hiding this comment.
I also took another look at the other files. However, the fallback is necessary again in the compose file.
There was a problem hiding this comment.
That makes sense. My concern was limited to this instance only.
Remove default value for TZ when setting timezone.
This PR standardizes timezone handling across all MISP Docker containers.
The timezone can now be set optionally via the
TZenvironment variable.If defined, it is applied globally and consistently across all containers and all processes, including system services, supervisord, background jobs, logs, and the MISP web interface.
If
TZis not set, the default remainsUTC.Changes
UTCBenefits
Best Regards from Bayern-CERT