werf does not have own pull command to download images from Docker registry. Regular docker pull should be used for such a task.
There is a need to use existing old images as a cache to build new images to speed up the builds. This is default behavior when there is a single werf build host with persistent local storage of images. No special actions required from the werf user in such case.
However, if local storage of build host is not persistent or there are multiple build hosts, then stages cache should be pulled before running a new build. This action allows sharing stages cache between an arbitrary number of build hosts no matter whether the storage of this hosts is persisted or not.
Distributed images cache
It is not sufficient to pull just a image from the Docker registry. When you pull a image from a docker registry, you don’t receive stages cache for this image in the werf world.
To enable stages cache sharing user must firstly push images with a stages cache as it is described in the push article.
Then the werf pull command must be used to pull stages cache before the build command.
Pay attention, that this is an optional command. It should not be used in the simple environment, where there is only a one build host with a persistent storage because it has an overhead on the build process speed in such case.
Build process steps for a distributed build environment
- Pull stages cache from the Docker registry with werf pull.
- Build and push images with a new stages cache to the Docker registry with werf push commands.
Command used to pull stages cache from the specified Docker registry. Call command before any of the build commands.
werf pull command optimized to pull only single cache stage for each image, that needed to rebuild current state of the image.
For example, there was a change in
beforeSetup stage of the image since last project build. werf pull command:
- Calculates current state of the stage cache and realizes, that there is a change in
install(the stage prior
beforeSetup) stage from Docker registry.
beforeInstallstage will not be downloaded, because only
installstage is needed to rebuild
beforeSetupand further stages.
A pulled stage can be used by multiple images of the same
werf.yaml config in the case when this stage is common between multiple images.
In other words, werf downloads from cache last common stage between old and new image state.
There is also an option to turn off this optimized behavior and always pull all stages.
werf pull command currently not reimplemented from Ruby.
Pull stages cache
werf pull registry.hello.com/taxi/backend
Command pull stages cache from the specified repo.
Pulled images have
image-stage prefixes. Here is an example of image name pulled as stages cache: