Publishing code changes in running docker containers

Updated: Jan 23

Although, Sitecore has an official documentation on how to apply patches/code changes in running docker containers, after reviewing the official documentation, I felt that it has some extra information which as a developer we might not need when we simply want to understand how code publishing works in containerized approach.


When I first started with working with docker, publishing the code changes was the most important part of the overall development workflow as we needed it pretty much every time when we want to apply any Sitecore patch, either our custom implementation or any Sitecore hotfix.


So, I am going to try in this blog to keep the information/steps as simple as possible by explaining why we need to follow these steps & how internally docker publishes our changes to the running containers.


I am assuming in this post, that we have already created a .NET MVC Web Application project & configured it as per the Sitecore version we are using (For Eg. For Sitecore V10.x -> .NET framework 4.8) and we have necessary code written (.cs, .cshtml or .config) as per required customizations. It is also assumed that we have a basic understanding of docker-compose container structure along with basic docker structure of Sitecore solution (Getting Started Template, MVP-Site, Basic Company Site etc..) .


We can use any Sitecore topology (XM, XP). This method will be universal across any topologies also applicable for Headless Rendering SDKs(.NET Core Rendering SDK, JSS SDK) as even if we are using these SDKs, we will need to have a .NET MVC project in our solution for applying customizations when needed for patching Sitecore pipelines.


Following are the steps to be followed for publishing your code changes :


For CM container in docker-compose.override.yml file, different volumes are mapped from local Sitecore solution folders to the webroot(inetpub) folder One such important volume is website folder:

As we can see, the LOCAL_DEPLOY_PATH (/docker/deploy/website) is mapped to the (C:/deploy) folder of the cm container.


Next thing to note is for cm container we have an entrypoint for the container defined in (C:\tools\entrypoints\iis\Development.ps1).


Now if we open the PowerShell script, we can see that whatever content we have in (C:\deploy) folder gets copied into (C:\inetpub\wwwroot) folder:

As we have already seen earlier, contents of (C:/deploy) folders are mapped to the (/docker/deploy/website) folder of the local solution. So, all we need to do to apply the patch in the running container is to publish our code to this local path.


Right click on the project & click on Publish, Select Folder as a Target & click on Next:



Keep (/docker/deploy/website) as the path of the Folder location & click on finish:


Keep Configuration as Debug instead of Release. Review all configurations once & click on publish. This will build & publish your code changes to the (/docker/deploy/website) folder from where they will get copied to (C:/deploy) folder & subsequently to the webroot (C:\inetpub\wwwroot) folder.


That's it, your code changes are now published in cm running container.



93 views0 comments