sitecore-docker icon indicating copy to clipboard operation
sitecore-docker copied to clipboard

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

Open Barsonax opened this issue 5 years ago • 2 comments

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 avatar May 21 '19 07:05 Barsonax

Images sizes for the mercury demo: image

Barsonax avatar May 21 '19 08:05 Barsonax

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.

Barsonax avatar May 21 '19 11:05 Barsonax