Open tenken opened 4 years ago
This works for me at the moment (setting the value in 1 place):
image:
name: edbizarro/gitlab-ci-pipeline-php:7.2
# Nothing in this thread seemed to help to set it globally for the image
# https://gitlab.com/gitlab-org/gitlab-runner/issues/2692#note_50147081
#
# entrypoint: ["/usr/local/bin/docker-php-entrypoint", "-a", "-d date.timezone=America/Los_Angeles"]
variables:
GIT_SSL_NO_VERIFY: 1
before_script:
- whoami
# If our shell is not interactive or a login shell we may need to allow alias expansion.
- shopt -s expand_aliases
- alias php='php -d date.timezone=America/Los_Angeles'
# Cannot do below in any script because invalid permissions as
# /usr/local/etc/php/conf.d is owned by root and gitlab-runner runs php
# container with user "php".
# - sudo echo "date.timezone = America/Los_Angeles" > /usr/local/etc/php/conf.d/tzdata.ini
# Run an example Test stage.
test:
script:
- set -x
# List found aliases
- alias
# Locally setting -d date.timezone works here, but doing this per-line sucks.
# - php -d date.timezone=America/Los_Angeles test.php
- php test.php
- date
# Show a list of available shells for possible debugging.
- cat /etc/shells
# To debug the container add the following line that will keep the container alive forever.
# - tail -f /dev/null
Hi,
I have noticed when I use this container as my main image for a stage, Bash within the container can match the same TZ as the Host OS. But when php uses date or something I get UTC output.
Example .gitlab-ci.yml file
Output
Is there a way to override TZ via an env var or a php config file. Maybe I could try a
before_script
usage:But I have not tried that. I'd rather not hardset the TZ via php application code if that can be avoided.
I like the idea of mounting a custom volume to the docker container and updating the php tzdata.conf value for it, but for a Gitlab service container this is not possible (easily) on Gitlab 12.x
Any feedback is appreciated.