Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mautic:5.1-fpm cannot be installed - AppTestKernel.php is not found. It is not there #287

Open
socialnicheguru opened this issue Jun 29, 2024 · 13 comments

Comments

@socialnicheguru
Copy link

Mautic:5.1-fpm cannot be installed

Warning: require(/var/www/html/vendor/composer/../../docroot/app/AppTestKernel.php): Failed to open stream: No such file or directory in /var/www/html/vendor/composer/autoload_real.php on line 41

Fatal error: Uncaught Error: Failed opening required '/var/www/html/vendor/composer/../../docroot/app/AppTestKernel.php' (include_path='.:/usr/local/lib/php') in /var/www/html/vendor/composer/autoload_real.php:41 Stack trace: #0 /var/www/html/vendor/composer/autoload_real.php(45): {closure}('7f9097acd45f80f...', '/var/www/html/v...') #1 /var/www/html/vendor/autoload.php(25): ComposerAutoloaderInitc287596483174f245407e95fbe560909::getLoader() #2 /var/www/html/docroot/autoload.php(13): require('/var/www/html/v...') #3 /var/www/html/docroot/app/config/bootstrap.php(5): require('/var/www/html/d...') #4 /var/www/html/docroot/index.php(9): require('/var/www/html/d...') #5 {main} thrown in /var/www/html/vendor/composer/autoload_real.php on line 41

when I log into my docker container the file, AppTestKernel.php, is not present on the path or in the system.
root@722386f8bb2c:/var/www/html/docroot/app# ls
AppCache.php codingstandards migrations
AppKernel.php composer.json phpunit.xml.dist
README.md config release_metadata.json
assets console-application.php
bundles middlewares

@RCheesley
Copy link
Member

I had this happen before when I'd got my root folder set incorrectly in my virtual host - is yours pointing to /docroot per the note in the docs here?

@escopecz
Copy link
Member

escopecz commented Jul 5, 2024

The AppTestKernel.php file isn't even used in production. It's there just to run PHPUNIT tests. What command or action triggers this error?

@silviupanaite
Copy link

I get the same error on a fresh install using the docker-compose file with migrations enabled.

@escopecz
Copy link
Member

@silviupanaite by running tests?

@silviupanaite
Copy link

silviupanaite commented Jul 23, 2024

No, I did a fresh install using

mautic_web:
    image: mautic/mautic:5-fpm

Updated the image to mautic:5.1-fpm and did docker-compose up
relevant options in the env

DOCKER_MAUTIC_RUN_MIGRATIONS=true
DOCKER_MAUTIC_LOAD_TEST_DATA=false

@escopecz
Copy link
Member

It will be connected to mautic/mautic#13797 where the AppTestKernel was re-introduced. But the class is clearly there. I can't explain why it's not in your filesystem.

I was testing upgrade from the Apache image from 5.3 to 5.1 while building https://github.com/escopecz/docker-compose-mautic and I had no problems to do so.

@silviupanaite
Copy link

I retried with mautic:5-apache and mautic:5.1-apache the result is

