We recently changed the way we deploy our Drupal site on our testing environment to a docker image.
The issue is that we were using a file based configuration. The current applied configuration is not deployed with the image, only the expected configuration. So we end up with a docker container with an empty active folder and a sync folder with the latest configuration.
As a result, running drush ci
crashes as it tries to create everything anew on a database on which was already applied most of the configuration.
Our strategy was to go back to a database based configuration (the default of Drupal). We tried this. The results were a broken website and it was impossible to run the drush cr
anymore.
Crash when running drush cr
:
root@7ef127fc56af:/var/www/CMS# vendor/bin/drush cr PHP Fatal error: Call to undefined function system_rebuild_module_data() in /var/www/CMS/web/core/includes/common.inc on line 1136 PHP Stack trace: PHP 1. {main}() /var/www/CMS/vendor/drush/drush/drush:0 PHP
2. require() /var/www/CMS/vendor/drush/drush/drush:4 PHP 3. Drush\Runtime\Runtime->run() /var/www/CMS/vendor/drush/drush/drush.php:66 PHP 4. Drush\Runtime\Runtime->doRun() /var/www/CMS/vendor/drush/drush/src/Runtime/Runtime.php:41 PHP 5. Symfony\Component\Console\Application->run() /var/www/CMS/vendor/drush/drush/src/Runtime/Runtime.php:112 PHP 6. Symfony\Component\Console\Application->doRun() /var/www/CMS/vendor/symfony/console/Application.php:148 PHP 7. Symfony\Component\Console\Application->doRunCommand() /var/www/CMS/vendor/symfony/console/Application.php:255 PHP 8. Symfony\Component\Console\Command\Command->run() /var/www/CMS/vendor/symfony/console/Application.php:978 PHP 9. Consolidation\AnnotatedCommand\AnnotatedCommand->execute() /var/www/CMS/vendor/symfony/console/Command/Command.php:255 PHP 10. Consolidation\AnnotatedCommand\CommandProcessor->process() /var/www/CMS/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:405 PHP 11. Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() /var/www/CMS/vendor/consolidation/annotated-command/src/CommandProcessor.php:151 PHP 12. Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() /var/www/CMS/vendor/consolidation/annotated-command/src/CommandProcessor.php:181 PHP 13. call_user_func_array:{/var/www/CMS/vendor/consolidation/annotated-command/src/CommandProcessor.php:235}() /var/www/CMS/vendor/consolidation/annotated-command/src/CommandProcessor.php:235 PHP 14. Drush\Commands\core\CacheCommands->rebuild() /var/www/CMS/vendor/consolidation/annotated-command/src/CommandProcessor.php:235 PHP 15. drupal_rebuild() /var/www/CMS/vendor/drush/drush/src/Commands/core/CacheCommands.php:203 PHP 16. drupal_flush_all_caches() /var/www/CMS/web/core/includes/utility.inc:52 [error] Drush command terminated abnormally due to an unrecoverable error. Error: Call to undefined function system_rebuild_module_data() in /var/www/CMS/web/core/includes/common.inc, line 1136
Questions:
- Did we choose the right solution by trying to fallback on a database based configuration, or is there a better idea?
We could find a way to keep the active configuration saved and put it back after each deployment, however, we use different technologies on our environments (for example we use docker for our testing environment), at first glance it seems quite complex to me.
- How can we change to a database based configuration?
Environment:
root@7ef127fc56af:/var/www/CMS# vendor/bin/drush status
Drupal version : 8.7.12
Site URI : default
DB driver : mysql
DB hostname : __DB_HOST__
DB port :
DB username : __DB_USER__
DB name : __DB_NAME__
PHP binary : /usr/bin/php5.6
PHP config : /etc/php/5.6/cli/php.ini
PHP OS : Linux
Drush script : /var/www/CMS/vendor/bin/drush
Drush version : 9.3.0
Drush temp : /tmp
Drush configs : /var/www/CMS/vendor/drush/drush/drush.yml
/var/www/CMS/drush/drush.yml
Drupal root : /var/www/CMS/web
Site path : sites/default
drush cex
and commit them insync
. When I deploy, I only deploy the content ofsync
. Since we're using a file based configuration, to import the new configuration, Drupal looks at the diff between active/sync. Sinceactive
is not commited (as it's environment related), it's empty. So the diff is actually the fullsync
folder – Gabriel Sep 4 '20 at 12:03