kimai / kimai

Kimai is a web-based multi-user time-tracking application. Works great for everyone: freelancers, companies, organizations - everyone can track their times, generate reports, create invoices and do so much more. SaaS version available at https://www.kimai.cloud
https://www.kimai.org
GNU Affero General Public License v3.0
3.32k stars 590 forks source link

Lots of log entries in Docker due to healthcheck 404 #5085

Closed liayn closed 1 month ago

liayn commented 2 months ago

Describe the problem

Using the FPM image, the docker logs show load of errors like

127.0.0.1 - 26/Sep/2024:15:24:34 +0100 "GET /ping" 404

This is due to the health check in https://github.com/kimai/kimai/blob/40154be8f9354b185d6595249c421051d545f64d/.docker/Dockerfile.kimai-base#L127

Obviously this does not work as intended.

Describe your setup and add your Docker compose file (redact your credentials)

Kimai Version 2.22.0

  time:
    image: kimai/kimai2:latest
    depends_on:
      - mysql81
    ports:
      - "127.0.0.1:9016:9000"
    environment:
      - DATABASE_URL=mysql://kimai:redacted@mysql81/kimai?charset=utf8mb4&serverVersion=8.1
      - TRUSTED_PROXIES=172.18.0.0/24
      - TRUSTED_HOSTS=*
      - MAILER_URL=smtp://mail.example.com
      - MAILER_FROM=webmaster@example.com
      - APP_SECRET=redacted
      - memory_limit=512M
    volumes:
      - /var/www/redacted/public:/opt/kimai/public
      - /opt/kimai/data:/opt/kimai/var/data
      - /opt/kimai/plugins:/opt/kimai/var/plugins
    restart: always

Command used to run the container

No response

kevinpapst commented 2 months ago

Thanks for your report!

Would you mind sharing your entire docker-compose.yaml ? I am currently updating the Docker docs and I have no example of a running FPM installation. The original maintainer left and now I a stuck with something I never used myself...

If you have any idea of how to improve the reported issue, I would be happy to discuss it.

liayn commented 1 month ago

Sure, but I can only add our mysql-service. We are running apache as reverse proxy natively, so this is not a pure docker-only setup.

If I had a solution ready, I would have pushed a PR; but I need to figure out how the healthcheck here is supposed to work.

services:
  mysql84:
    image: mysql:8.4
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=somepassword
    volumes:
      - /opt/mysql/mysqlcustom.cnf:/etc/mysql/conf.d/mysqlcustom.cnf
      - /opt/mysql/data:/var/lib/mysql
  time:
    image: kimai/kimai2:latest
    restart: always
    depends_on:
      - mysql84
    ports:
      - "127.0.0.1:9000:9000"
    environment:
      - DATABASE_URL=mysql://kimai:redacted@mysql84/kimai?charset=utf8mb4&serverVersion=8.4
      - TRUSTED_PROXIES=172.18.0.0/24
      - TRUSTED_HOSTS=*
      - MAILER_URL=smtp://mail.example.com
      - MAILER_FROM=webmaster@example.com
      - APP_SECRET=secret
    volumes:
      - /var/www/kimai/public:/opt/kimai/public
      - /opt/kimai/data:/opt/kimai/var/data
      - /opt/kimai/plugins:/opt/kimai/var/plugins

(If we would run the proxy in docker too, we would most likely either use "trafik" or "nginx" as proxy-service.)

liayn commented 1 month ago

@kevinpapst What's the correct route to access this action?

https://github.com/kimai/kimai/blob/40154be8f9354b185d6595249c421051d545f64d/src/API/StatusController.php#L35

I suppose it is "/api/ping", but this redirects me to the login.

The command SCRIPT_NAME=/ping SCRIPT_FILENAME=/ping REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 tries to contact the /ping "endpoint". I'm not sure whether it exists actually. (Did inspect the PHP code close enough yet.) If it should actually query the /api/ping endpoint, this must be adjusted, but won't help if it requires a login.

Also, I'm not sure, what SCRIPT_NAME and SCRIPT_FILENAME is actually required by Symfony to resolve the requested action correctly.

kevinpapst commented 1 month ago

I don't think that it is trying to reach the API. I think this is trying to check if PHP-FPM is available.

Search for ping.path on this page: https://www.php.net/manual/en/install.fpm.configuration.php Maybe that was activated in the past in the FPM default config and is now deactivated and therefor fails ... do we need to activate it with a sed during image build?

liayn commented 1 month ago

This is probably an upstream bug that has been resolved "recently" https://github.com/php/php-src/commit/43bc53a73060002644240d6bf47f58a41eca0c55

liayn commented 1 month ago

Okay, default config is "not set" (https://github.com/php/php-src/blob/91a07e7b75e6a685334c1482d27e856bc0a0183f/sapi/fpm/www.conf.in#L286)

I wonder if this never worked or if this config vanished

kevinpapst commented 1 month ago

History of this goes back a few years, so it either changed or never worked, we will never know.

In order to fix it, we need to activate the line you linked and this one is guess: https://github.com/php/php-src/blob/91a07e7b75e6a685334c1482d27e856bc0a0183f/sapi/fpm/www.conf.in#L369

kevinpapst commented 1 month ago

https://github.com/kimai/kimai/pull/5093