nextcloud / helm

A community maintained helm chart for deploying Nextcloud on Kubernetes.
GNU Affero General Public License v3.0
295 stars 258 forks source link

Feature: Setting for timezone in nextcloud-nginx container #494

Closed Tha-Fox closed 6 months ago

Tha-Fox commented 6 months ago

Description of the change

Currently I can set the timezone for nextcloud container via extraEnv and installing tzdata in postStartCommand. However, I can't find any similar setting for nextcloud-nginx container in the Helm chart. This leads to situation, where nextcloud container is two hours "ahead" compared to nextcloud-nginx container.

I think the most straightforward way to add this feature would be adding similar extraEnv for nextcloud-nginx as there already is for nextcloud container, but I've got to admit that I'm no expert when it comes to Helm charts.

Benefits

Troubleshooting is easier, when both containers have the same timezone.

Additional information

I'm currently running Nextcloud with this configuration:

image:
  repository: nextcloud
  tag: 27.1.4-fpm-alpine

lifecycle:
  postStartCommand:
    [
      "/bin/sh",
      "-c",
      "apk add tzdata",
      "&&",
      "crond",
    ]

nginx:
  ## You need to set an fpm version of the image for nextcloud if you want to use nginx!
  enabled: true
  image:
    repository: nginx
    tag: 1.21.6-alpine

I noticed that by default the timezone is UTC, but if I run manually export TZ=Europe/Helsinki inside nextcloud-nginx container, I get the correct time with date.

jessebot commented 6 months ago

For timezones in Kubernetes, it gets a bit complicated, but setting the TZ variable is definitely always the first step. Unfortunately, when it comes to nginx specifically, I haven't actually tried setting the timezone there, but personally, I use k8tz to inject timezones to the bulk of my k8s resources that need it. This also helps tackle things like cronjobs that are a bit harder to control in k8s.

Open to any other community members chatting about what they use as well :)

jessebot commented 6 months ago

Oh, sorry, missed that this was a feature request. :pray: If you'd like a feature in the nextcloud docker container specifically, you need to go to the upstream repo: nextcloud/docker. That repo has a separate set of maintainers.

jessebot commented 6 months ago

Sorry to ping you a third time @Tha-Fox but I found something in the nextcloud server docs!

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#default-timezone

Perhaps you can use this the above default_timezone parameter using the nextcloud.configs.myconfigfile.php feature?

This is untested, but perhaps something like this would be helpful?

nextcloud:
  configs:
    timezone.config.php: |-
      <?php
      $CONFIG = array (
        'default_timezone' => 'Europe/Berlin',
      );

Sorry, I've had covid for like a week now and my brain is slow, so I have to just ride any moment of clarity I have :sweat_smile: I apologize for all the confusion :pray:

@provokateurin do we want to provide a timezone feature in the helm chart to automatically set this? :)

provokateurin commented 6 months ago

I'd say the config.php way is enough :thinking: If the docker image provides an env variable then we should support that.

jessebot commented 6 months ago

Yeah, I couldn't find on for the docker image. :shrug: It would be nice to have the env var upstream though. If any community members would like to do that PR to nextcloud/docker, please let us know here and we will also review a PR here for accommodating that in this repo as well.

Tha-Fox commented 6 months ago

Thank you both for your replies!

Perhaps you can use this the above default_timezone parameter using the nextcloud.configs.myconfigfile.php feature?

My Nextcloud instance has correct timezone applied via extraEnv, so that is not a problem. Timezone is incorrect only within nextcloud-nginx container.

I have no skills with Helm charts, so from my perspective this issue can be closed. I'll add your excellent suggestion, k8tz, to my toolchain and fix the timezone that way.