LibreBooking / docker

Librebooking as a docker container
GNU General Public License v3.0
11 stars 12 forks source link

Timezone environment doesn't work in docker #11

Closed uebmaster closed 1 year ago

uebmaster commented 1 year ago

I've changed the TZ value in docker-compose.yml and the timezone is not reflected in librebooking.

Compose file:

image

After run docker compose, Application Configuration show America/New_York.

Then i change it to America/Mexico_City, but when i go to Server Settings it shows this:

image

That is not the real time.

How can i change it to America/Mexico_City?

Thanks in advance.

ben13300 commented 1 year ago

Dear @uebmaster , i think you will be able to change the timezone inside your config.phpµ image image

uebmaster commented 1 year ago

@ben13300 that was the first that i tried, but doesn't works.

colisee commented 1 year ago

Hola @uebmaster

First of all, thank you for your pull request regarding the wrong URL in the Dockerfile, as I forgot to update it since the main project was moved to the new librebooking namespace in github. I took the liberty to drop the commented wrong/old line.

Regarding the timezone issue, could you please run the following commands when performing the test?

docker volume rm librebooking_html librebooking-db_data
docker-compose up --detach
docker exec --tty librebooking-db sh -c 'date'
docker exec --tty librebooking sh -c 'date'

I believe it should work, thanks to the script entrypoint.sh. But then I realize that this script could have changed the timezone setting inside librebooking. I will make the change and push the new images to the docker's hub.

Saludos.

colisee commented 1 year ago

Hi,

I have pushed a new docker image librebooking/librebooking:2.8.5 to the docker's hub and I believe that the issue is fixed now.

  1. Display when registering the admin Capture d’écran de 2023-04-20 09-28-53

  2. Display when reviewing application settings Capture d’écran de 2023-04-20 09-30-23

Kind regards.

uebmaster commented 1 year ago

@colisee really i think that was my first pull request xD the true is that i'm not a developer, in fact, that was the reason for comment the original line cause i was not sure what i was suggesting were correct lol.

Regarding the timezone issue, I've already tested verifying the date in both containers and host, and all showed the right date, if i modified the date in librebooking's setup application i was able to change it, but when i check in server settings the time still being UTC +00:00, i don't know if this is right, but i have some standalone (bare metal) installs of bookedscheduler (when was free) and librebooking and it shows the right date and hour.

I wouldn't have a problem if it was only aesthetic, but since there was a time change in Mexico, in the other installs they couldn't create reservations due to the configured rules.

I suppose that is something relationated with librebooking, cause the date in containers shows correctly.

What could be?

Thanks in advance.

uebmaster commented 1 year ago

@colisee

when run

docker exec librebooking sh -c "php -i | grep 'date.timezone'"

i get

date.timezone => no value => no value

this could be the cause?

uebmaster commented 1 year ago

@colisee yeah, it is the cause, the timezone in apache is not configured in the container, i had to copy /usr/local/etc/php/php.ini-development to /usr/local/etc/php/php.ini,

then uncomment the

;date.time = (the value was empty)

and add the timezone America/Mexico_City

Restart apache2

service apache2 restart

and after that the server time is displayed correctly

image

I don't know how to implement that in the Dockerfile or entrypoints.sh in fact i don't know in what file it could be implemented xD

colisee commented 1 year ago

Hola @uebmaster ,

I was writing to you at the same moment! I reached the same conclusion as you, although I was considering to use the file php.ini-production.

As a confirmation, I suppose that your standalone server with librebooking has a php.ini file with the correct timezone value; right?

I confirm that the change must be done on entrypoint.sh. I will do it by tomorrow.

Saludos.

uebmaster commented 1 year ago

@colisee surely i have a php.ini in the standalone server.

Thanks, anyway i'll try to make the change, although for some reason when i try to build the container and run it i can't see the librebooking site :/

uebmaster commented 1 year ago

@colisee the docker compose needs a php.ini volume pointing to /usr/local/etc/php/php.ini like i commented you in the PR #15 (i don't know if is the correct pr lol)

image

and here the content of php.ini

