Sitecore Module with Docker


The adoption of containers with Sitecore for both development and production purposes has been growing rapidly over the past few years, and is now a fully supported option even with mainstream support from Sitecore. There are a number of benefits of using containers, more information is available in the documentation.

When using containers, the installation process for modules requires a different approach. The SearchStax for Sitecore Docker images have been built using the recommended format for Sitecore Docker modules, and follow the same structure as other asset type images (e.g. SXA, SPE).

You can find the details of the images in Docker Hub: https://hub.docker.com/u/searchstaxinc

Adding the SearchStax image layer

The module is layered in the same way as all other Sitecore modules and asset images. You must set the environment variables to match your SearchStax instance, update your Docker build files to layer in the module and configure the Docker compose files to utilise these.

Populate the environment variables

In your .env file set the following unassigned variables:

SEARCHSTAX_VERSION=1.4.1-10.2-ltsc2019
SEARCHSTAX_SXA_VERSION=1.4.1-ltsc2019
SEARCHSTAX_ROOT_ITEM=
SEARCHSTAX_SEARCH_ENDPOINT=
SEARCHSTAX_SUGGEST_ENDPOINT=
SEARCHSTAX_AUTH_BASIC_TOKEN=
SEARCHSTAX_ADMIN_AUTH_BASIC_TOKEN=
SEARCHSTAX_SOLR_USERNAME=
SEARCHSTAX_SOLR_PASSWORD=
SEARCHSTAX_ADMIN_SOLR_USERNAME=
SEARCHSTAX_ADMIN_SOLR_PASSWORD=
SEARCHSTAX_ANALYTICS_APIKEY=
SEARCHSTAX_INDEX_CORE_NAME=
SEARCHSTAX_DATABASE=

Please update all the required values for your configuration for your SearchStax instance.

Update your Dockerfiles

You can read more about the Sitecore runtime Dockerfiles in the Sietcore documentation. The SearchStax for Sitecore module follows the same set of basic instructions.

For the CM container modify the Dockerfile to match the following, the new lines have been highlighted (<–).

If you are not using SXA then you do not need to add the SXA layers below.

# escape=`
 
ARG BASE_IMAGE
ARG SXA_IMAGE
ARG SPE_IMAGE
ARG TOOLING_IMAGE
ARG SEARCHSTAX_IMAGE       <--
ARG SEARCHSTAX_SXA_IMAGE   <--
 
FROM ${TOOLING_IMAGE} as tooling
FROM ${SPE_IMAGE} as spe
FROM ${SXA_IMAGE} as sxa
FROM ${SEARCHSTAX_IMAGE} as searchstax          <--
FROM ${SEARCHSTAX_SXA_IMAGE} as searchstaxsxa   <--
FROM ${BASE_IMAGE}
 
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
 
# Copy development tools and entrypoint
COPY --from=tooling \tools\ \tools\
 
WORKDIR C:\inetpub\wwwroot
 
# Add SPE module
COPY --from=spe \module\cm\content .\
 
# Add SXA module
COPY --from=sxa \module\cm\content .\
COPY --from=sxa \module\tools \module\tools
RUN C:\module\tools\Initialize-Content.ps1 -TargetPath .\; `
    Remove-Item -Path C:\module -Recurse -Force;
 
# Add SearchStax module
COPY --from=searchstax \module\cm\content .\      <--
COPY --from=searchstaxsxa \module\cm\content .\   <--

For the CD container modify the Dockerfile to match the following, the new lines have been highlighted (<–)

# escape=`
 
ARG BASE_IMAGE
ARG SXA_IMAGE
ARG TOOLING_IMAGE
ARG SEARCHSTAX_IMAGE       <--
ARG SEARCHSTAX_SXA_IMAGE   <--
 
FROM ${TOOLING_IMAGE} as tooling
FROM ${SXA_IMAGE} as sxa
FROM ${SEARCHSTAX_IMAGE} as searchstax          <--
FROM ${SEARCHSTAX_SXA_IMAGE} as searchstaxsxa   <--
FROM ${BASE_IMAGE}
 
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
 
# Copy development tools and entrypoint
COPY --from=tooling \tools\ \tools\
 
WORKDIR C:\inetpub\wwwroot
 