mautic_web_1     | [2024-07-23 15:39:15] [notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
mautic_web_1     | [error] Migration Mautic\Migrations\Version20190524124819 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic_db.leads' doesn't exist"
mautic_web_1     | 
mautic_web_1     | In ExceptionConverter.php line 49:
mautic_web_1     |                                                                                
mautic_web_1     |   An exception occurred while executing a query: SQLSTATE[42S02]: Base table   
mautic_web_1     |   or view not found: 1146 Table 'mautic_db.leads' doesn't exist                
mautic_web_1     |                                                                                
mautic_web_1     | 
mautic_web_1     | In Exception.php line 28:
mautic_web_1     |                                                                                
mautic_web_1     |   SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic_db.leads'  
mautic_web_1     |    doesn't exist                                                               
mautic_web_1     |                                                                                
mautic_web_1     | 
mautic_web_1     | In Statement.php line 130:
mautic_web_1     |                                                                                
mautic_web_1     |   SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic_db.leads'  
mautic_web_1     |    doesn't exist                                                               
mautic_web_1     |                                                                                
mautic_web_1     | 
mautic_web_1     | doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--] [<version>]
mautic_web_1     | 
mautic_web_1     | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.96.3. Set the 'ServerName' directive globally to suppress this message
mautic_web_1     | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.96.3. Set the 'ServerName' directive globally to suppress this message
mautic_web_1     | [Tue Jul 23 15:39:16.878818 2024] [mpm_prefork:notice] [pid 18] AH00163: Apache/2.4.59 (Debian) PHP/8.1.29 configured -- resuming normal operations
mautic_web_1     | [Tue Jul 23 15:39:16.878866 2024] [core:notice] [pid 18] AH00094: Command line: 'apache2 -D FOREGROUND'
mautic_web_1     | 127.0.0.1 - - [23/Jul/2024:15:39:20 +0000] "GET / HTTP/1.1" 302 607 "-" "curl/7.88.1"
mautic_web_1     | 127.0.0.1 - - [23/Jul/2024:15:39:26 +0000] "GET / HTTP/1.1" 302 607 "-" "curl/7.88.1"
mautic_web_1     | 127.0.0.1 - - [23/Jul/2024:15:39:31 +0000] "GET / HTTP/1.1" 302 607 "-" "curl/7.88.1"
mautic_web_1     | 127.0.0.1 - - [23/Jul/2024:15:39:36 +0000] "GET / HTTP/1.1" 302 607 "-" "curl/7.88.1"
mautic_web_1     | 127.0.0.1 - - [23/Jul/2024:15:39:41 +0000] "GET / HTTP/1.1" 302 607 "-" "curl/7.88.1"
mautic_web_1     | 127.0.0.1 - - [23/Jul/2024:15:39:46 +0000] "GET / HTTP/1.1" 302 607 "-" "curl/7.88.1"

@escopecz
Copy link
Member

@silviupanaite can you also provide the steps you took along with the output? It's hard to understand the issue without it.

@silviupanaite
Copy link

git clone https://github.com/mautic/docker-mautic.git
cd examples/fpm-nginx
docker-compose up

edit the docker-compose.yaml and add 5.1-fpm instead of 5-fpm

docker-compose up 

I tried your repo, and it works with 5.1 the migration didn't work when I tried

@escopecz
Copy link
Member

@silviupanaite I cannot replicate following your steps. Can you be more concrete about

edit the docker-compose.yaml and add 5.1-fpm instead of 5-fpm

Did you replace it in all 3 places?

@silviupanaite
Copy link

Yes I did replace all the images for worker, cron and web

@imrodrigoalves
Copy link

imrodrigoalves commented Aug 1, 2024

Same issue here. While updating the image from 5-fpmto 5.1-fpm I get the same error.

Mautic docker-compose file:

version: '3.8'

x-mautic-volumes:
  &mautic-volumes
  - ./config:/var/www/html/config:z
  - ./logs:/var/www/html/var/logs:z
  - ./media/files:/var/www/html/media/files:z
  - ./media/images:/var/www/html/media/images:z
  - ./cron:/opt/mautic/cron:z
  - mautic-docroot:/var/www/html/docroot:z

services:
  rabbitmq:
    image: rabbitmq:3
    environment:
      - RABBITMQ_DEFAULT_VHOST=mautic
    volumes: 
      - rabbitmq-data:/var/lib/rabbitmq
    networks:
      - default
      
  web:
    container_name: mautic_web
    image: mautic/mautic:5-fpm
    restart: unless-stopped
    networks:
      - common-web-network
    volumes: *mautic-volumes
    environment:
      - DOCKER_MAUTIC_ROLE=mautic_web
    env_file:
      - .mautic_env
    healthcheck:
      test: cgi-fcgi -bind -connect 127.0.0.1:9000
      start_period: 5s
      interval: 5s
      timeout: 5s
      retries: 100
    deploy:
      resources:
        limits:
          memory: 1024M  

  cron:
    image: mautic/mautic:5-fpm
    restart: unless-stopped
    networks:
      - common-web-network
    volumes: *mautic-volumes
    environment:
      - DOCKER_MAUTIC_ROLE=mautic_cron
    env_file:
      - .mautic_env
    depends_on:
      web:
        condition: service_healthy
    deploy:
      resources:
        limits:
          memory: 1536M  

  worker:
    image: mautic/mautic:5-fpm
    restart: unless-stopped
    networks:
      - common-web-network
    volumes: *mautic-volumes
    environment:
      - DOCKER_MAUTIC_ROLE=mautic_worker
    env_file:
      - .mautic_env
    depends_on:
      web:
        condition: service_healthy
    deploy:
      resources:
        limits:
          memory: 1536M   

