Dockerfile

Renders a recipe module into Dockerfile text.

Usage

Source

Dockerfile()

A recipe is an ordinary Python module whose top-level code declares stages and instructions. Wrap it in a Dockerfile and call render to produce the text, once per configuration.

Parameter Attributes

module: ModuleType

Example

import my_recipe text = Dockerfile(my_recipe).render(gpu=True)

Methods

Name Description
render() Render the recipe into Dockerfile text.

render()

Render the recipe into Dockerfile text.

Usage

Source

render(path=None, **config_values)

Rendering runs the recipe module a second time. The first run — the import that produced module — is the discovery pass, where every DSL call is a no-op and only context.register fires, declaring the config schema. This call validates config_values against that schema with pydantic, then re-executes the module body so each Stage and method call accumulates into the active build.

Parameters
path: str | Path | None = None

Where to write the rendered text. When given, the file is written; the text is returned either way.

**config_values: Any
One value per field the recipe registered with context.register. Every registered field is required, and values are validated before the render pass runs.
Returns
str
The rendered Dockerfile text.
Example

Dockerfile(my_recipe).render(tag=“v1.0.0”, path=“Dockerfile”)