image.BakePlan
image.BakePlan
Represents a JSON bake plan for building Docker images using Docker Bake.
Usage
image.BakePlan()Attributes
| Name | Description |
|---|---|
| bake_file | Return the path to the bake file in the context directory. |
bake_file
Return the path to the bake file in the context directory.
bake_file: Path
Methods
| Name | Description |
|---|---|
| build() | Run the bake plan to build all targets. |
| from_image_targets() | Create a BakePlan from a list of ImageTarget objects. |
| remove() | Delete the bake plan file if it exists. |
| update_groups() | Update the default, image name, and image variant groups with the given UID. |
| write() | Write the bake plan to a file in the context directory. |
build()
Run the bake plan to build all targets.
Usage
build(
load=True,
push=False,
pull=False,
cache=True,
cache_from=None,
cache_to=None,
platforms=None,
set_opts=None,
clean_bakefile=True
)from_image_targets()
Create a BakePlan from a list of ImageTarget objects.
Usage
from_image_targets(context, image_targets, platforms=None, push=False)Parameters
context: Path-
The absolute path to the build context directory.
image_targets: list[ImageTarget]-
A list of ImageTarget objects to include in the bake plan.
platforms: list[str] | None = None-
Optional platform override (e.g., from CLI –platform flag). When provided, this takes precedence over each image target’s OS platform configuration for cache tag generation.
push: bool = False- If True, include cache-to in bake targets to push cache layers to the registry.
Returns
BakePlan- A BakePlan object containing the context, groups, and targets.
remove()
Delete the bake plan file if it exists.
Usage
remove()update_groups()
Update the default, image name, and image variant groups with the given UID.
Usage
update_groups(groups, uid, image_name, image_variant)Parameters
groups: dict[str, BakeGroup]-
The current groups of targets.
uid: str-
The unique identifier for the target.
image_name: str-
The name of the image.
image_variant: str- The variant of the image.
Returns
dict[str, BakeGroup]- The updated groups with the new target added.
write()
Write the bake plan to a file in the context directory.
Usage
write()