mount: - from: tmp_dir to: <absolute_path> - from: build_dir to: <absolute_path> - fromPath: <absolute_or_relative_path> to: <absolute_path>
Quite often when you build an image, you have auxiliary files that should be excluded from the image:
- Most package managers create a system-wide cache of packages and other files.
- Package managers for programming languages like npm (nodejs), glide (go), pip (python) store files in their cache folder.
- Building C, C++ and similar applications leaves behind itself the object files and other files of the used build systems.
Thus, those files:
- are useless in the image;
- might enormously increase image size;
- might be useful in the next image builds.
Reducing image size and speeding up a build can be performed by mounting external folders into assembly containers. Docker implements a mounting mechanism using volumes.
mount config directive is used for defining volumes. Host and assembly container mount folders determine each volume (accordingly in
When specifying the host mount point, you can choose an arbitrary file or folder, defined in
fromPath, or one of the service folders, defined in
tmp_diris an individual temporary image directory, created new for each build;
build_diris a collectively shared directory, stored between builds (
~/.werf/shared_context/mounts/projects/<project name>/<mount id>/). Project images can use this common directory to share and store assembly data (e.g., cache).
Werf binds host mount folders for reading/writing on each stage build. If you need to keep assembly data from these directories in an image, you should copy them to another directory during build
from stage werf adds mount points definitions to stage image labels.
Then each stage uses these definitions for adding volumes to an assembly container.
The implementation allows inheriting mount points from base image.
from stage werf cleans assembly container mount points in a base image.
Therefore, these folders are empty in an image.