volumes:
  rabbitmq-data:
  mautic-docroot:
    external: true
    
networks:
  common-web-network:
    external: true

Nginx docker-compose file:

version: '3.8'

services:
  nginx:
    image: nginx:1.25
    networks:
      - common-web-network
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - certs:/etc/letsencrypt
      - mautic-docroot:/var/www/mautic.domain.de/docroot:z
    ports:
      - 80:80
      - 443:443
    deploy:
      resources:
        limits:
          memory: 512M
      
  mysqldb:
    image: mysql:8.0
    networks:
      - common-web-network
    ports:
      - 3306:3306
    env_file:
      - ./mysql/.env
    volumes: 
      - ./mysql/my.cnf:/etc/mysql/my.cnf:ro
      - mysqldb:/var/lib/mysql
    healthcheck:
      test: mysqladmin --user=$$MYSQL_USER --password=$$MYSQL_PASSWORD ping
      start_period: 5s
      interval: 5s
      timeout: 5s
      retries: 10
    deploy:
      resources:
        limits:
          memory: 8G
          
  soketi:
    build: ./soketi
    image: soketi:latest
    networks:
      - common-web-network
    ulimits:
      nproc: 65535
      nofile:
        soft: 2048
        hard: 2048
    deploy:
      resources:
        limits:
          memory: 512M
  
volumes:
  mautic-docroot:
    external: true
  mysqldb:
    external: true
  certs:
    external: true
    
networks:
  common-web-network:
    external: true

Nginx config file:

server {
    listen 80;
    server_name mautic.domain.de;
    
    root /var/www/mautic.domain.de/docroot;
    
    # Allow Let's Encrypt ACME challenge for SSL certificate renewal
    location ~ /.well-known/acme-challenge {
        allow all;
        root /var/www/html;  # Adjust root path as per your server configuration
    }

    # Redirect all HTTP traffic to HTTPS
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    server_name mautic.domain.de;
    
    root /var/www/mautic.domain.de/docroot;
    
    ssl_certificate /etc/letsencrypt/live/mautic.domain.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mautic.domain.de/privkey.pem;
    
    # SSL Configuration (already included)

    # Enhance security headers
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Frame-Options "SAMEORIGIN";
    add_header Referrer-Policy "same-origin";

    location / {
        index index.php;
        try_files $uri $uri/ /index.php?$query_string;
        
        # Ensure client body and header sizes are limited
        # client_max_body_size 10m;
        # client_body_buffer_size 128k;
        # client_header_buffer_size 1k;
        # large_client_header_buffers 2 1k;
        
        # Block common vulnerable User-Agents
        if ($http_user_agent ~* (wget|curl) ) {
            return 403;
        }
        
        # Block access to hidden files and certain file types
        location ~ /\. {
            deny all;
        }
        
        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|^#.*#$|\.php_ {
            deny all;
            return 403;
        }
        
        # Whitelist your IP for administrative access
        # location /admin {
        #     allow your_admin_ip;
        #     deny all;
        # }
        
        # Proxy pass requests to your application server
        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass mautic_web:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /var/www/html/docroot/$fastcgi_script_name;
        }
    }
}

@SafPlusPlus
Copy link
Contributor

SafPlusPlus commented Aug 14, 2024

I worked around this on a test deployment by (backing up and) removing the named docker volume mautic-docroot. This contains versioned source copied from the image, since it's a docker volume. By removing it before running the new version, docker will populate the the volume with a fresh version of the updated docroot files.

I'm wondering, what is the purpose of that directory being a named volume? Is it that a leftover from in the past needing to be able to be update through the web interface?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants