NathanVaughn / webtrees-docker

Up-to-date Docker image for webtrees with all the bells and whistles.
https://hub.docker.com/r/nathanvaughn/webtrees
MIT License
64 stars 15 forks source link

php.ini modifications #112

Closed nopoz closed 1 year ago

nopoz commented 1 year ago

I'm trying to add session.gc_maxlifetime = 86400 to the "/usr/local/etc/php/php.ini" file in order to extend the lifetime of an authenticated session to 24 hours. However every time the docker container starts up, the startup script docker-entrypoint.py clobbers my php.ini file and overwrites my changes. If I create a php.ini file on the host, mount it in the container in my compose file, mark it as read only, the /docker-entrypoint.py errors out and the container fails to start entirely:

[NV_INIT] Creating php.ini
Traceback (most recent call last):
  File "/docker-entrypoint.py", line 503, in <module>
    main()
  File "/docker-entrypoint.py", line 486, in main
    php_ini()
  File "/docker-entrypoint.py", line 287, in php_ini
    with open(php_ini_filename, "w") as fp:
OSError: [Errno 30] Read-only file system: '/usr/local/etc/php/php.ini'

I see a few potential solutions:

  1. add a new variable to the docker container for the "session.gc_maxlifetime" setting
  2. modify the docker-entrypoint.py so it will not crash when it can't write to the php.ini file because it's read only
  3. docker-entrypoint.py script only creates php.ini when it doesn't already exist
  4. docker-entrypoint.py only modifies specific php.ini config lines that are configurable with docker variables rather than overwriting the whole file - this would allow both docker variables and manual customizations to exist together
NathanVaughn commented 1 year ago

This is a great point, thanks for pointing this out. I didn't think about that at all when I added that functionality.

I updated docker-entrypoint.py to create a new php.ini file if it does not exist, or to update an existing one in-place so you can your own customizations. I've started new builds and hopefully they push out in about an hour.

nopoz commented 1 year ago

Thanks for the fast response and commit! I've tested the new build out and it works as expected - modifications to php.ini stick around after a container restart.