tobybatch / kimai2

Docker containers for the kimai2 web application including docker-compose and kubernetes/helm deployment.
MIT License
181 stars 96 forks source link

[BUG] Kimai2 apache-latest: #377

Closed sgaechter closed 2 years ago

sgaechter commented 2 years ago

Describe the bug After Updating the Kimai2 Docker Container to apache-latest the following Error occure when I try to enter the kimai2 Webpage:

coaching_kimai2 | [Mon May 02 21:08:44.486742 2022] [php:notice] [pid 65] [client 127.0.0.1:39316] [2022-05-02 19:08:44] php.CRITICAL: Uncaught Error: Nelmio\CorsBundle\EventListener\CorsListener::__construct(): Argument #1 ($configurationResolver) must be of type Nelmio\CorsBundle\Options\ResolverInterface, Symfony\Component\EventDispatcher\EventDispatcher given, called in /opt/kimai/var/cache/prod/ContainerEpiL5CR/srcApp_KernelProdContainer.php on line 1636 {"exception":"[object] (TypeError(code: 0): Nelmio\\CorsBundle\\EventListener\\CorsListener::__construct(): Argument #1 ($configurationResolver) must be of type Nelmio\\CorsBundle\\Options\\ResolverInterface, Symfony\\Component\\EventDispatcher\\EventDispatcher given, called in /opt/kimai/var/cache/prod/ContainerEpiL5CR/srcApp_KernelProdContainer.php on line 1636 at /opt/kimai/vendor/nelmio/cors-bundle/EventListener/CorsListener.php:44)"} [] coaching_kimai2 | localhost:8001 127.0.0.1 - - [02/May/2022:21:08:44 +0200] "GET / HTTP/1.1" 500 1018 "-" "curl/7.64.0"

To Reproduce Steps to reproduce the behaviour:

  1. Start the container 'kimai2:apache-latest' with Logging
  2. Call the Page'
  3. See the std out on cmd

Desktop (please complete the following information):

Command used to run the container

Docker compose file (with passwords redacted)

version: '3.5'
services:

    kimai:
        image: kimai/kimai2:apache
        container_name: coaching_kimai2
        environment:
            - APP_ENV=prod
            - TRUSTED_PROXIES=localhost,127.0.0.1,familystation,192.168.178.2,traefik,familystation/kimai
            - TRUSTED_HOSTS=localhost,127.0.0.1,192.168.178.2,familystation,traefik
            - ADMINMAIL=webmaster@gaechter.info
            - ADMINPASS=XXXXXXXXX
            - DATABASE_URL=mysql://kimaiuser:kimaipassword@sqldb/kimai
        volumes:
            - /volume1/docker/kimai/var:/opt/kimai/var
        ports:
            - 8002:8001
        restart: unless-stopped
        healthcheck:
            test: curl -s -o /dev/null http://localhost:8001 || exit 1
            interval: 20s
            start_period: 10s
            timeout: 10s
            retries: 3
        labels:
            - traefik.enable=true
            - traefik.http.routers.kimai.rule=Path(`/kimai`)
            - traefik.http.routers.kimai.entrypoints=web
            - traefik.http.services.kimai.loadbalancer.server.port=8001
            - traefik.docker.network=web
        networks: 
            - web
            - kimai
    sqldb:
        image: mysql:5.7
        container_name: coaching_kimai2_db
        environment:
            - MYSQL_DATABASE=kimai
            - MYSQL_USER=kimaiuser
            - MYSQL_PASSWORD=XXXXXXXXX
            - MYSQL_ROOT_PASSWORD=XXXXXXX
        volumes:
            - /volume1/docker/kimai/db:/var/lib/mysql
        ports:
            - 3333:3306
        command: --default-storage-engine innodb 
        restart: unless-stopped
        healthcheck:
            test: mysqladmin -p@XXXXXXX ping -h localhost
            interval: 20s
            start_period: 10s
            timeout: 10s
            retries: 3
        networks: 
            - kimai

networks:
    web:
        external: true
    kimai:
        external: true

Additional context

After Error I rolled back to kimai2:apache with no issue.

kevinpapst commented 2 years ago

Probably an expired cache that is used with the new sources? Can you run bin/console kimai:reload after the update?

sgaechter commented 2 years ago

Hello Kevin. I updated and ran the suggested command:

      LOG 
      Reloading configurations ...

       [OK] All 39 YAML files contain valid syntax.

       [OK] All 512 XLIFF files contain valid syntax.

       Rebuilding your cache, please be patient ...

       // Clearing the cache for the prod environment with debug
       // false

       [OK] Cache for the "prod" environment (debug=false) was successfully cleared.

       // Warming up the cache for the prod environment with debug
       // false

       [ERROR] DoctrineMetadataCacheWarmer must load metadata first, check priority of
               your warmers.

       [WARNING] Cache could not be rebuilt.

                 Please run these commands to rebuild the cache manually:

                 rm -r var/cache/*
                 bin/console cache:clear --env=prod
                 bin/console cache:warmup --env=prod
      END LOG

I ran the tree suggested commands, the first didn't work, but the other two did. After this, I could access the page, but my Login with the previous credentials failed...

The rolback solved the problem, but still state 1.14.1...

kevinpapst commented 2 years ago

Hm, something is messed up. Sorry, but I don't know Docker, so I can't really help if the default commands don't work. Probably upgrading from 1.14 to 1.19 is not supported?

tobybatch commented 2 years ago

@sgaechter Thanks for the bug and fix. We'll keep an eye on this but I think Kevin may be right about the big upgrade jump. When building the container it's always a trade off between run every possible command that may be needed vs keep the process quick and the image small.

tobybatch commented 2 years ago

Are you actually shelled into the container before you run those commands?

docker-compose exec kimai bash
sgaechter commented 2 years ago

Dear all. Thanks for your suggestions. I've updated my Container now from "apache-1.14.1-prod" to "apache-1.14.3-prod" with no issues. I only had had to clear the cache by using

       bin/console cache:clear --env=prod
       bin/console cache:warmup --env=prod

After updating to "apache-1.15.1-prod" I could update every major version step by step, finally, I arrived at "apache-1.19.6-prod" In the future I keep my Container updated :-)

This is for documentation purposes - this Issue is closed. Thanks for your work @tobybatch.