From 07461123332e3971a7c7686a1a8995f3afaf2db7 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 29 May 2023 13:08:20 +1000 Subject: [PATCH 01/12] Setup MVP appsettings ready to automatic config of edge mode without docker --- .../MvpSite/rendering/appsettings.Development.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Project/MvpSite/rendering/appsettings.Development.json b/src/Project/MvpSite/rendering/appsettings.Development.json index c24ac36f..8b208571 100644 --- a/src/Project/MvpSite/rendering/appsettings.Development.json +++ b/src/Project/MvpSite/rendering/appsettings.Development.json @@ -14,5 +14,14 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "Okta" : { + "OktaDomain": "<>", + "ClientId": "<>", + "ClientSecret": "<>", + "AuthorizationServerId": "<>" + }, + "MvpSelectionsApiClient": { + "BaseAddress": "<>" + } } From 1956ba050ce1e1b7e6175f52ee48da34d3529532 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 29 May 2023 13:21:32 +1000 Subject: [PATCH 02/12] Configured init.ps1 for EdgeNoDocker mode for the MVP site, updated Readme to include steps --- README.md | 25 +++++++++++-- init.ps1 | 107 +++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 99 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 821e770d..6618593b 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ Examples of how to use them can be seen in the different setup guides for both L | SUCGON_INDIA_CDP_CLIENT_KEY | No | No | CDP Client key for SUGCON India Site | | SUCGON_INDIA_CDP_TARGET_URL | No | No | CDP Target URL for SUGCON India Site | | SUCGON_INDIA_CDP_POINTOFSALE | No | No | CDP POS for SUGCON India Site | +| EdgeNoDocker | No | No | Used to initialise the repo for Edge Developer without Docker | + ## Embeded Personalisation Embedded Personalisation is disabled locally by default. If you wish to enable it you will need to populate the different `xx_CDP_CLIENT_KEY`, `xx_CDP_TARGET_URL` & `xx_CDP_POINTOFSALE` parameters with valid values and change the `NODE_ENV` parameter from `development` to another value. @@ -98,7 +100,7 @@ Next, use the `up.ps1` script to bring up all of the containers required for Loc ## 🐋+🌏 Running in Edge Development Mode with Docker Running in Edge Mode with Docker will run only run the Head applications and Traefik. To be able to run the sites in this repository locally against Edge, you will need to have access to an active XM Cloud Subscription with enough entitlements to be able to create a new Project & Environment to run against. -## Create a new environment and deploy the codebase +### Create a new environment and deploy the codebase You can follow these steps to create a new XM Cloud Project & Environment, then generate an Edge Token used to authenticate your Head applications with your Edge Tenant. - Authenticate with the XM Cloud Deploy Application - `dotnet sitecore cloud login` @@ -121,10 +123,10 @@ If you want more information about the Cloud plugin for the CLI then you access First initialize your repo using the `.init/ps1` script, you will need to pass in the `-Edge_Token` parameter set to the value you generated in the previous step. ```ps1 -.\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword" --Edge_Token "<>" +.\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword" -Edge_Token "<>" ``` -## Bring up all the application elements for Edge Mode with Docker +### Bring up all the application elements for Edge Mode with Docker Once you have initialized the repository with your Edge Token, use the `up.ps1` script, ensuring to pass the `-UseEdge` parameter to bring up all of the containers required for Edge Mode. ```ps1 @@ -132,4 +134,19 @@ Once you have initialized the repository with your Edge Token, use the `up.ps1` ``` ## 💻+🌏 Running in Edge Development Mode without Docker -Coming soon... + +### Initialize your repository for Edge Development Mode with Docker +First initialize your repo using the `.init/ps1` script, you will need to pass in the `-Edge_Token` & `-EdgeNoDocker` parameters to ensure that the repository is correct initialised. + +```ps1 +.\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword" -Edge_Token "<>" - EdgeNoDocker +``` + +Running with the `-EdgeNoDocker` switch, will setup configuration files for each of the heads included in this repository. You can then manually run each of them using either NPM or DotNet. + +### Running the MVP Site + +After completing the init setup above you will be able to run the MVP Site either directly from within Visual Studio, or by using the DotNet CLI. + +- To run from within Visual Studio, open the `src\XmCloudIntroduction.sln`, ensure that the `Mvp.Project.MvpSite.Rendering` project is set as your StartUp Project, then hit F5. +- To run from the DotNet CLI, open a new terminal window and navigate to the `src\Project\MvpSite\rendering` folder, then run `dotnet run` diff --git a/init.ps1 b/init.ps1 index 822265ec..97c91f16 100644 --- a/init.ps1 +++ b/init.ps1 @@ -34,7 +34,9 @@ Param ( [Parameter(HelpMessage = "SUGCON INDIA CPD Target URL.")] [string]$SUCGON_INDIA_CDP_TARGET_URL, [Parameter(HelpMessage = "SUGCON INDIA CPD Point of Sale.")] - [string]$SUCGON_INDIA_CDP_POINTOFSALE + [string]$SUCGON_INDIA_CDP_POINTOFSALE, + [Parameter(HelpMessage = "Switch to setup the heads to run against edge without docker.")] + [switch]$EdgeNoDocker ) $ErrorActionPreference = "Stop"; @@ -96,34 +98,34 @@ $SUGCON_INDIA_HOST = "sugconindia.$Host_Suffix" ################################## # Configure TLS/HTTPS certificates ################################## -Push-Location docker\traefik\certs -try { - $mkcert = ".\mkcert.exe" - if ($null -ne (Get-Command mkcert.exe -ErrorAction SilentlyContinue)) { - # mkcert installed in PATH - $mkcert = "mkcert" - } elseif (-not (Test-Path $mkcert)) { - Write-Host "Downloading and installing mkcert certificate tool..." -ForegroundColor Green - Invoke-WebRequest "https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-windows-amd64.exe" -UseBasicParsing -OutFile mkcert.exe - if ((Get-FileHash mkcert.exe).Hash -ne "1BE92F598145F61CA67DD9F5C687DFEC17953548D013715FF54067B34D7C3246") { - Remove-Item mkcert.exe -Force - throw "Invalid mkcert.exe file" - } - } - Write-Host "Generating Traefik TLS certificate." -ForegroundColor Green - & $mkcert -install - & $mkcert "*.$Host_Suffix" - & $mkcert $Host_Suffix +# Push-Location docker\traefik\certs +# try { +# $mkcert = ".\mkcert.exe" +# if ($null -ne (Get-Command mkcert.exe -ErrorAction SilentlyContinue)) { +# # mkcert installed in PATH +# $mkcert = "mkcert" +# } elseif (-not (Test-Path $mkcert)) { +# Write-Host "Downloading and installing mkcert certificate tool..." -ForegroundColor Green +# Invoke-WebRequest "https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-windows-amd64.exe" -UseBasicParsing -OutFile mkcert.exe +# if ((Get-FileHash mkcert.exe).Hash -ne "1BE92F598145F61CA67DD9F5C687DFEC17953548D013715FF54067B34D7C3246") { +# Remove-Item mkcert.exe -Force +# throw "Invalid mkcert.exe file" +# } +# } +# Write-Host "Generating Traefik TLS certificate." -ForegroundColor Green +# & $mkcert -install +# & $mkcert "*.$Host_Suffix" +# & $mkcert $Host_Suffix - # stash CAROOT path for messaging at the end of the script - $caRoot = "$(& $mkcert -CAROOT)\rootCA.pem" -} -catch { - Write-Error "An error occurred while attempting to generate TLS certificate: $_" -} -finally { - Pop-Location -} +# # stash CAROOT path for messaging at the end of the script +# $caRoot = "$(& $mkcert -CAROOT)\rootCA.pem" +# } +# catch { +# Write-Error "An error occurred while attempting to generate TLS certificate: $_" +# } +# finally { +# Pop-Location +# } ################################ # Add Windows hosts file entries @@ -189,6 +191,52 @@ if ($InitEnv) { } Write-Host "Finished populating .env file." -ForegroundColor Green +################################## +# Configure/Reset EdgeNoDockerMode +################################## +if ($EdgeNoDocker) { + + # Ensure Edge token is passed in when attempting to setup Edge Mode without Docker + if($Edge_Token -eq "") + { + Write-Error "Edge Token is required when running in Edge Mode without Docker" + exit -1 + } + + Write-Host "Configuring heads to run in Edge Mode without Docker" -ForegroundColor Green + + # Read .env into PS runtime for each access + get-content .env | ForEach-Object { + if(-Not $_.StartsWith("#") -and -Not $_ -eq "") { + $splitChar = $_.IndexOf('=') + $name = $_.Substring(0, $splitChar) + $value = $_.Substring($splitChar + 1) + set-content env:\$name $value + } + } + + Write-Host "Configuring MVP Head" + $appSettings = Get-Content 'src/Project/MvpSite/rendering/appsettings.Development.json' | ConvertFrom-Json + $appSettings.Sitecore.InstanceUri = $env:EXPERIENCE_EDGE_URL + $appSettings.Sitecore.LayoutServicePath = "/api/graphql/v1" + $appSettings.Sitecore.ExperienceEdgeToken = $env:EXPERIENCE_EDGE_TOKEN + $appSettings.Okta.OktaDomain = $env:OKTA_DOMAIN + $appSettings.Okta.ClientId = $env:OKTA_CLIENT_ID + $appSettings.Okta.ClientSecret = $env:OKTA_CLIENT_SECRET + $appSettings.Okta.AuthorizationServerId = $env:OKTA_AUTH_SERVER_ID + $appSettings.MvpSelectionsApiClient.BaseAddress = $env:MVP_SELECTIONS_API + $appSettings | ConvertTo-Json | Out-File "src/Project/MvpSite/rendering/appsettings.Development.json" + Write-Host "Finsihed Configuring MVP Head" +} +else { + Write-Host "Removing files used to configure Edge Mode without Docker" -ForegroundColor Green + + Write-Host "Configuring MVP Head" + git restore 'src/Project/MvpSite/rendering/appsettings.Development.json' + Write-Host "Finsihed Configuring MVP Head" +} + + ########################## # Show Certificate Details ########################## @@ -209,4 +257,5 @@ catch { } finally { Pop-Location -} \ No newline at end of file +} + From 6505478d5e648913277836582933a67d5ea6575a Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 29 May 2023 13:23:27 +1000 Subject: [PATCH 03/12] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6618593b..738bd4bb 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ Once you have initialized the repository with your Edge Token, use the `up.ps1` ## 💻+🌏 Running in Edge Development Mode without Docker -### Initialize your repository for Edge Development Mode with Docker +### Initialize your repository for Edge Development Mode without Docker First initialize your repo using the `.init/ps1` script, you will need to pass in the `-Edge_Token` & `-EdgeNoDocker` parameters to ensure that the repository is correct initialised. ```ps1 From dc16d72d8b89b0c862154bc33f00ddd934183997 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 29 May 2023 13:26:02 +1000 Subject: [PATCH 04/12] Updated README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 738bd4bb..70d37409 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ Once you have initialized the repository with your Edge Token, use the `up.ps1` First initialize your repo using the `.init/ps1` script, you will need to pass in the `-Edge_Token` & `-EdgeNoDocker` parameters to ensure that the repository is correct initialised. ```ps1 -.\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword" -Edge_Token "<>" - EdgeNoDocker +.\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword" -Edge_Token "<>" -EdgeNoDocker ``` Running with the `-EdgeNoDocker` switch, will setup configuration files for each of the heads included in this repository. You can then manually run each of them using either NPM or DotNet. @@ -149,4 +149,4 @@ Running with the `-EdgeNoDocker` switch, will setup configuration files for each After completing the init setup above you will be able to run the MVP Site either directly from within Visual Studio, or by using the DotNet CLI. - To run from within Visual Studio, open the `src\XmCloudIntroduction.sln`, ensure that the `Mvp.Project.MvpSite.Rendering` project is set as your StartUp Project, then hit F5. -- To run from the DotNet CLI, open a new terminal window and navigate to the `src\Project\MvpSite\rendering` folder, then run `dotnet run` +- To run from the DotNet CLI, open a new terminal window and navigate to the `src\Project\MvpSite\rendering` folder, then run `dotnet restore && dotnet run` From ef09986e00d04904e9eee4f4f30c24b926019e54 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 29 May 2023 13:28:11 +1000 Subject: [PATCH 05/12] Uncommented out elements on init.ps1 --- init.ps1 | 57 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/init.ps1 b/init.ps1 index 97c91f16..114e583d 100644 --- a/init.ps1 +++ b/init.ps1 @@ -98,34 +98,34 @@ $SUGCON_INDIA_HOST = "sugconindia.$Host_Suffix" ################################## # Configure TLS/HTTPS certificates ################################## -# Push-Location docker\traefik\certs -# try { -# $mkcert = ".\mkcert.exe" -# if ($null -ne (Get-Command mkcert.exe -ErrorAction SilentlyContinue)) { -# # mkcert installed in PATH -# $mkcert = "mkcert" -# } elseif (-not (Test-Path $mkcert)) { -# Write-Host "Downloading and installing mkcert certificate tool..." -ForegroundColor Green -# Invoke-WebRequest "https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-windows-amd64.exe" -UseBasicParsing -OutFile mkcert.exe -# if ((Get-FileHash mkcert.exe).Hash -ne "1BE92F598145F61CA67DD9F5C687DFEC17953548D013715FF54067B34D7C3246") { -# Remove-Item mkcert.exe -Force -# throw "Invalid mkcert.exe file" -# } -# } -# Write-Host "Generating Traefik TLS certificate." -ForegroundColor Green -# & $mkcert -install -# & $mkcert "*.$Host_Suffix" -# & $mkcert $Host_Suffix +Push-Location docker\traefik\certs +try { + $mkcert = ".\mkcert.exe" + if ($null -ne (Get-Command mkcert.exe -ErrorAction SilentlyContinue)) { + # mkcert installed in PATH + $mkcert = "mkcert" + } elseif (-not (Test-Path $mkcert)) { + Write-Host "Downloading and installing mkcert certificate tool..." -ForegroundColor Green + Invoke-WebRequest "https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-windows-amd64.exe" -UseBasicParsing -OutFile mkcert.exe + if ((Get-FileHash mkcert.exe).Hash -ne "1BE92F598145F61CA67DD9F5C687DFEC17953548D013715FF54067B34D7C3246") { + Remove-Item mkcert.exe -Force + throw "Invalid mkcert.exe file" + } + } + Write-Host "Generating Traefik TLS certificate." -ForegroundColor Green + & $mkcert -install + & $mkcert "*.$Host_Suffix" + & $mkcert $Host_Suffix -# # stash CAROOT path for messaging at the end of the script -# $caRoot = "$(& $mkcert -CAROOT)\rootCA.pem" -# } -# catch { -# Write-Error "An error occurred while attempting to generate TLS certificate: $_" -# } -# finally { -# Pop-Location -# } + # stash CAROOT path for messaging at the end of the script + $caRoot = "$(& $mkcert -CAROOT)\rootCA.pem" +} +catch { + Write-Error "An error occurred while attempting to generate TLS certificate: $_" +} +finally { + Pop-Location +} ################################ # Add Windows hosts file entries @@ -257,5 +257,4 @@ catch { } finally { Pop-Location -} - +} \ No newline at end of file From 2086a10b1abf19a5396b3a383cfc10d28289a404 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 29 May 2023 13:59:04 +1000 Subject: [PATCH 06/12] Updated init to configure running SUGCON sites in edge mode without docker, updated readme to include steps --- README.md | 9 +++++++++ init.ps1 | 23 ++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 70d37409..e5d4526c 100644 --- a/README.md +++ b/README.md @@ -149,4 +149,13 @@ Running with the `-EdgeNoDocker` switch, will setup configuration files for each After completing the init setup above you will be able to run the MVP Site either directly from within Visual Studio, or by using the DotNet CLI. - To run from within Visual Studio, open the `src\XmCloudIntroduction.sln`, ensure that the `Mvp.Project.MvpSite.Rendering` project is set as your StartUp Project, then hit F5. + - The site should then be started loaded in the browser automatically - To run from the DotNet CLI, open a new terminal window and navigate to the `src\Project\MvpSite\rendering` folder, then run `dotnet restore && dotnet run` + - You can then access the site at `https://localhost:5001` or `http://localhost:5000` + +### Running the SUGCON Sites + +After completing the init setup above you will be able to run the SUGCON Sites directly using the NPM CLI, they are all built using SXA Headless so the process is the same for each of them. + +- Open a new terminal window and navigate to the `src\Project\Sugcon\<>` folder, then run `npm i && npm run start:connected` + - You can then access the site at `http://localhost:3000` \ No newline at end of file diff --git a/init.ps1 b/init.ps1 index 114e583d..9ea88bc3 100644 --- a/init.ps1 +++ b/init.ps1 @@ -227,16 +227,29 @@ if ($EdgeNoDocker) { $appSettings.MvpSelectionsApiClient.BaseAddress = $env:MVP_SELECTIONS_API $appSettings | ConvertTo-Json | Out-File "src/Project/MvpSite/rendering/appsettings.Development.json" Write-Host "Finsihed Configuring MVP Head" + + Write-Host "Creating .env for SUGCON Sites" + $sugconEnvContents = +@" +SITECORE_API_HOST=${env:EXPERIENCE_EDGE_URL} +SITECORE_API_KEY=${env:EXPERIENCE_EDGE_TOKEN} +GRAPH_QL_ENDPOINT=${env:GRAPH_QL_ENDPOINT} +FETCH_WITH="GraphQL" +"@ + + Write-Host "Writing .env files for SUGCON Heads" + $sugconEnvContents | Out-File "src/Project/Sugcon/SugconAnzSxa/.env" + $sugconEnvContents | Out-File "src/Project/Sugcon/SugconEuSxa/.env" + $sugconEnvContents | Out-File "src/Project/Sugcon/SugconIndiaSxa/.env" } else { - Write-Host "Removing files used to configure Edge Mode without Docker" -ForegroundColor Green - - Write-Host "Configuring MVP Head" + Write-Host "Cleaning any files used to run Edge Mode without Docker" -ForegroundColor Green git restore 'src/Project/MvpSite/rendering/appsettings.Development.json' - Write-Host "Finsihed Configuring MVP Head" + if(Test-Path './src/Project/Sugcon/SugconAnzSxa/.env') { Remove-Item -Path './src/Project/Sugcon/SugconAnzSxa/.env' -Force } + if(Test-Path './src/Project/Sugcon/SugconEuSxa/.env') { Remove-Item -Path './src/Project/Sugcon/SugconEuSxa/.env' -Force } + if(Test-Path './src/Project/Sugcon/SugconIndiaSxa/.env') { Remove-Item -Path './src/Project/Sugcon/SugconIndiaSxa/.env' -Force } } - ########################## # Show Certificate Details ########################## From 46fb3da89d0b330f0cb1a0c9379e80ff9f42a11a Mon Sep 17 00:00:00 2001 From: Jason St-Cyr Date: Thu, 29 Jun 2023 13:06:20 -0400 Subject: [PATCH 07/12] Fixing typos and UK English --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e5d4526c..d21d8ab4 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Examples of how to use them can be seen in the different setup guides for both L |------------------------------|-----------------------|---------------------------|-----------------------------------------------------------------| | LicenseXmlPath | **Yes** | **Yes** | Used to specify the path to the license file | | AdminPassword | **Yes** | **Yes** | Used to specify the password for the Sitecore admin user | -| InitEnv | No | No | Used to force a full initialisation of the repository | +| InitEnv | No | No | Used to force a full initialization of the repository | | Edge_Token | No | No | Used to authenticate with XM Cloud, when running in 'Edge Mode' | | OKTA_Domain | **Yes** | No | Okta domain used by the MVP Rendering host | | OKTA_Client_Id | **Yes** | No | Okta Client Id used by the MVP Rendering host | @@ -57,11 +57,11 @@ Examples of how to use them can be seen in the different setup guides for both L | SUCGON_INDIA_CDP_CLIENT_KEY | No | No | CDP Client key for SUGCON India Site | | SUCGON_INDIA_CDP_TARGET_URL | No | No | CDP Target URL for SUGCON India Site | | SUCGON_INDIA_CDP_POINTOFSALE | No | No | CDP POS for SUGCON India Site | -| EdgeNoDocker | No | No | Used to initialise the repo for Edge Developer without Docker | +| EdgeNoDocker | No | No | Used to initialize the repo for Edge Developer without Docker | -## Embeded Personalisation -Embedded Personalisation is disabled locally by default. If you wish to enable it you will need to populate the different `xx_CDP_CLIENT_KEY`, `xx_CDP_TARGET_URL` & `xx_CDP_POINTOFSALE` parameters with valid values and change the `NODE_ENV` parameter from `development` to another value. +## Embedded Personalization +Embedded Personalization is disabled locally by default. If you wish to enable it you will need to populate the different `xx_CDP_CLIENT_KEY`, `xx_CDP_TARGET_URL` & `xx_CDP_POINTOFSALE` parameters with valid values and change the `NODE_ENV` parameter from `development` to another value. # 🏃 Running the Repository After you have initialized the repository, you can run it using the `up.ps1` script. There are 3 different ways you can run this repository @@ -136,7 +136,7 @@ Once you have initialized the repository with your Edge Token, use the `up.ps1` ## 💻+🌏 Running in Edge Development Mode without Docker ### Initialize your repository for Edge Development Mode without Docker -First initialize your repo using the `.init/ps1` script, you will need to pass in the `-Edge_Token` & `-EdgeNoDocker` parameters to ensure that the repository is correct initialised. +First initialize your repo using the `.init/ps1` script, you will need to pass in the `-Edge_Token` & `-EdgeNoDocker` parameters to ensure that the repository is correct initialized. ```ps1 .\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword" -Edge_Token "<>" -EdgeNoDocker From 508ecd9d4c4366ca84eb9099b49484f4ff1d75d3 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 10 Jul 2023 14:39:50 +1000 Subject: [PATCH 08/12] Re-ordered init file logic & update README --- README.md | 55 +++++++-------- init.ps1 | 203 +++++++++++++++++++++++++++++------------------------- 2 files changed, 137 insertions(+), 121 deletions(-) diff --git a/README.md b/README.md index e5d4526c..05fd85b0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This repository contains the codebase for a series of sites managed by the Techn # ✋ Prerequisites - [DotNet 6.0](https://dotnet.microsoft.com/en-us/download) - [NodeJS 16 LTS](https://nodejs.org/en/download/) (or greater) -- [Docker](https://www.docker.com/) +- [Docker](https://www.docker.com/) (Not required when running in Edge Development Mode without Docker) ## Docker Compose v2 This repository uses Docker Compose v2. As of June 2023 v1 is no longer supported by Docker. You can read more about the differences between the two versions [here](https://docs.docker.com/compose/compose-v2/). @@ -34,31 +34,32 @@ If you wish to run the MVP Site you will need to provide Okta configuration deta When you interact with XM Cloud you will be asked to authenticate with our Auth0 tenant. If you don't have an account already you can follow the registration flow provided by the Auth0 to create one. # ▶️ Initializing the repository -You first need to initialize your .env file which will configure how the different application elements will run. There are a series of parameters you can pass in to override the default behaviour of the application, you can find the full list of parameters with their purpose here. - -Examples of how to use them can be seen in the different setup guides for both Local Mode and Edge Mode below. - -| Parameter | Required for MVP Site | Required for SUGCON Sites | Purpose | -|------------------------------|-----------------------|---------------------------|-----------------------------------------------------------------| -| LicenseXmlPath | **Yes** | **Yes** | Used to specify the path to the license file | -| AdminPassword | **Yes** | **Yes** | Used to specify the password for the Sitecore admin user | -| InitEnv | No | No | Used to force a full initialisation of the repository | -| Edge_Token | No | No | Used to authenticate with XM Cloud, when running in 'Edge Mode' | -| OKTA_Domain | **Yes** | No | Okta domain used by the MVP Rendering host | -| OKTA_Client_Id | **Yes** | No | Okta Client Id used by the MVP Rendering host | -| OKTA_Client_Secret | **Yes** | No | Okta Client Secret used by the MVP Rendering host | -| MVP_Selections_API | **Yes** | No | URL for the MVP Selections API | -| SUCGON_ANZ_CDP_CLIENT_KEY | No | No | CDP Client key for SUGCON ANZ Site | -| SUCGON_ANZ_CDP_TARGET_URL | No | No | CDP Target URL for SUGCON ANZ Site | -| SUCGON_ANZ_CDP_POINTOFSALE | No | No | CDP POS for SUGCON ANZ Site | -| SUCGON_EU_CDP_CLIENT_KEY | No | No | CDP Client key for SUGCON EU Site | -| SUCGON_EU_CDP_TARGET_URL | No | No | CDP Target URL for SUGCON EU Site | -| SUCGON_EU_CDP_POINTOFSALE | No | No | CDP POS for SUGCON EU Site | -| SUCGON_INDIA_CDP_CLIENT_KEY | No | No | CDP Client key for SUGCON India Site | -| SUCGON_INDIA_CDP_TARGET_URL | No | No | CDP Target URL for SUGCON India Site | -| SUCGON_INDIA_CDP_POINTOFSALE | No | No | CDP POS for SUGCON India Site | -| EdgeNoDocker | No | No | Used to initialise the repo for Edge Developer without Docker | - +You first need to initialize the repository, which will configure how the different application elements will run. There are a series of parameters you can pass into the `init.ps1` script to achieve this, you can find the full list of parameters with their purpose here. + +You must be in "administrator mode" to run the `init.ps1` script. + +Examples of how to use them can be seen in the setup guides for the different running modes below . + +| Parameter | Required for MVP Site | Required for SUGCON Sites | Required for full local | Required for Edge Mode | Purpose | +|------------------------------|-----------------------|---------------------------|-------------------------|------------------------|-----------------------------------------------------------------| +| LicenseXmlPath | No | No | **Yes** | No | Used to specify the path to the license file | +| AdminPassword | No | No | **Yes** | No | Used to specify the password for the Sitecore admin user | +| InitEnv | No | No | No | No | Used to force a full initialisation of the repository | +| Edge_Token | No | No | No | **Yes** | Used to authenticate with XM Cloud, when running in 'Edge Mode' | +| OKTA_Domain | **Yes** | No | No | No | Okta domain used by the MVP Rendering host | +| OKTA_Client_Id | **Yes** | No | No | No | Okta Client Id used by the MVP Rendering host | +| OKTA_Client_Secret | **Yes** | No | No | No | Okta Client Secret used by the MVP Rendering host | +| MVP_Selections_API | No | No | No | No | URL for the MVP Selections API | +| SUCGON_ANZ_CDP_CLIENT_KEY | No | No | No | No | CDP Client key for SUGCON ANZ Site | +| SUCGON_ANZ_CDP_TARGET_URL | No | No | No | No | CDP Target URL for SUGCON ANZ Site | +| SUCGON_ANZ_CDP_POINTOFSALE | No | No | No | No | CDP POS for SUGCON ANZ Site | +| SUCGON_EU_CDP_CLIENT_KEY | No | No | No | No | CDP Client key for SUGCON EU Site | +| SUCGON_EU_CDP_TARGET_URL | No | No | No | No | CDP Target URL for SUGCON EU Site | +| SUCGON_EU_CDP_POINTOFSALE | No | No | No | No | CDP POS for SUGCON EU Site | +| SUCGON_INDIA_CDP_CLIENT_KEY | No | No | No | No | CDP Client key for SUGCON India Site | +| SUCGON_INDIA_CDP_TARGET_URL | No | No | No | No | CDP Target URL for SUGCON India Site | +| SUCGON_INDIA_CDP_POINTOFSALE | No | No | No | No | CDP POS for SUGCON India Site | +| Edge_NoDocker | No | No | No | No | Used to initialise the repo for Edge Developer without Docker | ## Embeded Personalisation Embedded Personalisation is disabled locally by default. If you wish to enable it you will need to populate the different `xx_CDP_CLIENT_KEY`, `xx_CDP_TARGET_URL` & `xx_CDP_POINTOFSALE` parameters with valid values and change the `NODE_ENV` parameter from `development` to another value. @@ -139,7 +140,7 @@ Once you have initialized the repository with your Edge Token, use the `up.ps1` First initialize your repo using the `.init/ps1` script, you will need to pass in the `-Edge_Token` & `-EdgeNoDocker` parameters to ensure that the repository is correct initialised. ```ps1 -.\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword" -Edge_Token "<>" -EdgeNoDocker +.\init.ps1 -InitEnv -Edge_Token "<>" -Edge_NoDocker ``` Running with the `-EdgeNoDocker` switch, will setup configuration files for each of the heads included in this repository. You can then manually run each of them using either NPM or DotNet. diff --git a/init.ps1 b/init.ps1 index 9ea88bc3..65bf8584 100644 --- a/init.ps1 +++ b/init.ps1 @@ -3,9 +3,9 @@ Param ( [Parameter(HelpMessage = "Enables initialization of values in the .env file, which may be placed in source control.")] [switch]$InitEnv, - [Parameter(Mandatory = $true, HelpMessage = "The path to a valid Sitecore license.xml file.")] + [Parameter(HelpMessage = "The path to a valid Sitecore license.xml file.")] [string]$LicenseXmlPath, - [Parameter(Mandatory = $true, HelpMessage = "Sets the sitecore\\admin password for this environment via environment variable.")] + [Parameter(HelpMessage = "Sets the sitecore\\admin password for this environment via environment variable.")] [String]$AdminPassword, [Parameter(HelpMessage = "The Edge token used when running in Edge Mode.")] [string]$Edge_Token, @@ -36,107 +36,17 @@ Param ( [Parameter(HelpMessage = "SUGCON INDIA CPD Point of Sale.")] [string]$SUCGON_INDIA_CDP_POINTOFSALE, [Parameter(HelpMessage = "Switch to setup the heads to run against edge without docker.")] - [switch]$EdgeNoDocker + [switch]$Edge_NoDocker ) $ErrorActionPreference = "Stop"; -############### -# License Check -############### -Write-Host "Checking for existence of License." -ForegroundColor Green -if (-not $LicenseXmlPath.EndsWith("license.xml")) { - Write-Error "Sitecore license file must be named 'license.xml'." -} -if (-not (Test-Path $LicenseXmlPath)) { - Write-Error "Could not find Sitecore license file at path '$LicenseXmlPath'." -} -# We actually want the folder that it's in for mounting -$LicenseXmlPath = (Get-Item $LicenseXmlPath).Directory.FullName - ################## # Create .env file ################## Write-Host "Creating .env file." -ForegroundColor Green Copy-Item ".\.env.template" ".\.env" -Force -################################################ -# Retrieve and import SitecoreDockerTools module -################################################ -# Check for Sitecore Gallery -Import-Module PowerShellGet -$SitecoreGallery = Get-PSRepository | Where-Object { $_.SourceLocation -eq "https://sitecore.myget.org/F/sc-powershell/api/v2" } -if (-not $SitecoreGallery) { - Write-Host "Adding Sitecore PowerShell Gallery..." -ForegroundColor Green - Unregister-PSRepository -Name SitecoreGallery -ErrorAction SilentlyContinue - Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2 -InstallationPolicy Trusted - $SitecoreGallery = Get-PSRepository -Name SitecoreGallery -} - -# Install and Import SitecoreDockerTools -$dockerToolsVersion = "10.2.7" -Remove-Module SitecoreDockerTools -ErrorAction SilentlyContinue -if (-not (Get-InstalledModule -Name SitecoreDockerTools -RequiredVersion $dockerToolsVersion -ErrorAction SilentlyContinue)) { - Write-Host "Installing SitecoreDockerTools." -ForegroundColor Green - Install-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion -Scope CurrentUser -Repository $SitecoreGallery.Name -} -Write-Host "Importing SitecoreDockerTools." -ForegroundColor Green -Import-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion -Write-SitecoreDockerWelcome - -########################### -# Setup site host variables -########################### -Write-Host "Setting HOSTS values." -ForegroundColor Green -$Host_Suffix = "xmcloudcm.localhost" -$CM_Host = $Host_Suffix -$MVP_Host = "mvp.$Host_Suffix" -$SUGCON_EU_HOST = "sugconeu.$Host_Suffix" -$SUGCON_ANZ_HOST = "sugconanz.$Host_Suffix" -$SUGCON_INDIA_HOST = "sugconindia.$Host_Suffix" - -################################## -# Configure TLS/HTTPS certificates -################################## -Push-Location docker\traefik\certs -try { - $mkcert = ".\mkcert.exe" - if ($null -ne (Get-Command mkcert.exe -ErrorAction SilentlyContinue)) { - # mkcert installed in PATH - $mkcert = "mkcert" - } elseif (-not (Test-Path $mkcert)) { - Write-Host "Downloading and installing mkcert certificate tool..." -ForegroundColor Green - Invoke-WebRequest "https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-windows-amd64.exe" -UseBasicParsing -OutFile mkcert.exe - if ((Get-FileHash mkcert.exe).Hash -ne "1BE92F598145F61CA67DD9F5C687DFEC17953548D013715FF54067B34D7C3246") { - Remove-Item mkcert.exe -Force - throw "Invalid mkcert.exe file" - } - } - Write-Host "Generating Traefik TLS certificate." -ForegroundColor Green - & $mkcert -install - & $mkcert "*.$Host_Suffix" - & $mkcert $Host_Suffix - - # stash CAROOT path for messaging at the end of the script - $caRoot = "$(& $mkcert -CAROOT)\rootCA.pem" -} -catch { - Write-Error "An error occurred while attempting to generate TLS certificate: $_" -} -finally { - Pop-Location -} - -################################ -# Add Windows hosts file entries -################################ -Write-Host "Adding Windows hosts file entries." -ForegroundColor Green -Add-HostsEntry $CM_Host -Add-HostsEntry $MVP_Host -Add-HostsEntry $SUGCON_EU_HOST -Add-HostsEntry $SUGCON_ANZ_HOST -Add-HostsEntry $SUGCON_INDIA_HOST - ############################### # Generate scjssconfig ############################### @@ -194,7 +104,7 @@ Write-Host "Finished populating .env file." -ForegroundColor Green ################################## # Configure/Reset EdgeNoDockerMode ################################## -if ($EdgeNoDocker) { +if ($Edge_NoDocker) { # Ensure Edge token is passed in when attempting to setup Edge Mode without Docker if($Edge_Token -eq "") @@ -241,6 +151,13 @@ FETCH_WITH="GraphQL" $sugconEnvContents | Out-File "src/Project/Sugcon/SugconAnzSxa/.env" $sugconEnvContents | Out-File "src/Project/Sugcon/SugconEuSxa/.env" $sugconEnvContents | Out-File "src/Project/Sugcon/SugconIndiaSxa/.env" + + Write-Host + Write-Host ("#"*75) -ForegroundColor Cyan + Write-Host "Configuration Edge Mode without Docker complete" -ForegroundColor Cyan + Write-Host "You can now run the different sites directly, please see the README for further details." -ForegroundColor Cyan + Write-Host ("#"*75) -ForegroundColor Cyan + exit 0 } else { Write-Host "Cleaning any files used to run Edge Mode without Docker" -ForegroundColor Green @@ -250,6 +167,104 @@ else { if(Test-Path './src/Project/Sugcon/SugconIndiaSxa/.env') { Remove-Item -Path './src/Project/Sugcon/SugconIndiaSxa/.env' -Force } } +############### +# License Check +############### +Write-Host "Checking for existence of License." -ForegroundColor Green +if (-not $LicenseXmlPath.EndsWith("license.xml")) { + Write-Error "Sitecore license file must be named 'license.xml'." +} +if (-not (Test-Path $LicenseXmlPath)) { + Write-Error "Could not find Sitecore license file at path '$LicenseXmlPath'." +} +# We actually want the folder that it's in for mounting +$LicenseXmlPath = (Get-Item $LicenseXmlPath).Directory.FullName + +################################################ +# Retrieve and import SitecoreDockerTools module +################################################ +# Check for Sitecore Gallery +Import-Module PowerShellGet +$SitecoreGallery = Get-PSRepository | Where-Object { $_.SourceLocation -eq "https://sitecore.myget.org/F/sc-powershell/api/v2" } +if (-not $SitecoreGallery) { + Write-Host "Adding Sitecore PowerShell Gallery..." -ForegroundColor Green + Unregister-PSRepository -Name SitecoreGallery -ErrorAction SilentlyContinue + Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2 -InstallationPolicy Trusted + $SitecoreGallery = Get-PSRepository -Name SitecoreGallery +} + +# Install and Import SitecoreDockerTools +$dockerToolsVersion = "10.2.7" +Remove-Module SitecoreDockerTools -ErrorAction SilentlyContinue +if (-not (Get-InstalledModule -Name SitecoreDockerTools -RequiredVersion $dockerToolsVersion -ErrorAction SilentlyContinue)) { + Write-Host "Installing SitecoreDockerTools." -ForegroundColor Green + Install-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion -Scope CurrentUser -Repository $SitecoreGallery.Name +} +Write-Host "Importing SitecoreDockerTools." -ForegroundColor Green +Import-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion +Write-SitecoreDockerWelcome + +########################### +# Setup site host variables +########################### +Write-Host "Setting HOSTS values." -ForegroundColor Green +$Host_Suffix = "xmcloudcm.localhost" +$CM_Host = $Host_Suffix +$MVP_Host = "mvp.$Host_Suffix" +$SUGCON_EU_HOST = "sugconeu.$Host_Suffix" +$SUGCON_ANZ_HOST = "sugconanz.$Host_Suffix" +$SUGCON_INDIA_HOST = "sugconindia.$Host_Suffix" + +################################## +# Configure TLS/HTTPS certificates +################################## +Push-Location docker\traefik\certs +try { + $mkcert = ".\mkcert.exe" + if ($null -ne (Get-Command mkcert.exe -ErrorAction SilentlyContinue)) { + # mkcert installed in PATH + $mkcert = "mkcert" + } elseif (-not (Test-Path $mkcert)) { + Write-Host "Downloading and installing mkcert certificate tool..." -ForegroundColor Green + Invoke-WebRequest "https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-windows-amd64.exe" -UseBasicParsing -OutFile mkcert.exe + if ((Get-FileHash mkcert.exe).Hash -ne "1BE92F598145F61CA67DD9F5C687DFEC17953548D013715FF54067B34D7C3246") { + Remove-Item mkcert.exe -Force + throw "Invalid mkcert.exe file" + } + } + Write-Host "Generating Traefik TLS certificate." -ForegroundColor Green + & $mkcert -install + & $mkcert "*.$Host_Suffix" + & $mkcert $Host_Suffix + + # stash CAROOT path for messaging at the end of the script + $caRoot = "$(& $mkcert -CAROOT)\rootCA.pem" +} +catch { + Write-Error "An error occurred while attempting to generate TLS certificate: $_" +} +finally { + Pop-Location +} + +################################ +# Add Windows hosts file entries +################################ +Write-Host "Adding Windows hosts file entries." -ForegroundColor Green +Add-HostsEntry $CM_Host +Add-HostsEntry $MVP_Host +Add-HostsEntry $SUGCON_EU_HOST +Add-HostsEntry $SUGCON_ANZ_HOST +Add-HostsEntry $SUGCON_INDIA_HOST + + + + + + + + + ########################## # Show Certificate Details ########################## From 7111e0edb329bb59d56f0affdcbd5ea96ba28482 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Mon, 10 Jul 2023 15:21:37 +1000 Subject: [PATCH 09/12] Updated init script --- init.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/init.ps1 b/init.ps1 index 65bf8584..425d53f8 100644 --- a/init.ps1 +++ b/init.ps1 @@ -74,8 +74,6 @@ Set-EnvFileVariable "JSS_EDITING_SECRET" -Value $jssEditingSecret if ($InitEnv) { Write-Host "Populating .env file." -ForegroundColor Green Set-EnvFileVariable "HOST_LICENSE_FOLDER" -Value $LicenseXmlPath - Set-EnvFileVariable "CM_HOST" -Value $CM_Host - Set-EnvFileVariable "MVP_RENDERING_HOST" -Value $MVP_Host Set-EnvFileVariable "REPORTING_API_KEY" -Value (Get-SitecoreRandomString 128 -DisallowSpecial) Set-EnvFileVariable "TELERIK_ENCRYPTION_KEY" -Value (Get-SitecoreRandomString 128 -DisallowSpecial) Set-EnvFileVariable "MEDIA_REQUEST_PROTECTION_SHARED_SECRET" -Value (Get-SitecoreRandomString 64 -DisallowSpecial) From c1eec3764d14c97ee0efdef87c467239e05e8239 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Wed, 12 Jul 2023 11:15:40 +1000 Subject: [PATCH 10/12] Formatting in init.ps1 --- init.ps1 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/init.ps1 b/init.ps1 index 425d53f8..058ab2ca 100644 --- a/init.ps1 +++ b/init.ps1 @@ -152,7 +152,7 @@ FETCH_WITH="GraphQL" Write-Host Write-Host ("#"*75) -ForegroundColor Cyan - Write-Host "Configuration Edge Mode without Docker complete" -ForegroundColor Cyan + Write-Host "Configuring Edge Mode without Docker complete" -ForegroundColor Cyan Write-Host "You can now run the different sites directly, please see the README for further details." -ForegroundColor Cyan Write-Host ("#"*75) -ForegroundColor Cyan exit 0 @@ -255,14 +255,6 @@ Add-HostsEntry $SUGCON_EU_HOST Add-HostsEntry $SUGCON_ANZ_HOST Add-HostsEntry $SUGCON_INDIA_HOST - - - - - - - - ########################## # Show Certificate Details ########################## From d5ec4a8025b79943129632a0072e5ac7a99d544f Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Wed, 12 Jul 2023 14:40:24 +1000 Subject: [PATCH 11/12] Setup init.ps1 for none docker mode --- init.ps1 | 77 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/init.ps1 b/init.ps1 index 058ab2ca..73d1e79c 100644 --- a/init.ps1 +++ b/init.ps1 @@ -41,6 +41,30 @@ Param ( $ErrorActionPreference = "Stop"; +################################################ +# Retrieve and import SitecoreDockerTools module +################################################ +# Check for Sitecore Gallery +Import-Module PowerShellGet +$SitecoreGallery = Get-PSRepository | Where-Object { $_.SourceLocation -eq "https://sitecore.myget.org/F/sc-powershell/api/v2" } +if (-not $SitecoreGallery) { + Write-Host "Adding Sitecore PowerShell Gallery..." -ForegroundColor Green + Unregister-PSRepository -Name SitecoreGallery -ErrorAction SilentlyContinue + Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2 -InstallationPolicy Trusted + $SitecoreGallery = Get-PSRepository -Name SitecoreGallery +} + +# Install and Import SitecoreDockerTools +$dockerToolsVersion = "10.2.7" +Remove-Module SitecoreDockerTools -ErrorAction SilentlyContinue +if (-not (Get-InstalledModule -Name SitecoreDockerTools -RequiredVersion $dockerToolsVersion -ErrorAction SilentlyContinue)) { + Write-Host "Installing SitecoreDockerTools." -ForegroundColor Green + Install-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion -Scope CurrentUser -Repository $SitecoreGallery.Name +} +Write-Host "Importing SitecoreDockerTools." -ForegroundColor Green +Import-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion +Write-SitecoreDockerWelcome + ################## # Create .env file ################## @@ -113,37 +137,38 @@ if ($Edge_NoDocker) { Write-Host "Configuring heads to run in Edge Mode without Docker" -ForegroundColor Green - # Read .env into PS runtime for each access + # Read .env into HashTable + $envVars = @{} get-content .env | ForEach-Object { if(-Not $_.StartsWith("#") -and -Not $_ -eq "") { $splitChar = $_.IndexOf('=') $name = $_.Substring(0, $splitChar) $value = $_.Substring($splitChar + 1) - set-content env:\$name $value + $envVars.Add($name,$value) } } - + Write-Host "Configuring MVP Head" $appSettings = Get-Content 'src/Project/MvpSite/rendering/appsettings.Development.json' | ConvertFrom-Json - $appSettings.Sitecore.InstanceUri = $env:EXPERIENCE_EDGE_URL + $appSettings.Sitecore.InstanceUri = $envVars.EXPERIENCE_EDGE_URL $appSettings.Sitecore.LayoutServicePath = "/api/graphql/v1" - $appSettings.Sitecore.ExperienceEdgeToken = $env:EXPERIENCE_EDGE_TOKEN - $appSettings.Okta.OktaDomain = $env:OKTA_DOMAIN - $appSettings.Okta.ClientId = $env:OKTA_CLIENT_ID - $appSettings.Okta.ClientSecret = $env:OKTA_CLIENT_SECRET - $appSettings.Okta.AuthorizationServerId = $env:OKTA_AUTH_SERVER_ID - $appSettings.MvpSelectionsApiClient.BaseAddress = $env:MVP_SELECTIONS_API + $appSettings.Sitecore.ExperienceEdgeToken = $envVars.EXPERIENCE_EDGE_TOKEN + $appSettings.Okta.OktaDomain = $envVars.OKTA_DOMAIN + $appSettings.Okta.ClientId = $envVars.OKTA_CLIENT_ID + $appSettings.Okta.ClientSecret = $envVars.OKTA_CLIENT_SECRET + $appSettings.Okta.AuthorizationServerId = $envVars.OKTA_AUTH_SERVER_ID + $appSettings.MvpSelectionsApiClient.BaseAddress = $envVars.MVP_SELECTIONS_API $appSettings | ConvertTo-Json | Out-File "src/Project/MvpSite/rendering/appsettings.Development.json" Write-Host "Finsihed Configuring MVP Head" Write-Host "Creating .env for SUGCON Sites" $sugconEnvContents = @" -SITECORE_API_HOST=${env:EXPERIENCE_EDGE_URL} -SITECORE_API_KEY=${env:EXPERIENCE_EDGE_TOKEN} -GRAPH_QL_ENDPOINT=${env:GRAPH_QL_ENDPOINT} +SITECORE_API_HOST={0} +SITECORE_API_KEY={1} +GRAPH_QL_ENDPOINT={2} FETCH_WITH="GraphQL" -"@ +"@ -f $envVars.EXPERIENCE_EDGE_URL, $envVars.EXPERIENCE_EDGE_TOKEN, $envVars.GRAPH_QL_ENDPOINT Write-Host "Writing .env files for SUGCON Heads" $sugconEnvContents | Out-File "src/Project/Sugcon/SugconAnzSxa/.env" @@ -178,30 +203,6 @@ if (-not (Test-Path $LicenseXmlPath)) { # We actually want the folder that it's in for mounting $LicenseXmlPath = (Get-Item $LicenseXmlPath).Directory.FullName -################################################ -# Retrieve and import SitecoreDockerTools module -################################################ -# Check for Sitecore Gallery -Import-Module PowerShellGet -$SitecoreGallery = Get-PSRepository | Where-Object { $_.SourceLocation -eq "https://sitecore.myget.org/F/sc-powershell/api/v2" } -if (-not $SitecoreGallery) { - Write-Host "Adding Sitecore PowerShell Gallery..." -ForegroundColor Green - Unregister-PSRepository -Name SitecoreGallery -ErrorAction SilentlyContinue - Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2 -InstallationPolicy Trusted - $SitecoreGallery = Get-PSRepository -Name SitecoreGallery -} - -# Install and Import SitecoreDockerTools -$dockerToolsVersion = "10.2.7" -Remove-Module SitecoreDockerTools -ErrorAction SilentlyContinue -if (-not (Get-InstalledModule -Name SitecoreDockerTools -RequiredVersion $dockerToolsVersion -ErrorAction SilentlyContinue)) { - Write-Host "Installing SitecoreDockerTools." -ForegroundColor Green - Install-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion -Scope CurrentUser -Repository $SitecoreGallery.Name -} -Write-Host "Importing SitecoreDockerTools." -ForegroundColor Green -Import-Module SitecoreDockerTools -RequiredVersion $dockerToolsVersion -Write-SitecoreDockerWelcome - ########################### # Setup site host variables ########################### From a1133272c9fe6071825e7ff30723fc20546930a4 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Wed, 12 Jul 2023 15:14:23 +1000 Subject: [PATCH 12/12] Fixed ordering in init.ps1 --- init.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.ps1 b/init.ps1 index 73d1e79c..30bc832b 100644 --- a/init.ps1 +++ b/init.ps1 @@ -97,7 +97,6 @@ Set-EnvFileVariable "JSS_EDITING_SECRET" -Value $jssEditingSecret ############################### if ($InitEnv) { Write-Host "Populating .env file." -ForegroundColor Green - Set-EnvFileVariable "HOST_LICENSE_FOLDER" -Value $LicenseXmlPath Set-EnvFileVariable "REPORTING_API_KEY" -Value (Get-SitecoreRandomString 128 -DisallowSpecial) Set-EnvFileVariable "TELERIK_ENCRYPTION_KEY" -Value (Get-SitecoreRandomString 128 -DisallowSpecial) Set-EnvFileVariable "MEDIA_REQUEST_PROTECTION_SHARED_SECRET" -Value (Get-SitecoreRandomString 64 -DisallowSpecial) @@ -202,6 +201,7 @@ if (-not (Test-Path $LicenseXmlPath)) { } # We actually want the folder that it's in for mounting $LicenseXmlPath = (Get-Item $LicenseXmlPath).Directory.FullName +Set-EnvFileVariable "HOST_LICENSE_FOLDER" -Value $LicenseXmlPath ########################### # Setup site host variables