contentacms / contenta_jsonapi

Contenta CMS, the decoupled Drupal
http://www.contentacms.org/
GNU General Public License v2.0
328 stars 103 forks source link

Ensure Contenta can run with DDEV (or other local stacks) #360

Closed mglaman closed 6 months ago

mglaman commented 5 years ago

The project template does not have issues available, so posting one about https://github.com/contentacms/contenta_jsonapi_project here.

Profiles, can define config_install: true, which imports CONFIG_SYNC_DIRECTORY on install. Contenta has this option enabled and the config in its directory. This allows it to install like a SaaSy install of Drupal.

But DDEV provides an auto-definition of $config_directories if it does not yet exist when settings.ddev.php is loaded. This causes everything to explode 💥 when running DDEV and Contenta.

My proposed fix is to ensure that Contenta ships with a settings.php that points the $config_directories to the profile location

The default ScriptHandler for drupal-project Composer template does this. We customized it for our own Drupal Commerce demo, as well

https://github.com/drupalcommerce/demo-project/blob/master/scripts/composer/ScriptHandler.php#L51

I'll work on a PR to provide a fix for the project template.

mglaman commented 5 years ago

Actually. I think the fix is to just define config_install_path. Per drupal_install_config_directories:

It will respect the defined path.

  if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
    if (empty($install_state['config_install_path'])) {
      // Add a randomized config directory name to settings.php
      $config_directories[CONFIG_SYNC_DIRECTORY] = \Drupal::service('site.path') . '/files/config_' . Crypt::randomBytesBase64(55) . '/sync';
    }
    else {
      // Install profiles can contain a config sync directory. If they do,
      // 'config_install_path' is a path to the directory.
      $config_directories[CONFIG_SYNC_DIRECTORY] = $install_state['config_install_path'];
    }
    $settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
      'value' => $config_directories[CONFIG_SYNC_DIRECTORY],
      'required' => TRUE,
    ];
    // Rewrite settings.php, which also sets the value as global variable.
    drupal_rewrite_settings($settings);
  }
mglaman commented 5 years ago

I think the fix is just adding config_install_path: web/profiles/contrib/contenta_jsonapi/config/sync in the .info.yml; needs manual testing.

hyperfocus1337 commented 5 years ago

Is this also a fix for https://github.com/contentacms/contenta_jsonapi/issues/353? Did you manage to install contenta CMS reliably with ddev?

mglaman commented 5 years ago

@SuperNami I just reposted here from someone on Slack that was having issues and offered to open an issue. It looks like your solution and notes in #353 are exactly what's required.

I'd like to just open a PR which ensures the settings.php has proper values instead of just being a copied file.

andy-blum commented 3 years ago

@mglaman I tried pasting your snippet from 4/24/19 into the .info.yml file and I'm still getting the error

"The configuration synchronization failed validation. This import is empty and if applied would delete all of your configuration, so has been rejected."