User stages, beforeInstall, install, beforeSetup, setup, depend upon the appropriate instructions in the configuration. Any modification in stage instructions leads to re-assembling the appropriate stage with all instructions. Therefore, if the instructions are heavy and time-consuming, development of the configuration may take much time.

Let us also consider the situation where one of the last stage instruction fails. A user cannot retrieve the environment state preceding the failure of the instruction or check those previous instructions were correctly executed.

For development and debugging, we introduce asLayers directive. When assembling, the instructions are cached separately, and re-assembly is only performed when their sequence changes. The directive can be specified for a specific image or artifact in the werf.yaml configuration.

If asLayers: true, then the new caching mode is enabled — one docker image for one shell command, or one task for ansible. Otherwise, if asLayers directive is not specified (or if asLayers: false) default caching is applied, one docker image is used for all stage instructions.

Switching between assembly mode is only governed by the asLayers directive. Other instructions for the configuration remain unchanged. After having debugged the assembly instructions, asLayers must be disabled.

asLayers directive allows caching of individual instructions. If --introspect-error and --introspect-before-error introspection options are used, users may retrieve the environment before or after execution of a problem instruction.

It is important not to use this instruction in the course of regular assembly of images: this mode generates an excessive number of docker images and is not intended for incremental assembly (due to a longer timeout and greater size of stages)