Skip to content

Commit

Permalink
Merge pull request #1768 from gjrtimmer/fix-timezone
Browse files Browse the repository at this point in the history
Fix container timezone
  • Loading branch information
sameersbn authored Jul 3, 2021
2 parents 4ecfe8a + 6ed4aa7 commit 0341e15
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `[email protected]` |
| `GITLAB_EMAIL` | The email address for the GitLab server. Defaults to value of `SMTP_USER`, else defaults to `[email protected]`. |
Expand Down
2 changes: 2 additions & 0 deletions assets/runtime/env-defaults
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

# CONTAINER
DEBUG=${DEBUG:-$DEBUG_ENTRYPOINT}
TIMEZONE=${TZ:-UTC}

## GITLAB CORE
GITLAB_TEMP_DIR="${GITLAB_DATA_DIR}/tmp"
Expand Down
16 changes: 16 additions & 0 deletions assets/runtime/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1561,13 +1561,29 @@ EOF
chmod +x /usr/local/sbin/healthcheck
}

configure_container_timezone() {
# Perform 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
initialize_datadir
update_ca_certificates
generate_ssh_host_keys
update_ssh_listen_port
configure_container_timezone
install_configuration_templates
rm -rf /var/run/supervisor.sock
}
Expand Down

0 comments on commit 0341e15

Please sign in to comment.