Saturday, August 10, 2019

Local Docker Registry for Sitecore Images

    There are a lot of articles how to run Sitecore on Docker. But no one explain, how it is possible to do without paid account on Docker hub(or alternative).
    If for some reasons, you don't want to use Docker Hub(or alternative) for hosting your Sitecore images and want to host them locally, this article is for you. Here are steps that you need to achieve it:
  1. Run registry-windows container. It will be your local "Docker Hub".
    docker run -d -p 5000:5000 --restart=always --name registry -v D:\registry:C:\registry stefanscherer/registry-windows:2.6.2 

    Where:
    5000:5000  is mapping your local port to the port inside container

    --name registry is setting name to "registry" of your container.

    stefanscherer/registry-windows:2.6.2 is image name(version tag is optional). As you will run Sitecore containers in Windows mode then it makes sense to run registry which is Windows container.

     D:\registry:C:\registry  is mapping your local "D:\registry" folder to folder "C:\registry" inside container. It is required to save all your work if something go wrong. All your images in your local registry will be saved on your drive, not inside the registry container. 
  2. Verify that your registry container is up and running. You can check it by opening URL: http://localhost:5000/v2/_catalog. Expected result: Empty JSON response. 
  3. Modify your build.ps1 that will be used to build Sitecore images. You need to add -Registry "localhost:5000" parameter to make sure that your images will be pushed to your local repository.
  4. Run building and pushing Sitecore images (build.ps1).  It will take sometime.
  5. Verify that you get images in your local repository. Open URL: http://localhost:5000/v2/_catalog. It should return something like this, depending on your build.ps1:
  6. Configure docker to use local registry:
  7. Now you are ready to download Sitecore images from local registry and run them in containers.

Friday, July 19, 2019

Small Remark about Sitecore Agents

It is possible to create Sitecore agents that could be configured via parameters from configuration files. E.g.:

  <agent type="YourNamespace.SomeAgent" method="Run" interval="00:05:00">
    <param desc="database">master</param>
    <param desc="website">shell</param>
  </agent>

and you have constructor to initialize agent: SomeAgent(string database, string website).

Desc attribute in configuration is used only for description of parameter. And if you occasionally change order in configuration file, you will get different order in your constructor. Database will become website. Website will become database.

So, here is reminder: order of parameters in configuration of Sitecore agents matters. Desc attribute is used only for information and nothing else.