Skip to content

Commit 0341e15

Browse files
authored
Merge pull request #1768 from gjrtimmer/fix-timezone
Fix container timezone
2 parents 4ecfe8a + 6ed4aa7 commit 0341e15

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,13 +781,14 @@ Below is the complete list of available options that can be used to customize yo
781781
| Parameter | Description |
782782
|-----------|-------------|
783783
| `DEBUG` | Set this to `true` to enable entrypoint debugging. |
784+
| `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`. |
784785
| `GITLAB_HOST` | The hostname of the GitLab server. Defaults to `localhost` |
785786
| `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. |
786787
| `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`. |
787788
| `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. |
788789
| `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. |
789790
| `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. |
790-
| `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). |
791+
| `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` |
791792
| `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**. |
792793
| `GITLAB_ROOT_EMAIL` | The email for the root user on firstrun. Defaults to `[email protected]` |
793794
| `GITLAB_EMAIL` | The email address for the GitLab server. Defaults to value of `SMTP_USER`, else defaults to `[email protected]`. |

assets/runtime/env-defaults

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

3+
# CONTAINER
34
DEBUG=${DEBUG:-$DEBUG_ENTRYPOINT}
5+
TIMEZONE=${TZ:-UTC}
46

57
## GITLAB CORE
68
GITLAB_TEMP_DIR="${GITLAB_DATA_DIR}/tmp"

assets/runtime/functions

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,13 +1561,29 @@ EOF
15611561
chmod +x /usr/local/sbin/healthcheck
15621562
}
15631563

1564+
configure_container_timezone() {
1565+
# Perform sanity check of provided timezone value
1566+
if [ -e /usr/share/zoneinfo/${TIMEZONE} ]; then
1567+
# Configured timezone is available
1568+
1569+
# Set localtime
1570+
ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
1571+
1572+
# Set timezone
1573+
echo ${TIMEZONE} > /etc/timezone
1574+
1575+
echo "Container TimeZone -> ${TIMEZONE}"
1576+
fi
1577+
}
1578+
15641579
initialize_system() {
15651580
map_uidgid
15661581
initialize_logdir
15671582
initialize_datadir
15681583
update_ca_certificates
15691584
generate_ssh_host_keys
15701585
update_ssh_listen_port
1586+
configure_container_timezone
15711587
install_configuration_templates
15721588
rm -rf /var/run/supervisor.sock
15731589
}

0 commit comments

Comments
 (0)