# Add SXA module
COPY --from=sxa \module\cm\content .\
COPY --from=sxa \module\tools \module\tools
RUN C:\module\tools\Initialize-Content.ps1 -TargetPath .\; `
    Remove-Item -Path C:\module -Recurse -Force;
 
# Add SearchStax module
COPY --from=searchstax \module\cd\content .\      <--
COPY --from=searchstaxsxa \module\cd\content .\   <--
For the mssql container modify the Dockerfile to match the following, the new lines have been highlighted (<--)
# escape=`
 
ARG BASE_IMAGE
ARG SXA_IMAGE
ARG SPE_IMAGE
ARG SEARCHSTAX_IMAGE       <--
ARG SEARCHSTAX_SXA_IMAGE   <--
 
FROM ${SPE_IMAGE} as spe
FROM ${SXA_IMAGE} as sxa
FROM ${SEARCHSTAX_IMAGE} as searchstax          <--
FROM ${SEARCHSTAX_SXA_IMAGE} as searchstaxsxa   <--
FROM ${BASE_IMAGE}
 
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
 
# Add SPE module
COPY --from=spe \module\db \spe_data
RUN C:\DeployDatabases.ps1 -ResourcesDirectory C:\spe_data; `
    Remove-Item -Path C:\spe_data -Recurse -Force;
 
# Add SXA module
COPY --from=sxa \module\db \sxa_data
RUN C:\DeployDatabases.ps1 -ResourcesDirectory C:\sxa_data; `
    Remove-Item -Path C:\sxa_data -Recurse -Force;
 
# Add SearchStax module                                                <--
COPY --from=searchstax \module\db \searchstax_data                     <--
RUN C:\DeployDatabases.ps1 -ResourcesDirectory C:\searchstax_data; `   <--
    Remove-Item -Path C:\searchstax_data -Recurse -Force;              <--
 
# Add SearchStax SXA module                                               <--
COPY --from=searchstaxsxa \module\db \searchstaxsxa_data                  <--
RUN C:\DeployDatabases.ps1 -ResourcesDirectory C:\searchstaxsxa_data; `   <--
    Remove-Item -Path C:\searchstaxsxa_data -Recurse -Force;              <--

Docker Compose File

In your docker-compose.override.yml update the mssql container args to include:

SEARCHSTAX_IMAGE: searchstaxinc/searchstax-for-sitecore:${SEARCHSTAX_VERSION}
SEARCHSTAX_SXA_IMAGE: 

Update the cd and cm containers args to include:

SEARCHSTAX_IMAGE: searchstaxinc/search-stax-sitecore:${SEARCHSTAX_VERSION}
SEARCHSTAX_SXA_IMAGE: searchstaxinc/search-stax-sitecore-sxa:${SEARCHSTAX_SXA_VERSION}

and the environment section to include:

SearchStax_RootItem: ${SEARCHSTAX_ROOT_ITEM}
SearchStax_SearchEndPoint: ${SEARCHSTAX_SEARCH_ENDPOINT}
SearchStax_SuggestEndPoint: ${SEARCHSTAX_SUGGEST_ENDPOINT}
SearchStax_AuthenticationBasicToken: ${SEARCHSTAX_AUTH_BASIC_TOKEN}
SearchStax_AdminAuthenticationBasicToken: ${SEARCHSTAX_ADMIN_AUTH_BASIC_TOKEN}
SearchStax_SolrUsername: ${SEARCHSTAX_SOLR_USERNAME}
SearchStax_SolrPassword: ${SEARCHSTAX_SOLR_PASSWORD}
SearchStax_AdminSolrUsername: ${SEARCHSTAX_ADMIN_SOLR_USERNAME}
SearchStax_AdminSolrPassword: ${SEARCHSTAX_ADMIN_SOLR_PASSWORD}
SearchStax_AnalyticsApiKey: ${SEARCHSTAX_ANALYTICS_APIKEY}
SearchStax_IndexCoreName: ${SEARCHSTAX_INDEX_CORE_NAME}
SearchStax_Database: ${SEARCHSTAX_DATABASE}

Disabling the health check

For local development, the default Sitecore health check needs to be disabled to make sure that the Search Stax index doesn’t fail the health check. This is recommended anyway to getting meaningful messages due to any startup errors.

traefik:
    depends_on:
      cm:
        condition: service_started
 
  cm:
    healthcheck:
      test: ["CMD", "powershell", "-command", "exit 0"]