wodby / docker4drupal

Docker-based Drupal stack
https://wodby.com/docker4drupal
MIT License
1.23k stars 535 forks source link

unable to use existing drupal site when removing override yml #484

Open q8tywolf opened 3 years ago

q8tywolf commented 3 years ago

OS type Windows WSL 2 docker

Drupal version 9

Codebase my codebase

Describe the bug I deleted the docker-compose.override.yml to mount my own codebase, but I get the following error

Output of docker info

Additional uncaught exception thrown while handling exception.
Original
Error: Call to a member function setFormClass() on null in system_entity_type_build() (line 1200 of /var/www/html/web/core/modules/system/system.module).

system_entity_type_build(Array) (Line: 129)
Drupal\Core\Entity\EntityTypeManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('date_format', ) (Line: 143)
Drupal\Core\Entity\EntityTypeManager->getDefinition('date_format') (Line: 269)
Drupal\Core\Entity\EntityTypeManager->getHandler('date_format', 'storage') (Line: 208)
Drupal\Core\Entity\EntityTypeManager->getStorage('date_format') (Line: 93)
Drupal\Core\Datetime\DateFormatter->__construct(Object, Object, Object, Object, Object)
ReflectionClass->newInstanceArgs(Array) (Line: 1144)
Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object, Array, 1, 'date.formatter') (Line: 618)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet('date.formatter', 1) (Line: 558)
Symfony\Component\DependencyInjection\ContainerBuilder->get('date.formatter') (Line: 87)
Drupal\Core\TempStore\Element\BreakLockLink::create(Object, Array, 'break_lock_link', Array) (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('break_lock_link', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('break_lock_link', Array) (Line: 141)
Drupal\Core\Render\ElementInfoManager->createInstance('break_lock_link') (Line: 111)
Drupal\Core\Render\ElementInfoManager->buildInfo('seven') (Line: 77)
Drupal\Core\Render\ElementInfoManager->getInfo('form') (Line: 812)
Drupal\Core\Form\FormBuilder->prepareForm('install_select_language_form', Array, Object) (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm('Drupal\Core\Installer\Form\SelectLanguageForm', Object) (Line: 942)
install_get_form('Drupal\Core\Installer\Form\SelectLanguageForm', Array) (Line: 1369)
install_select_language(Array) (Line: 690)
install_run_task(Array, Array) (Line: 565)
install_run_tasks(Array, NULL) (Line: 118)
install_drupal(Object) (Line: 48)
Additional
Error: Call to a member function setFormClass() on null in system_entity_type_build() (line 1200 of /var/www/html/web/core/modules/system/system.module).

system_entity_type_build(Array) (Line: 129)
Drupal\Core\Entity\EntityTypeManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('date_format', ) (Line: 143)
Drupal\Core\Entity\EntityTypeManager->getDefinition('date_format') (Line: 269)
Drupal\Core\Entity\EntityTypeManager->getHandler('date_format', 'storage') (Line: 208)
Drupal\Core\Entity\EntityTypeManager->getStorage('date_format') (Line: 93)
Drupal\Core\Datetime\DateFormatter->__construct(Object, Object, Object, Object, Object)
ReflectionClass->newInstanceArgs(Array) (Line: 1144)
Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object, Array, 1, 'date.formatter') (Line: 618)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet('date.formatter', 1) (Line: 558)
Symfony\Component\DependencyInjection\ContainerBuilder->get('date.formatter') (Line: 87)
Drupal\Core\TempStore\Element\BreakLockLink::create(Object, Array, 'break_lock_link', Array) (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('break_lock_link', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('break_lock_link', Array) (Line: 141)
Drupal\Core\Render\ElementInfoManager->createInstance('break_lock_link') (Line: 111)
Drupal\Core\Render\ElementInfoManager->buildInfo('seven') (Line: 77)
Drupal\Core\Render\ElementInfoManager->getInfo('html') (Line: 300)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 144)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 145)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 1048)
install_display_output(Array, Array, Array) (Line: 270)
_drupal_log_error(Array, 1) (Line: 323)
_drupal_exception_handler(Object)

Contents of your docker-compose.yml

version: "3.7"

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD
    volumes:
     - ${PROJECT_DATA}:/var/lib/mysql # Use bind mount

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
    volumes:
      - ${PROJECT_DRUPAL}:/var/www/html

  crond:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_crond"
    environment:
     CRONTAB: "0 * * * * drush -r /var/www/html/web cron"
    command: sudo -E LD_PRELOAD=/usr/lib/preloadable_libiconv.so crond -f -d 0
    volumes:
     - ${PROJECT_DRUPAL}:/var/www/html

  nginx:
    image: wodby/nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
     - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
    volumes:
     - ${PROJECT_DRUPAL}:/var/www/html
    labels:
     - "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)"

  mailhog:
    image: mailhog/mailhog
    container_name: "${PROJECT_NAME}_mailhog"
    labels:
     - "traefik.http.services.${PROJECT_NAME}_mailhog.loadbalancer.server.port=8025"
     - "traefik.http.routers.${PROJECT_NAME}_mailhog.rule=Host(`mailhog.${PROJECT_BASE_URL}`)"

  traefik:
    image: traefik:v2.0
    container_name: "${PROJECT_NAME}_traefik"
    command: --api.insecure=true --providers.docker
    ports:
     - '8000:80'
     - '8080:8080' # Dashboard
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Contents of your .env

PROJECT_FOLDER=M:\path\to\drupal
PROJECT_NAME=tosale_drup
PROJECT_BASE_URL=tosale.docker.localhost
PROJECT_DATA=M:\databases\tosale\data
PROJECT_HOME=M:\databases\tosale\home
PROJECT_DRUPAL=M:\path\to\drupal\www
PROJECT_WEB=M:\path\to\drupal\www\web

DB_NAME=tosale_db
DB_USER=tosale
DB_PASSWORD=lettosalein
DB_ROOT_PASSWORD=root
DB_HOST=mariadb
DB_PORT=3306
DB_DRIVER=mysql
### --- MARIADB ----
MARIADB_TAG=10.5-3.12.4
### --- PHP ----
PHP_TAG=8.0-dev-4.24.6

### --- NGINX ----
NGINX_TAG=1.20-5.14.0
NGINX_VHOST_PRESET=drupal9

Logs output docker-compose logs

tosale_drup_php | NOTICE: PHP message: Error: Call to a member function setFormClass() on null in /var/www/html/web/core/modules/system/system.module on line 1200 #0 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(129): system_entity_type_build(Array)
tosale_drup_php | #1 /var/www/html/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(175): Drupal\Core\Entity\EntityTypeManager->findDefinitions()
tosale_drup_php | #2 /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(22): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
tosale_drup_php | #3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(143): Drupal\Core\Plugin\DefaultPluginManager->getDefinition('date_format', false)
tosale_drup_php | #4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(269): Drupal\Core\Entity\EntityTypeManager->getDefinition('date_format')
tosale_drup_php | #5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(208): Drupal\Core\Entity\EntityTypeManager->getHandler('date_format', 'storage')
tosale_drup_php | #6 /var/www/html/web/core/lib/Drupal/Core/Datetime/DateFormatter.php(93): Drupal\Core\Entity\EntityTypeManager->getStorage('date_format')
tosale_drup_php | #7 [internal function]: Drupal\Core\Datetime\DateFormatter->__construct(Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Language\LanguageManager), Object(Drupal\Core\StringTranslation\TranslationManager), Object(Drupal\Core\Config\ConfigFactory), Object(Symfony\Component\HttpFoundation\RequestStack))
tosale_drup_php | #8 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1144): ReflectionClass->newInstanceArgs(Array)
tosale_drup_php | #9 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(618): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'date.formatter')
tosale_drup_php | #10 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(558): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('date.formatter', 1)
tosale_drup_php | #11 /var/www/html/web/core/lib/Drupal/Core/TempStore/Element/BreakLockLink.php(87): Symfony\Component\DependencyInjection\ContainerBuilder->get('date.formatter')
tosale_drup_php | #12 /var/www/html/web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21): Drupal\Core\TempStore\Element\BreakLockLink::create(Object(Drupal\Core\DependencyInjection\ContainerBuilder), Array, 'break_lock_link', Array)
tosale_drup_php | #13 /var/www/html/web/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(83): Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('break_lock_link', Array)
tosale_drup_php | #14 /var/www/html/web/core/lib/Drupal/Core/Render/ElementInfoManager.php(141): Drupal\Component\Plugin\PluginManagerBase->createInstance('break_lock_link', Array)
tosale_drup_php | #15 /var/www/html/web/core/lib/Drupal/Core/Render/ElementInfoManager.php(111): Drupal\Core\Render\ElementInfoManager->createInstance('break_lock_link')
tosale_drup_php | #16 /var/www/html/web/core/lib/Drupal/Core/Render/ElementInfoManager.php(77): Drupal\Core\Render\ElementInfoManager->buildInfo('seven')
tosale_drup_php | #17 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(812): Drupal\Core\Render\ElementInfoManager->getInfo('form')
tosale_drup_php | #18 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(279): Drupal\Core\Form\FormBuilder->prepareForm('install_select_...', Array, Object(Drupal\Core\Form\FormState))
tosale_drup_php | #19 /var/www/html/web/core/includes/install.core.inc(942): Drupal\Core\Form\FormBuilder->buildForm('Drupal\\Core\\Ins...', Object(Drupal\Core\Form\FormState))
tosale_drup_php | #20 /var/www/html/web/core/includes/install.core.inc(1369): install_get_form('Drupal\\Core\\Ins...', Array)
tosale_drup_php | #21 /var/www/html/web/core/includes/install.core.inc(690): install_select_language(Array)
tosale_drup_php | #22 /var/www/html/web/core/includes/install.core.inc(565): install_run_task(Array, Array)
tosale_drup_php | #23 /var/www/html/web/core/includes/install.core.inc(118): install_run_tasks(Array, NULL)
tosale_drup_php | #24 /var/www/html/web/core/install.php(48): install_drupal(Object(Composer\Autoload\ClassLoader))
tosale_drup_php | #25 {main}
tosale_drup_php | 172.26.0.7 -  02/May/2021:01:00:47 +0000 "GET /core/install.php" 200
tosale_drup_nginx | 2021/05/02 01:00:51 [error] 45#45: *3 FastCGI sent in stderr: "PHP message: Error: Call to a member function setFormClass() on null in /var/www/html/web/core/modules/system/system.module on line 1200 #0 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(129): system_entity_type_build(Array)
tosale_drup_nginx | #1 /var/www/html/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(175): Drupal\Core\Entity\EntityTypeManager->findDefinitions()
tosale_drup_nginx | #2 /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(22): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
tosale_drup_nginx | #3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(143): Drupal\Core\Plugin\DefaultPluginManager->getDefinition('date_format', false)
tosale_drup_nginx | #4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(269): Drupal\Core\Entity\EntityTypeManager->getDefinition('date_format')
tosale_drup_nginx | #5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(208): Drupal\Core\Entity\EntityTypeManager->getHandler('date_format', 'storage')
tosale_drup_nginx | #6 /var/www/html/web/core/lib/Drupal/Core/Datetime/DateFormatter.php(93): Drupal\Core\Entity\EntityTypeManager->getStorage('date_format')
tosale_drup_nginx | #7 [internal function]: Drupal\Core\Datetime\DateFormatter->__construct(Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Language\LanguageManager), Object(Drupal\Core\StringTranslation\TranslationManager), Object(Drupal\Core\Config\ConfigFactory), Object(Symfony\Component\HttpFoundation\RequestStack))
tosale_drup_nginx | #8 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1144): ReflectionClass->newInstanceArgs(Array)
tosale_drup_nginx | #9 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(618): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'date.formatter')
tosale_drup_nginx | #10 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(558): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('date.formatter', 1)
tosale_drup_nginx | #11 /var/www/html/w
tosale_drup_nginx | 172.26.0.6 - - [02/May/2021:01:00:51 +0000] "GET /core/install.php HTTP/1.1" 200 1352 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36"
tosale_drup_nginx | 172.26.0.6 - - [02/May/2021:01:00:51 +0000] "GET /favicon.ico HTTP/1.1" 200 43 "http://tosale.docker.localhost:8000/core/install.php" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36"
szeidler commented 3 years ago

Could you try to disable the WSL 2 based engine in in Docker and add the project directing under Resources -> File Sharing like shown here: https://stackoverflow.com/a/62721155 ?

yzaman88 commented 2 years ago

I have the same issue and have disabled WSL 2 based engine + added project under resources > file sharing. It didn't help. Any other ideas?

szeidler commented 2 years ago

Have you tried to ouse another shell than Powershell? Does it show a different behavior?

refaelgold commented 1 year ago

@szeidler I'm tried to use it with WSL and its still didn't help. For now , We cant run doker4drupal

igorbiki commented 1 year ago

Using Terminal app on W10 works for me, using my codebase. Works nicely!

arcker commented 1 year ago

Just came here to say this. I was having the same setformclass error while using an existing drupal site ( v9.4.9 ) After 3 days i just mounter a docker in drupal with buster then i copy the existing file ( rsync ) and THEN : DRUPAL CR ( do it before any load test site !! ) after that the site just pops well i modified my docker composer for drupal as follow to make it automatic : ` drupal: image: drupal:9.4.9-apache-buster command: sh -c "./vendor/bin/drush cr && apache2-foreground" working_dir: /var/www/html

command: pwd

container_name: drupal
ports:
  - 80:80
depends_on:
  - mysql
restart: unless-stopped
networks:
  # - internal
  - external
volumes:
  -  ./volumes/drupal-data:/var/www/html`

and for developers, i just seen that you can totally disable cache : https://www.drupal.org/node/2598914

I searched anywhere and no one was mentionning this drupal cache clean.

Now our developers are working locally Windows 10 with drupal desktop

Not a docker4drupal issue imho

regards

arcker