[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone=${TZ}

after that the Mexico's timezone is displayed correctly in Server Settings.

Thanks for the container.

PD: Sorry for my bad English.

~~UPDATE: For some reason after restart the container the timezone back to utc 00:00 in server settings, i don't know why but i think that you know how to make it persistent lol.~~

bye.

colisee commented 1 year ago

@uebmaster , thank you for proposing your solution and submitting a pull request.

I prefer to use a simpler solution that avoids installing a new php extension: modify entrypoint.sh in order to create file /usr/local/etc/php/conf.d/librebooking.ini with the proper date.timezone assignment.

In addition to this change, which solves the issue, I also followed the recommendation of the authors of the php:7-apache image by renaming the file /usr/local/etc/php/php.ini-production into /usr/local/etc/php/php.ini in the Dockerfile.

At this stage, I didn't merge the above 2 changes to the main branch, yet. Could you kindly build the image from the develop branch by following the revised option-1 instructions and report whether the solution worked for you?

Saludos.

uebmaster commented 1 year ago

@colisee it works, i already see the right timezone in server settings section, but the time still be wrong, it shows one more hour than real time, see screenshot:

image

I think the creation of php.ini its elegant, but the update of timezonedb at least (i think) version 2022.7 (2023.3 last version, i think is better last version) is necessary for people like me, tha live in Mexico, because starting this year there will be no daylight saving time, es posible that you implement that update?

colisee commented 1 year ago

@uebmaster , OK got it!

I understand that the problem now is that the timezonedb shipped with the base docker image (php:7-apache) is too old. What you need, is the latest version of timezonedb (olson 2023.3) to take into account the new daylight saving time rules implemented in Mexico.

I now better understand the changes you were proposing in Dockerfile. Nevertheless, I believe that pecl should be called from entrypoint.sh.

While I work on the change, you can run the following commands in the librebooking container:

pecl install timezonedb
echo "extension=timezonedb.so" >> /usr/local/etc/php/conf.d/librebooking.ini
service apache2 reload
uebmaster commented 1 year ago

@colisee thanks, one more question, how can i update from version 2.8.5 to version 2.8.6 using docker? Assuming that a new docker container has been released.

Thanks.

colisee commented 1 year ago

@uebmaster , I need to review the Dockerfile for version 2.8.6, because some php modules must apparently be installed with composer now.

Thus you need to be a little patient ;-)

colisee commented 1 year ago

@uebmaster , I just pushed the modified entrypoint.sh in the develop branch. I think this should finally solve/close this issue.

Could you please build the image and test?

uebmaster commented 1 year ago

@colisee It Works!!!

Thanks

uebmaster commented 1 year ago

there is something weird :s

if i change the timezone to the schedule, the timetable looks weird, i need to back the timezone to new york, look at:

This is with schedule's new york timezone image

image

And this is withs chedule's Mexico city timezone image

image

If i return to new york's timezone the timetable looks right again.

The server setting's timezone has the correct date and hour accord to Mexico city.

I thinked that could be the update of the timezonedb but I've commented the new lines and it's the same apparently.

Do you think there is no problem if i use the server with mexico's timezone and schedule with new York's timezone?

Thanks in advance.

uebmaster commented 1 year ago

there is something weird :s

if i change the timezone to the schedule, the timetable looks weird, i need to back the timezone to new york, look at:

This is with schedule's new york timezone image

image

And this is withs chedule's Mexico city timezone image

image

If i return to new york city timezone the timetable looks right again.

The server setting's timezone has the correct date and hour accord to Mexico city.

I thinked that could be the update of the timezonedb but I've commented the new lines and it's the same apparently.

Do you think there is no problem if i use the server with mexico's timezone and schedule with new York's timezone?

Thanks in advance.

colisee commented 1 year ago

@uebmaster, do you get the same result when you start from a fresh copy; that is:

docker-compose down --volumes  # this will delete your 2 librebooking data volumes
docker-compose up -d
# repeat the librebooking setup

On my side, the only "weird" sign I saw was that the initial timezone of the Default schedule was "America/New_York".

I changed it to "America/Mexico_City", changed the reservation blocks (from 09:00 to 18:00) and saved it. Then I created the resource. Finally, when displaying the Schedule/Bookings, I could see the proper slots (from 09:00 to 18:00 with 4 slots per hour).

If you cannot delete the docker volumes (because you are in production), then you can try to create a new schedule, making sure it is correct before validating. Then link the resource to the new schedule.

uebmaster commented 1 year ago

Maybe my problem is that I'm making the new install importing demo data, I'll check on Monday with a fresh install without demo data.Thanks, have a nice weekend.El 22 abr. 2023 3:45 a. m., Robin ALEXANDER @.***> escribió: @uebmaster, do you get the same result when you start from a fresh copy; that is: docker-compose down --volumes # this will delete your 2 librebooking data volumes docker-compose up -d

repeat the librebooking setup

On my side, the only "weird" sign I saw was that the initial timezone of the Default schedule was "America/New_York". I changed it to "America/Mexico_City", changed the reservation blocks (from 09:00 to 18:00) and saved it. Then I created the resource. Finally, when displaying the Schedule/Bookings, I could see the proper slots (from 09:00 to 18:00 with 4 slots per hour). If you cannot delete the docker volumes (because you are in production), then you can try to create a new schedule, making sure it is correct before validating. Then link the resource to the new schedule.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

uebmaster commented 1 year ago

@colisee i was sure that I've commented that making a fresh install librebooking works fine with the Mexico city timezone :/

Anyway, it works, thanks a lot.