Skip to content

Multistage builds & image sizes #285

@vitaliitylyk

Description

@vitaliitylyk

At the moment variant images (e.g sitecore-xm-jss, sitecore-xm-sxa-jss, etc) use multi-stage build approach to decrease the amount of layers. Most of the work is done in a build stage, and the resulting 2-nd stage images are just copying the results to wwwroot:

COPY --from=build ["C:\\inetpub\\wwwroot\\", "C:\\inetpub\\wwwroot\\"]

On the first glance this looks good, but...

The problem

The COPY command actually increases the resulting image size by the size of wwwroot. Since variant images are based on each other (e.g sitecore-xm-sxa-jss is based on sitecore-xm-sxa), such layering increases the total image size on approximately ~400MB multiplied by number of layers. So sitecore-xm-sxa-jss adds ~800MB to the image size.

Proposed solution

Instead of copying the whole wwwroot directory, we need to copy only changed files. For example, when JSS is installed in the sitecore-xm-jss image we need to copy only contents of the JSS package (and make sure transformations are done on a web.config):

  1. Unpack the JSS package to c:\temp\wwwroot
  2. Copy web.config from BASE_IMAGE to c:\temp\wwwroot
  3. Run XDT transforms
  4. In the 2-nd stage image copy c:\temp\wwwroot to c:\inetpub\wwwroot

If you agree with the approach I can submit a PR ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions