The docker compose file below has additional properties defined that instruct the Docker Daemon how to build an image if the requested image does not exist.
When run, the example below, will check to see if an image exists. For example, custom-sitecore-solution:custom-tag
(remember the variables below are passed in from .env file).
If it does not exist, it will run the docker build
command, with the Dockerfile at the current location (./) and pass in the current directory as the build Context. If successful, it will then create the originally requested image (i.e. custom-sitecore-solution:custom-tag).
Note: The Scale:0 definition states that the docker-compose process should not try to instantiate a container from the created image.
The next service definition CM, also looks for an image file custom-sitecore-final-image:custom-tag, if that does not exist, it will run the docker build
command, with Dockerfile located ./docker/build/cm
. This Dockerfile then takes two arguments which specify sitecore-xm-cm as the base image and the file we just created above custom-sitecore-solution:custom-tag as the solution image). That file copies across our custom assets and code over the top of the vanilla sitecore application.
version: "2.4" docker build
services:
solution:
image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-solution:${VERSION:-latest}
build:
context: ./
args:
BASE_IMAGE: ${SOLUTION_BASE_IMAGE}
BUILD_IMAGE: ${SOLUTION_BUILD_IMAGE}
BUILD_CONFIGURATION: ${BUILD_CONFIGURATION}
scale: 0
cm:
image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm-cm:${VERSION:-latest}
ports:
- "44002:80"
build:
context: ./docker/build/cm
args:
BASE_IMAGE: sitecore-xm-cm:9.3.0-windowsservercore-ltsc2019
SOLUTION_IMAGE: ${REGISTRY}${COMPOSE_PROJECT_NAME}-solution:${VERSION:-latest}
environment:
SITECORE_LICENSE: ${SITECORE_LICENSE}
SITECORE_APPSETTINGS_ROLE:DEFINE: ContentManagement
SITECORE_CONNECTIONSTRINGS_MASTER: ${MASTER}
SITECORE_CONNECTIONSTRINGS_CORE: ${CORE}
SITECORE_CONNECTIONSTRINGS_SECURITY: ${SECURITY}
SITECORE_CONNECTIONSTRINGS_WEB: ${WEB}
SITECORE_CONNECTIONSTRINGS_EXPERIENCEFORMS: ${FORMS}
SITECORE_CONNECTIONSTRINGS_REPORTING: ${REPORTING}
SITECORE_CONNECTIONSTRINGS_SOLR.SEARCH: ${SOLR}
ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED: 'true'
ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED: 'true'
ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED: 'true'
volumes:
- ${LOCAL_DEPLOY_PATH}\website:C:\deploy
- ${LOCAL_DATA_PATH}\cm:C:\inetpub\wwwroot\App_Data\logs