Latest changes in Sitecore MVP Site Docker setup + few minor issues/fixes

Going forward,  if you want to start your local Docker sitecore mvp site, you need to use the new Start-Environment.ps1 instead of up.ps1. Like me, if you have an existing folder and pull the latest code from github, you definitely will have a few hiccups and this blog article is for you.

So, making the long story short, I pulled the main branch and I noticed there is no up.ps1 and instead there is Start-Environment.ps1 and Stop-Environment.ps1. 

The Stop-Environment.ps1 script is straight forward, it does a system prune too:

Next, as any lazy developer, I want to see everything work fine with my existing folder setup. So, I executed Start-Environment.ps1 on the existing folder in my machine just passing this one argument:

.\start-environment.ps1  

The first error I hit was this:

Initialize-HostNames : Cannot validate argument on parameter 'HostDomain'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command

again.

At C:\mvp-site\Start-Environment.ps1:62 char:26

+     Initialize-HostNames $HostDomain

+                          ~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Initialize-HostNames], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationError,Initialize-HostNames


The reason for  this error is, my existing .env file (classic lazy developer!) didn't have the HOST_DOMAIN key and the Start-Environment.ps1 looks for such a key as per this line:


Note that the key is added automatically if you setup everything from scratch:


But, since I'm lazy, I added the key with the following value to .env file matching how the certs are already generated in my machine under the traefik folder:

HOST_DOMAIN=sc.localhost



Now, when I execute the following command, everything seems fine:

.\start-environment.ps1  


After some patience, containers are up and running:


But, Docker is unable to access the id instance:


Error connecting to https://id.sc.localhost/.well-known/openid-configuration: No such host is known.

Push-Items : Unable to log into Sitecore, did the Sitecore environment start correctly? See logs above.

At C:\mvp-site\Start-Environment.ps1:99 char:1

+ Push-Items -IdHost "https://id.$($HostDomain)" -CmHost "https://cm.$( ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException

    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Push-Items


Straightaway, you can figure out that the mvp prefix is missing for the id instance. So, I located the concerned lines in Start-Environment.ps1 and rectified the same:

I also adjusted the ComposeProjectName since it is used all through the code to build the host domain:


Note: Adjust license path to c:\license if you are like me and have such a folder, across all your machines!

.\Start-Environment.ps1  was successful this time!


I raised a pull request for these minor fixes in Start-Environment.ps1 and should be resolved if they are merged else, bookmark this blog article!

Note that in case of a brand new setup, if you execute .\Start-Environment.ps1 -InitializeEnvFile, you get the option to setup everything from scratch including OKTA:


But, during CLI push, the id instance will still not be reachable.

Also, the following entries need to be adjusted since they get defaulted in the .env file:



The Pull Request covers this one too.

Params in Start-Environment.ps1:

    $ComposeProjectName:  For first time setup, good to pass "sc" keeping up with sc.localhost domain

    $LicensePath:  For first time setup

    $InitializeEnvFile:  For first time setup, OKTA configuration is part of it

    $Pull: Switch that pulls latest SCR images

    $Clean: No need to run clean.ps1 from docker folder anymore

    $StartSugconSites: Switch ($true or $false) value to start sugcon site

    $StartmvpSite: Switch ($true or $false) value to start mvp site

Comments

Popular Posts