Image Builders
Image builders allow you to build container images.
BaseImageBuilder
Bases: StackComponent
, ABC
Base class for all ZenML image builders.
Source code in src/zenml/image_builders/base_image_builder.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
build_context_class
property
Build context class to use.
The default build context class creates a build context that works for the Docker daemon. Override this method if your image builder requires a custom context.
Returns:
Type | Description |
---|---|
Type[BuildContext]
|
The build context class. |
config
property
The stack component configuration.
Returns:
Type | Description |
---|---|
BaseImageBuilderConfig
|
The configuration. |
is_building_locally
abstractmethod
property
Whether the image builder builds the images on the client machine.
Returns:
Type | Description |
---|---|
bool
|
True if the image builder builds locally, False otherwise. |
build(image_name, build_context, docker_build_options, container_registry=None)
abstractmethod
Builds a Docker image.
If a container registry is passed, the image will be pushed to that registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_name
|
str
|
Name of the image to build. |
required |
build_context
|
BuildContext
|
The build context to use for the image. |
required |
docker_build_options
|
Dict[str, Any]
|
Docker build options. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Optional container registry to push to. |
None
|
Returns:
Type | Description |
---|---|
str
|
The Docker image repo digest or name. |
Source code in src/zenml/image_builders/base_image_builder.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
BaseImageBuilderConfig
Bases: StackComponentConfig
Base config for image builders.
Source code in src/zenml/image_builders/base_image_builder.py
37 38 |
|
BaseImageBuilderFlavor
Bases: Flavor
, ABC
Base class for all ZenML image builder flavors.
Source code in src/zenml/image_builders/base_image_builder.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
config_class
property
implementation_class
property
type
property
BuildContext
Bases: Archivable
Image build context.
This class is responsible for creating an archive of the files needed to build a container image.
Source code in src/zenml/image_builders/build_context.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
dockerignore_file
property
The dockerignore file to use.
Returns:
Type | Description |
---|---|
Optional[str]
|
Path to the dockerignore file to use. |
__init__(root=None, dockerignore_file=None)
Initializes a build context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[str]
|
Optional root directory for the build context. |
None
|
dockerignore_file
|
Optional[str]
|
Optional path to a dockerignore file. If not
given, a file called |
None
|
Source code in src/zenml/image_builders/build_context.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
get_files()
Gets all regular files that should be included in the archive.
Returns:
Type | Description |
---|---|
Dict[str, str]
|
A dict {path_in_archive: path_on_filesystem} for all regular files |
Dict[str, str]
|
in the archive. |
Source code in src/zenml/image_builders/build_context.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
write_archive(output_file, archive_type=ArchiveType.TAR_GZ)
Writes an archive of the build context to the given file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_file
|
IO[bytes]
|
The file to write the archive to. |
required |
archive_type
|
ArchiveType
|
The type of archive to create. |
TAR_GZ
|
Source code in src/zenml/image_builders/build_context.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
LocalImageBuilder
Bases: BaseImageBuilder
Local image builder implementation.
Source code in src/zenml/image_builders/local_image_builder.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
config
property
The stack component configuration.
Returns:
Type | Description |
---|---|
LocalImageBuilderConfig
|
The configuration. |
is_building_locally
property
Whether the image builder builds the images on the client machine.
Returns:
Type | Description |
---|---|
bool
|
True if the image builder builds locally, False otherwise. |
build(image_name, build_context, docker_build_options=None, container_registry=None)
Builds and optionally pushes an image using the local Docker client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_name
|
str
|
Name of the image to build and push. |
required |
build_context
|
BuildContext
|
The build context to use for the image. |
required |
docker_build_options
|
Optional[Dict[str, Any]]
|
Docker build options. |
None
|
container_registry
|
Optional[BaseContainerRegistry]
|
Optional container registry to push to. |
None
|
Returns:
Type | Description |
---|---|
str
|
The Docker image repo digest. |
Source code in src/zenml/image_builders/local_image_builder.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
LocalImageBuilderConfig
Bases: BaseImageBuilderConfig
Local image builder configuration.
Source code in src/zenml/image_builders/local_image_builder.py
32 33 |
|
LocalImageBuilderFlavor
Bases: BaseImageBuilderFlavor
Local image builder flavor.
Source code in src/zenml/image_builders/local_image_builder.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
config_class
property
docs_url
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class
property
logo_url
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name
property
The flavor name.
Returns:
Type | Description |
---|---|
str
|
The flavor name. |
sdk_docs_url
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |