Skip to content
DocsTry Aspire
DocsTry

DockerfileBuilder Methods

ClassMethods5 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)
{
// ...
}
}
namestringThe name of the build argument.
DockerfileBuilderThe 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)
{
// ...
}
}
namestringThe name of the build argument.
defaultValuestringThe default value for the build argument.
DockerfileBuilderThe 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)
{
// ...
}
}
imagestringThe image reference (e.g., 'node:18' or 'alpine:latest').
stageNamestringThe stage name for multi-stage builds.
DockerfileStageA stage builder for the new stage.
Adds a FROM statement to start a new stage.
public class DockerfileBuilder
{
public DockerfileStage From(
string image)
{
// ...
}
}
imagestringThe image reference (e.g., 'node:18' or 'alpine:latest').
DockerfileStageA 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))
{
// ...
}
}
writerStreamWriterThe IO.StreamWriter to write to.
cancellationTokenCancellationTokenoptionalA cancellation token.
TaskA task representing the asynchronous write operation.