docker icon indicating copy to clipboard operation
docker copied to clipboard

Create logfile at startup

Open ne20002 opened this issue 5 months ago • 2 comments

This PR is opened as draft pull request as it may need some discussion and a bit more testing.

As described in #https://github.com/friendica/friendica/issues/15001 the log file is not creatd by friendica when logging is enabled. This PR is an attempt to fix this.

I only had time to test this with the fpm image (which is debian based).

My concerns are:

  • I don't want to just create an empty log file with the current default (which is /var/www/html/friendica.log) as its location in /var/www/html is not really a good idea. I would vote for /var/log/friendica.log as a default.
  • To make use of FRIENDICA_LOGFILE requires to check for the correct permission on the folder from the entrypoint.sh script. To do so I needed to add sudo to the installed packages (not really a security issue but not best practice).
  • I haven't tested with Alpine (not sure if Alpine suports sudo out of the box).
  • The correct solution would be that Friendica itself creates the file upon start or when enabled/changed in the UI. It seems as if it honors the location from then environment variable (which is good).

ne20002 avatar Jul 05 '25 13:07 ne20002

I believe there is no elegant way to create the logfile with the docker image. The possible options left are:

  • just create an empty friendica.log file in /var/www/html in Dockerfile as this is the logfile default and it would by placed in a writable volume

For using Docker usually users would mount the log file and if so, the logfile needs to exist anyway. In all other cases I believe the underlying problem should be fixed in Friendica.

@mfxa, @nupplaphil: do you agree?

ne20002 avatar Aug 30 '25 16:08 ne20002

For some reason i can't make a direct comment on your new "comment", so responding here instead:

I believe there is no elegant way to create the logfile with the docker image. The possible options left are:

* just create an empty friendica.log file in /var/www/html in Dockerfile as this is the logfile default and it would by placed in a writable volume

For using Docker usually users would mount the log file and if so, the logfile needs to exist anyway. In all other cases I believe the underlying problem should be fixed in Friendica.

@mfxa, @nupplaphil: do you agree?

I think it sounds like a better idea to create it in the Dockerfile, yes. Good idea. Better to move as much as possible to build time, and then it only needs to be done in one place.

mfxa avatar Sep 10 '25 13:09 mfxa