From 9180bed1fe1428ab0222825c4b78090e45c9d0c4 Mon Sep 17 00:00:00 2001 From: Gert-Jan Timmer Date: Thu, 8 Nov 2018 16:26:06 +0100 Subject: [PATCH 1/3] fix Container TimeZone Fix Container TimeZone Fix Container TimeZone --- README.md | 3 ++- assets/runtime/functions | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cb903f331..f42089b31 100644 --- a/README.md +++ b/README.md @@ -781,13 +781,14 @@ Below is the complete list of available options that can be used to customize yo | Parameter | Description | |-----------|-------------| | `DEBUG` | Set this to `true` to enable entrypoint debugging. | +| `TZ` | Set the container timezone. Defaults to `UTC`. Values are expected to be in Canonical format. Example: `Europe/Amsterdam` See the list of [acceptable values](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). For configuring the timezone of gitlab see variable `GITLAB_TIMEZONE`. | | `GITLAB_HOST` | The hostname of the GitLab server. Defaults to `localhost` | | `GITLAB_CI_HOST` | If you are migrating from GitLab CI use this parameter to configure the redirection to the GitLab service so that your existing runners continue to work without any changes. No defaults. | | `GITLAB_PORT` | The port of the GitLab server. This value indicates the public port on which the GitLab application will be accessible on the network and appropriately configures GitLab to generate the correct urls. It does not affect the port on which the internal nginx server will be listening on. Defaults to `443` if `GITLAB_HTTPS=true`, else defaults to `80`. | | `GITLAB_SECRETS_DB_KEY_BASE` | Encryption key for GitLab CI secret variables, as well as import credentials, in the database. Ensure that your key is at least 32 characters long and that you don't lose it. You can generate one using `pwgen -Bsv1 64`. If you are migrating from GitLab CI, you need to set this value to the value of `GITLAB_CI_SECRETS_DB_KEY_BASE`. No defaults. | | `GITLAB_SECRETS_SECRET_KEY_BASE` | Encryption key for session secrets. Ensure that your key is at least 64 characters long and that you don't lose it. This secret can be rotated with minimal impact - the main effect is that previously-sent password reset emails will no longer work. You can generate one using `pwgen -Bsv1 64`. No defaults. | | `GITLAB_SECRETS_OTP_KEY_BASE` | Encryption key for OTP related stuff with GitLab. Ensure that your key is at least 64 characters long and that you don't lose it. **If you lose or change this secret, 2FA will stop working for all users.** You can generate one using `pwgen -Bsv1 64`. No defaults. | -| `GITLAB_TIMEZONE` | Configure the timezone for the gitlab application. This configuration does not effect cron jobs. Defaults to `UTC`. See the list of [acceptable values](http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html). | +| `GITLAB_TIMEZONE` | Configure the timezone for the gitlab application. This configuration does not effect cron jobs. Defaults to `UTC`. See the list of [acceptable values](http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html). For settings the container timezone which will effect cron, see variable `TZ` | | `GITLAB_ROOT_PASSWORD` | The password for the root user on firstrun. Defaults to `5iveL!fe`. GitLab requires this to be at least **8 characters long**. | | `GITLAB_ROOT_EMAIL` | The email for the root user on firstrun. Defaults to `admin@example.com` | | `GITLAB_EMAIL` | The email address for the GitLab server. Defaults to value of `SMTP_USER`, else defaults to `example@example.com`. | diff --git a/assets/runtime/functions b/assets/runtime/functions index 18bc8d524..82beafc10 100644 --- a/assets/runtime/functions +++ b/assets/runtime/functions @@ -1561,6 +1561,23 @@ EOF chmod +x /usr/local/sbin/healthcheck } +configure_container_timezone() { + TIMEZONE=${TZ:-UTC} + + # Preform sanity check of provided timezone value + if [ -e /usr/share/zoneinfo/${TIMEZONE} ]; then + # Configured timezone is available + + # Set localtime + ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime + + # Set timezone + echo ${TIMEZONE} > /etc/timezone + + echo "Container TimeZone -> ${TIMEZONE}" + fi +} + initialize_system() { map_uidgid initialize_logdir @@ -1568,6 +1585,7 @@ initialize_system() { update_ca_certificates generate_ssh_host_keys update_ssh_listen_port + configure_container_timezone install_configuration_templates rm -rf /var/run/supervisor.sock } From e194e7d8d01da6b5d845ebe81a8de77531018899 Mon Sep 17 00:00:00 2001 From: "G.J.R. Timmer" Date: Fri, 2 Oct 2020 13:37:13 +0200 Subject: [PATCH 2/3] moved default TIMEZONE variable to env-defaults Resolve conversation --- assets/runtime/env-defaults | 2 ++ assets/runtime/functions | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/runtime/env-defaults b/assets/runtime/env-defaults index a2967a53f..ad1ebc18f 100644 --- a/assets/runtime/env-defaults +++ b/assets/runtime/env-defaults @@ -1,6 +1,8 @@ #!/bin/bash +# CONTAINER DEBUG=${DEBUG:-$DEBUG_ENTRYPOINT} +TIMEZONE=${TZ:-UTC} ## GITLAB CORE GITLAB_TEMP_DIR="${GITLAB_DATA_DIR}/tmp" diff --git a/assets/runtime/functions b/assets/runtime/functions index 82beafc10..5d1d0a2b2 100644 --- a/assets/runtime/functions +++ b/assets/runtime/functions @@ -1562,8 +1562,6 @@ EOF } configure_container_timezone() { - TIMEZONE=${TZ:-UTC} - # Preform sanity check of provided timezone value if [ -e /usr/share/zoneinfo/${TIMEZONE} ]; then # Configured timezone is available From 6ed4aa776ce1a387f3668185ac0ba5605f28517f Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Wed, 10 Mar 2021 10:34:07 +0530 Subject: [PATCH 3/3] fixed typo --- assets/runtime/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/runtime/functions b/assets/runtime/functions index 5d1d0a2b2..c0561674e 100644 --- a/assets/runtime/functions +++ b/assets/runtime/functions @@ -1562,7 +1562,7 @@ EOF } configure_container_timezone() { - # Preform sanity check of provided timezone value + # Perform sanity check of provided timezone value if [ -e /usr/share/zoneinfo/${TIMEZONE} ]; then # Configured timezone is available