From 1a4dd89b788c3dc3b6069cc1d495a35049b10341 Mon Sep 17 00:00:00 2001
From: Alex Washtell <alex@kasaku.co.uk>
Date: Mon, 13 Jan 2020 21:15:28 +0000
Subject: [PATCH] Added docker support for development.

---
 .env               |  7 ++++++
 .gitignore         |  6 ++++-
 Clean-Data.ps1     |  5 ++++
 data/cm/.gitkeep   |  0
 data/solr/.gitkeep |  0
 data/sql/.gitkeep  |  0
 deploy/.gitkeep    |  0
 docker-compose.yml | 62 ++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 .env
 create mode 100644 Clean-Data.ps1
 create mode 100644 data/cm/.gitkeep
 create mode 100644 data/solr/.gitkeep
 create mode 100644 data/sql/.gitkeep
 create mode 100644 deploy/.gitkeep
 create mode 100644 docker-compose.yml

diff --git a/.env b/.env
new file mode 100644
index 0000000..c7f9254
--- /dev/null
+++ b/.env
@@ -0,0 +1,7 @@
+REGISTRY=
+WINDOWSSERVERCORE_VERSION=ltsc2019
+NANOSERVER_VERSION=1809
+SITECORE_VERSION=9.3.0
+SITECORE_LICENSE=
+SQL_SA_PASSWORD=6g3sSSfkkifINMaHN0m1iBpYqCIH6pnl721I0UGnkWzUhG1xzZW9GYoxOm0q4w4H
+TELERIK_ENCRYPTION_KEY=tE5juGvP4xwVyS28AZSBn5vUw6sXxGZjJGUTx44EZeR8aLSEGMwntUJaqDC5TA72
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 7b61d36..5f154ce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -69,4 +69,8 @@ bld/
 *.nuget.targets
 
 # Custom libs
-libs/**/*.dll
\ No newline at end of file
+libs/**/*.dll
+
+# Docker related files
+#data/*
+#deploy/*
diff --git a/Clean-Data.ps1 b/Clean-Data.ps1
new file mode 100644
index 0000000..e3d1490
--- /dev/null
+++ b/Clean-Data.ps1
@@ -0,0 +1,5 @@
+Get-ChildItem -Path (Join-Path $PSScriptRoot "\data") -Directory | ForEach-Object {
+    $dataPath = $_.FullName
+
+    Get-ChildItem -Path $dataPath -Exclude ".gitkeep" -Recurse | Remove-Item -Force -Recurse -Verbose
+}
\ No newline at end of file
diff --git a/data/cm/.gitkeep b/data/cm/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/data/solr/.gitkeep b/data/solr/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/data/sql/.gitkeep b/data/sql/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/deploy/.gitkeep b/deploy/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..b01c2e9
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,62 @@
+version: "2.4"
+
+services:
+  sql:
+    image: ${REGISTRY}sitecore-xm-sqldev:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION}
+    volumes:
+      - .\data\sql:C:\Data
+    mem_limit: 2GB
+    ports:
+      - "44010:1433"
+    environment:
+      SA_PASSWORD: ${SQL_SA_PASSWORD}
+      ACCEPT_EULA: "Y"
+
+  solr:
+    image: ${REGISTRY}sitecore-xm-solr:${SITECORE_VERSION}-nanoserver-${NANOSERVER_VERSION}
+    volumes:
+      - .\data\solr:C:\Data
+    mem_limit: 1GB
+    ports:
+      - "44011:8983"
+    environment:
+      SOLR_LOG_LEVEL: ERROR
+
+  cm:
+    image: ${REGISTRY}sitecore-xm-cm:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION}
+    entrypoint: powershell.exe -Command "& C:\\tools\\entrypoints\\iis\\Development.ps1 -WatchDirectoryParameters @{ Path = 'C:\\src'; Destination = 'C:\\inetpub\\wwwroot'; }"
+    ports:
+      - "44001:80"
+      - "44024:4024"
+    volumes:
+      - .\deploy:C:\src
+      - .\data\cm:C:\inetpub\wwwroot\App_Data\logs
+      - C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Remote Debugger:C:\remote_debugger:ro
+    networks:
+      default:
+        aliases:
+          - sweep.dev.local
+    environment:
+      HOST_HEADER: sweep.dev.local
+      SITECORE_LICENSE: ${SITECORE_LICENSE}
+      SITECORE_APPSETTINGS_ROLE:DEFINE: ContentManagement, Indexing
+      SITECORE_CONNECTIONSTRINGS_CORE: Data Source=sql;Initial Catalog=Sitecore.Core;User ID=sa;Password=${SQL_SA_PASSWORD}
+      SITECORE_CONNECTIONSTRINGS_SECURITY: Data Source=sql;Initial Catalog=Sitecore.Core;User ID=sa;Password=${SQL_SA_PASSWORD}
+      SITECORE_CONNECTIONSTRINGS_MASTER: Data Source=sql;Initial Catalog=Sitecore.Master;User ID=sa;Password=${SQL_SA_PASSWORD}
+      SITECORE_CONNECTIONSTRINGS_WEB: Data Source=sql;Initial Catalog=Sitecore.Web;User ID=sa;Password=${SQL_SA_PASSWORD}
+      SITECORE_CONNECTIONSTRINGS_EXPERIENCEFORMS: Data Source=sql;Initial Catalog=Sitecore.ExperienceForms;User ID=sa;Password=${SQL_SA_PASSWORD}
+      SITECORE_CONNECTIONSTRINGS_SOLR.SEARCH: http://solr:8983/solr
+      SITECORE_APPSETTINGS_TELERIK.ASYNCUPLOAD.CONFIGURATIONENCRYPTIONKEY: ${TELERIK_ENCRYPTION_KEY}
+      SITECORE_APPSETTINGS_TELERIK.UPLOAD.CONFIGURATIONHASHKEY: ${TELERIK_ENCRYPTION_KEY}
+      SITECORE_APPSETTINGS_TELERIK.WEB.UI.DIALOGPARAMETERSENCRYPTIONKEY: ${TELERIK_ENCRYPTION_KEY}
+      ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED: 'false'
+      ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED: 'false'
+      ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED: 'true'
+    depends_on:
+      - sql
+      - solr
+
+networks:
+  default:
+    external:
+      name: nat