avivasolutionsnl / sitecore-docker

Dockerized Sitecore 9 XP0 & XC
33 stars 24 forks source link

Consider persisting the mssql databases in a clean mssql image (aka multi stage build) #123

Open Barsonax opened 5 years ago

Barsonax commented 5 years ago

Currently everytime we persist the databases another copy of the databases is put into the docker image. This causes the image size to grow significantly.

Consider a multi stage approach where the database files are persisted in a clean mssql image.

Barsonax commented 5 years ago

Images sizes for the mercury demo: image

Barsonax commented 5 years ago

Could be done as follows (untested, powershell):

$InstallPath = "$env:INSTALL_PATH"
$DataPath = "$env:DATA_PATH"

$imagename = "project-mssql"
$containername = "sitecore-xp-mssql"

$baseimagename =sitecore-xp-mssql
$intermediateContainerName =  "intermediate-" + $containername

docker create $baseimagename  --name $intermediateContainername #create a new container based on the clean mssql container (contains no databases files)
docker cp $containername:$DataPath $intermediateContainername:$InstallPath #copy the database files to the temporary container
docker commit $intermediateContainername $imagename #commit the temporary container, overwritting the old image

#do some cleanup

So the idea is to copy the files to a temporary intermediate container that uses the base image and then commit that container under the required image name.