Skip to content
Docs Try Aspire

DockerfileBuilder Methods

Class Methods 5 members
Builder for creating Dockerfiles programmatically.
Adds a global ARG statement to define a build-time variable before any stages.
public class DockerfileBuilder
{
public DockerfileBuilder Arg(
string name)
{
// ...
}
}
name string The name of the build argument.
DockerfileBuilder The current DockerfileBuilder instance for method chaining.
Global ARG statements appear before the first FROM statement and can be used to parameterize the base image selection.
Adds a global ARG statement to define a build-time variable with a default value before any stages.
public class DockerfileBuilder
{
public DockerfileBuilder Arg(
string name,
string defaultValue)
{
// ...
}
}
name string The name of the build argument.
defaultValue string The default value for the build argument.
DockerfileBuilder The current DockerfileBuilder instance for method chaining.
Global ARG statements appear before the first FROM statement and can be used to parameterize the base image selection.
Adds a FROM statement to start a new named stage.
public class DockerfileBuilder
{
public DockerfileStage From(
string image,
string stageName)
{
// ...
}
}
image string The image reference (e.g., 'node:18' or 'alpine:latest').
stageName string The stage name for multi-stage builds.
DockerfileStage A stage builder for the new stage.
Adds a FROM statement to start a new stage.
public class DockerfileBuilder
{
public DockerfileStage From(
string image)
{
// ...
}
}
image string The image reference (e.g., 'node:18' or 'alpine:latest').
DockerfileStage A stage builder for the new stage.
WriteAsync(StreamWriter, CancellationToken) Section titled WriteAsync(StreamWriter, CancellationToken) Task
Writes the Dockerfile content to the specified IO.StreamWriter.
public class DockerfileBuilder
{
public Task WriteAsync(
StreamWriter writer,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
writer StreamWriter The IO.StreamWriter to write to.
cancellationToken CancellationToken optional A cancellation token.
Task A task representing the asynchronous write operation.