You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
# This file is a template, and might need editing before it works on your project.# Select image from https://hub.docker.com/_/php/image: edbizarro/gitlab-ci-pipeline-php:7.2# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service# See http://docs.gitlab.com/ce/ci/services/README.html for examples.services:
- {name: 'tenken/mysqlci:8.0.16', alias: 'mysql-service'}# Set any variables we needvariables:
# Configure mysql environment variables (https://hub.docker.com/r/_/mysql/)MYSQL_ROOT_PASSWORD: testMYSQL_USER: testMYSQL_PASSWORD: testMYSQL_DATABASE: testdb# https://gitlab.com/gitlab-org/gitlab-runner/issues/4405#note_225960882MYSQL_INITDB_SKIP_TZINFO: 1DB_HOST: mysql-serviceCURRENT_QUARTER: $CURRENT_QUARTERGIT_SSL_NO_VERIFY: 1# Run our tests# If Xdebug was installed you can generate a coverage report and see code coverage metrics.test:
script:
- php test.php
- date# Output some MYSQL information to assure DBs created ok.
- mysql -h $DB_HOST -e "SHOW VARIABLES LIKE '%version%';" -uroot -p$MYSQL_ROOT_PASSWORD# To debug the container add the following line that will keep the container alive forever.
- tail -f /dev/null
Output
php date is: 2020-01-14 09:44:17 UTC
$ date
818 Tue Jan 14 13:44:17 PST 2020
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.
The text was updated successfully, but these errors were encountered:
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: 1before_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
php date is: 2020-01-14 09:44:17 UTC $ date 818 Tue Jan 14 13:44:17 PST 2020
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.
The text was updated successfully, but these errors were encountered: