Auto-Fill the .env file for Sitecore XC 10 Docker Container Installation (XC0 topology)

One of the important pre-requisites for setting up Sitecore Commerce Docker Container for developer workstation is to fill the .env file necessary for docker-compose up.


The XC Installation Guide for Developer Workstation with Containers  provides  UpdateEnvCompose.ps1 for this purpose:

The above cmdlet expects the parameter values like the secrets and certificates as cmd line arguments but this is multi-step: You have to first generate the random/encoded values and then fill those manually.

A better approach would be auto-generate the values and auto-copy those to the .env file similar to init.ps1 in the examples github repo created by Nick Wesselman.

So, created the init-setup.ps1 specific for XC Containers installation. This powershell script not only generates random/encoded values but also copies necessary values to the .env file then goes ahead and creates the Docker container volumes under c:\containers folder. 

Here is the gist of the script:

1. Generates random/encoded strings based on length specified in XC Installation Guide for Developer Workstation with Containers  for keys and secrets

2. Downloads mkcert.exe and creates the necessary TLS\HTTPS certificates under .\traefik\certs folder 

3. Copies the generated random/encoded values onto the .env file - secrets, passwords, license and certificate 

4. Adds necessary host file entries

5. Creates the necessary Docker container volumes under c:\containers folder (the CreateVolumeFolders.ps1 script for this must be under scripts folder) -


Now, execute the script in PS: 

Docker Container Volumes created successfully:

Auto-Filled .env file:

If using the scripts, be sure to modify the cert names and host file entries (specific to your domain names) or pass these as parameters after making the script generic:


Also, ensure that the rounded dns name (below) matches your identity server domain name:


Note that the root-ca security certificate is created under .\traefik\certs. This must be installed under Trusted Root Certification Authority.

If the dns name doesn't match the host file entry, you will get a certificate error (similar to the one below) while accessing the site (after docker-compose up and the site is created - more about XC site creation in a separate blog) -


Happy Dockering while Sitecoring!

Comments

Popular Posts