Search code examples
solrtypo3ddev

How to set up Solr server for TYPO3 using DDEV?


I have TYPO3 development environment set up using DDEV. Now I want to add Solr server to it, and use Ext:Solr extension for indexing and searching.

How can I set up Solr server to be available from the ddev web container?


Solution

  • EDIT: The instruction how to configure Solr Server for TYPO3 has been included in the official ddev-contrib repository, and can be found here: https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/typo3-solr

    The original answer:

    In order to configure Solr server for TYPO3 using DDEV you need to follow these steps:

    1. Configure Solr container

      Create .ddev/docker-compose.solr.yaml file:

      version: '3.6'
      
      services:
        solr:
          container_name: ddev-${DDEV_SITENAME}-solr
          image: typo3solr/ext-solr:10.0.1
          restart: "no"
          ports:
            - 8983
          labels:
            com.ddev.site-name: ${DDEV_SITENAME}
            com.ddev.approot: $DDEV_APPROOT
          environment:
            - VIRTUAL_HOST=$DDEV_HOSTNAME
            - HTTP_EXPOSE=8983
          volumes:
            - "./solr:/opt/solr/server/solr"
            # If you want your solr to persist over `ddev stop` and `ddev start` then uncomment the following line
            # If you uncomment it and want to flush your data you have to `ddev stop` and then
            # `docker volume rm ddev-<projectname>_solrdata` to destroy it.
      #      - solrdata:/var/solr
        web:
          links:
            - solr:$DDEV_HOSTNAME
      
      volumes:
        # solrdata is a persistent Docker volume for this project's solr data
        solrdata:
      

      For more details about the configuration, take a look at ddev documentation: https://ddev.readthedocs.io/en/latest/users/extend/custom-compose-files/

      This configuration will create Solr container and make Solr admin panel being available through http://<project-name>.ddev.local:8983/solr/ from your host machine.

    2. Copy default Solr configuration from Ext:Solr to ddev

      Create the folder path .ddev/solr. Then copy the Solr configuration and cores configuration from typo3conf/ext/solr/Resources/Private/Solr to .ddev/solr.

      So you should have a structure under .ddev/solr:

      • /solr.xml
      • /cores/
      • /configsets/
    3. Configure TYPO3 to access Solr

      You can do it using TypoScript:

      plugin.tx_solr {
       solr {
         host = solr
         port = 8983
         path = /solr/core_en/
       }
      }