Skip to content

Local development

Chris Lai edited this page May 29, 2024 · 5 revisions

Note: These instructions are for local development specific to the data catalogue.

Getting started

  1. Follow the instructions for setting up a site locally with ddev except instead of creating a new Git repo and downloading the bcbb-template Composer file into it, clone the MFIN-Data-Catalogue repo. Configure config sync.
  2. Get a copy of the database from another environment

    Note: we should have a section on how to get a copy of the DB out of OpenShift. Is this something Chris could contribute?

  3. ddev import-db --src=/path-to-where-i-saved-the-db/myDb.sql.gz //import the db
  4. ddev drush cr // clear caches
  5. ddev drush cim -y // import configurations (config sync)
  6. ddev launch // launch the site

Import files

This step is optional. Usually you can do development work without getting the files.

  1. get a copy of the files from another environment

    Note: we should have a section on how to get a copy of the files out of OpenShift. Is this something Chris could contribute?

  2. ddev import-files --src=/path-to-where-i-saved-the-files //import the files
  3. ddev drush cr // clear caches

Important

Files and data-bases are brought in for development. They are never pushed upstream.

Update an existing local site

  1. git pull // get the latest
  2. ddev composer install // get any new modules or patches
  3. ddev start // ddev has to be running
  4. ddev drush cr // clear caches
  5. ddev drush cim // bring in any new config

Importing a database from OpenShift

  1. Login to OpenShift CLI with the OpenShift token
  2. oc project [project licence plate] // go to the project
  3. (oc exec -i deployment/mfin-data-catalogue-drupal -- pg_dump --no-owner --no-acl -h $DBHOST -U $DBUSER $DBNAME | grep -v "EXTENSION.*pgaudit") > "database-$1-$2.sql"

Additional packages

The feature to download search results requires php8.1-zip. To make it available in your project:

  1. starting at the root of your project, edit .ddev/config.yaml
  2. add the line webimage_extra_packages: [php8.1-zip]
  3. save
  4. ddev restart // in terminal

Add Solr

These instructions assume:

  1. You have a local instance of MFIN-Data-Catalogue running locally
  2. You are working with the latest release of the repo, this has the necessary Solr modules and config.

This will install Solr for Drupal 9^. It has been tested and works with Drupal 10.1.0.

  1. ddev get ddev/ddev-drupal9-solr && ddev restart at the root of your project (see ddev-drupal9-solr)
  2. ddev describe // see that solr service is running.

Solr settings in settings.local.php

There are no Solr credentials tracked in git. The easiest way to manage the local Solr connection is to add it to the local settings file.

If you are using the default ddev Solr set-up, add this to /html/sites/default/settings.local.php.

 // Solr server
$config['search_api.server.solr'] = [
  'backend_config' => [
    'connector' => 'basic_auth',
    'connector_config' => [
      'scheme' => 'http',
      'host' => 'solr',
      'core' => 'dev',
      'port' => '8983',
    ],
  ],
];

Before you see any search results, you will need to index the site so Solr can build a DB. You can do this at https://mySite.ddev.site/admin/config/search/search-api/index/default_index